You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+119Lines changed: 119 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -38,6 +38,9 @@ These verbs are available for `ros2 bag`:
38
38
39
39
For up-to-date information on the available options for each, use `ros2 bag <verb> --help`.
40
40
41
+
Moreover, `rosbag2_transport::Player` and `rosbag2_transport::Recorder` components can be instantiated in `rclcpp` component containers, which makes possible to use intra-process communication for greater efficiency.
42
+
See [composition](#using-with-composition) section for details.
43
+
41
44
### Recording data
42
45
43
46
In order to record all topics currently available in the system:
@@ -345,6 +348,122 @@ For example, if we named the above XML launch script, `record_all.launch.xml`:
345
348
$ ros2 launch record_all.launch.xml
346
349
```
347
350
351
+
You can also invoke the `play` and `record` functionalities provided by `rosbag2_transport` package as nodes.
352
+
The advantage to use this invocation strategy is that the Python layer handling the `ros2 bag` CLI is completely skipped.
353
+
354
+
```python
355
+
import launch
356
+
357
+
def generate_launch_description():
358
+
return launch.LaunchDescription([
359
+
launch.actions.Node(
360
+
package='rosbag2_transport',
361
+
executable='player',
362
+
name='player',
363
+
output="screen",
364
+
parameters=["/path/to/params.yaml"],
365
+
)
366
+
])
367
+
```
368
+
369
+
## Using with composition
370
+
371
+
Play and record are fundamental tasks of `rosbag2`. However, playing or recording data at high rates may have limitations (e.g. spurious packet drops) due to one of the following:
ROS 2 C++ nodes can benefit from intra-process communication to partially or completely bypass network transport of messages between two nodes.
378
+
379
+
Multiple _components_ can be _composed_, either [statically](https://docs.ros.org/en/rolling/Tutorials/Intermediate/Composition.html#compile-time-composition-using-ros-services) or [dynamically](https://docs.ros.org/en/rolling/Tutorials/Intermediate/Composition.html#run-time-composition-using-ros-services-with-a-publisher-and-subscriber): all the composed component will share the same address space because they will be loaded in a single process.
380
+
381
+
A prerequirement is for each C++ node to be [_composable_](https://docs.ros.org/en/rolling/Concepts/Intermediate/About-Composition.html?highlight=composition) and to follow the [guidelines](https://docs.ros.org/en/rolling/Tutorials/Demos/Intra-Process-Communication.html?highlight=intra) for efficient publishing & subscription.
382
+
383
+
With the above requirements met, the user can:
384
+
- compose multiple nodes together
385
+
- explicitly enable intra-process communication
386
+
387
+
Whenever a publisher and a subscriber on the same topic belong to the same _composed_ process, and intra-process is enabled for both, `rclcpp` completely bypasses RMW layer and below transport layer (i.e. DDS). Instead, messages are shared via process memory and *potentially* never copied. Some exception hold, so please have a look to the [IPC guidelines](https://docs.ros.org/en/rolling/Tutorials/Demos/Intra-Process-Communication.html?highlight=intra).
388
+
389
+
Here is an example of Python launchfile composition. Notice that composable container components do not expect YAML files to be directly passed to them: parameters have to be "dumped" out from the YAML file (if you have one). A suggestion of possible implementation is offered as a starting point.
390
+
391
+
```python
392
+
import launch
393
+
import launch_ros
394
+
import yaml
395
+
396
+
'''
397
+
Used to load parameters for composable nodes from a standard param file
Here's an example YAML configuration for both composable player and recorder:
425
+
```yaml
426
+
recorder:
427
+
ros__parameters:
428
+
use_sim_time: false
429
+
record:
430
+
all: true
431
+
is_discovery_disabled: false
432
+
topic_polling_interval:
433
+
sec: 0
434
+
nsec: 10000000
435
+
include_hidden_topics: true
436
+
ignore_leaf_topics: false
437
+
start_paused: false
438
+
439
+
storage:
440
+
uri: "/path/to/destination/folder"
441
+
storage_id: "sqlite3"
442
+
max_cache_size: 20000000
443
+
```
444
+
and
445
+
```yaml
446
+
player:
447
+
ros__parameters:
448
+
play:
449
+
read_ahead_queue_size: 1000
450
+
node_prefix: ""
451
+
rate: 1.0
452
+
loop: false
453
+
# Negative timestamps will make the playback to not stop.
454
+
playback_duration:
455
+
sec: -1
456
+
nsec: 00000000
457
+
start_paused: false
458
+
459
+
storage:
460
+
uri: "path/to/rosbag/file"
461
+
storage_id: "mcap"
462
+
storage_config_uri: ""
463
+
```
464
+
465
+
For a full list of available parameters, you can refer to [`player`](rosbag2_transport/test/resources/player_node_params.yaml) and [`recorder`](rosbag2_transport/test/resources/recorder_node_params.yaml) configurations from the `test` folder of `rosbag2_transport`.
466
+
348
467
## Storage format plugin architecture
349
468
350
469
Looking at the output of the `ros2 bag info` command, we can see a field `Storage id:`.
0 commit comments