@@ -67,22 +67,22 @@ Let's also make a new directory to store our saved recordings, just as good prac
67
67
68
68
.. code-block :: console
69
69
70
- mkdir bag_files
71
- cd bag_files
70
+ $ mkdir bag_files
71
+ $ cd bag_files
72
72
73
73
.. group-tab :: macOS
74
74
75
75
.. code-block :: console
76
76
77
- mkdir bag_files
78
- cd bag_files
77
+ $ mkdir bag_files
78
+ $ cd bag_files
79
79
80
80
.. group-tab :: Windows
81
81
82
82
.. code-block :: console
83
83
84
- md bag_files
85
- cd bag_files
84
+ $ md bag_files
85
+ $ cd bag_files
86
86
87
87
88
88
2 Choose a topic
@@ -427,6 +427,218 @@ You can see the service request from the bag file and the service response from
427
427
request: []
428
428
response: [{sum: 5}]
429
429
430
+ <<<<<<< HEAD
431
+ =======
432
+ Managing Action Data
433
+ --------------------
434
+
435
+ 1 Setup
436
+ ^^^^^^^
437
+
438
+ You'll be recording action data between ``fibonacci_action_client `` and ``fibonacci_action_server ``, then display and replay that same data later on.
439
+ To record action data between action client and server, ``Action Introspection `` must be enabled on the nodes.
440
+
441
+ Let's start ``fibonacci_action_client `` and ``fibonacci_action_server `` nodes and enable ``Action Introspection ``.
442
+ You can see more details for :doc: `Action Introspection Demo <../../Demos/Action-Introspection >`.
443
+
444
+ Open a new terminal and run ``fibonacci_action_server ``, enabling ``Action Introspection ``:
445
+
446
+ .. code-block :: console
447
+
448
+ $ ros2 run action_tutorials_py fibonacci_action_server --ros-args -p action_server_configure_introspection:=contents
449
+
450
+ Open another terminal and run ``fibonacci_action_client ``, enabling ``Action Introspection ``:
451
+
452
+ .. code-block :: console
453
+
454
+ $ ros2 run action_tutorials_cpp fibonacci_action_client --ros-args -p action_client_configure_introspection:=contents
455
+
456
+ 2 Check action availability
457
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^
458
+
459
+ ``ros2 bag `` can only record data from available actions.
460
+ To see the list of your system's actions, open a new terminal and run the command:
461
+
462
+ .. code-block :: console
463
+
464
+ $ ros2 action list
465
+ /fibonacci
466
+
467
+ To check if ``Action Introspection `` is enabled on the action, run the command:
468
+
469
+ .. code-block :: console
470
+
471
+ $ ros2 action echo --flow-style /fibonacci
472
+ interface: GOAL_SERVICE
473
+ info:
474
+ event_type: REQUEST_SENT
475
+ stamp:
476
+ sec: 1744917904
477
+ nanosec: 760683446
478
+ client_gid: [1, 15, 165, 231, 234, 109, 65, 202, 0, 0, 0, 0, 0, 0, 19, 4]
479
+ sequence_number: 1
480
+ request: [{goal_id: {uuid: [81, 55, 121, 145, 81, 66, 209, 93, 214, 113, 255, 100, 120, 6, 102, 83]}, goal: {order: 10}}]
481
+ response: []
482
+ ---
483
+ ...
484
+
485
+ 3 Record actions
486
+ ^^^^^^^^^^^^^^^^
487
+
488
+ To record action data, the following options are supported.
489
+ Action data can be recorded with topics and services at the same time.
490
+
491
+ To record specific actions:
492
+
493
+ .. code-block :: console
494
+
495
+ $ ros2 bag record --action <action_names>
496
+
497
+ To record all actions:
498
+
499
+ .. code-block :: console
500
+
501
+ $ ros2 bag record --all-actions
502
+
503
+ Run the command:
504
+
505
+ .. code-block :: console
506
+
507
+ $ ros2 bag record --action /fibonacci
508
+ [INFO] [1744953225.214114862] [rosbag2_recorder]: Press SPACE for pausing/resuming
509
+ [INFO] [1744953225.218369761] [rosbag2_recorder]: Listening for topics...
510
+ [INFO] [1744953225.218386223] [rosbag2_recorder]: Event publisher thread: Starting
511
+ [INFO] [1744953225.218580294] [rosbag2_recorder]: Recording...
512
+ [INFO] [1744953225.725417634] [rosbag2_recorder]: Subscribed to topic '/fibonacci/_action/cancel_goal/_service_event'
513
+ [INFO] [1744953225.727901848] [rosbag2_recorder]: Subscribed to topic '/fibonacci/_action/feedback'
514
+ [INFO] [1744953225.729655213] [rosbag2_recorder]: Subscribed to topic '/fibonacci/_action/get_result/_service_event'
515
+ [INFO] [1744953225.731315612] [rosbag2_recorder]: Subscribed to topic '/fibonacci/_action/send_goal/_service_event'
516
+ [INFO] [1744953225.735061252] [rosbag2_recorder]: Subscribed to topic '/fibonacci/_action/status'
517
+ ...
518
+
519
+ Now ``ros2 bag `` is recording the action data for the ``/fibonacci `` action: goal, result, and feedback.
520
+ To stop the recording, enter ``Ctrl+C `` in the terminal.
521
+
522
+ The data will be accumulated in a new bag directory with a name in the pattern of ``rosbag2_year_month_day-hour_minute_second ``.
523
+ This directory will contain a ``metadata.yaml `` along with the bag file in the recorded format.
524
+
525
+ 4 Inspect action data
526
+ ^^^^^^^^^^^^^^^^^^^^^
527
+
528
+ You can see details about your recording by running:
529
+
530
+ .. code-block :: console
531
+
532
+ $ ros2 bag info <bag_file_name>
533
+ Files: rosbag2_2025_04_17-22_20_40_0.mcap
534
+ Bag size: 20.7 KiB
535
+ Storage id: mcap
536
+ ROS Distro: rolling
537
+ Duration: 9.019568080s
538
+ Start: Apr 17 2025 22:20:47.263125070 (1744953647.263125070)
539
+ End: Apr 17 2025 22:20:56.282693150 (1744953656.282693150)
540
+ Messages: 0
541
+ Topic information:
542
+ Services: 0
543
+ Service information:
544
+ Actions: 1
545
+ Action information:
546
+ Action: /fibonacci | Type: example_interfaces/action/Fibonacci | Topics: 2 | Service: 3 | Serialization Format: cdr
547
+ Topic: feedback | Count: 9
548
+ Topic: status | Count: 3
549
+ Service: send_goal | Event Count: 4
550
+ Service: cancel_goal | Event Count: 0
551
+ Service: get_result | Event Count: 4
552
+
553
+ 5 Play action data
554
+ ^^^^^^^^^^^^^^^^^^
555
+
556
+ Before replaying the bag file, enter :kbd: `Ctrl - C ` in the terminal where ``fibonacci_action_client `` is running.
557
+ When ``fibonacci_action_client `` stops running, ``fibonacci_action_server `` also stops printing the result because there are no incoming requests.
558
+
559
+ Replaying the action data from the bag file will start sending the requests to ``fibonacci_action_server ``.
560
+
561
+ Enter the command:
562
+
563
+ .. code-block :: console
564
+
565
+ $ ros2 bag play --send-actions-as-client <bag_file_name>
566
+ [INFO] [1744953720.691068674] [rosbag2_player]: Set rate to 1
567
+ [INFO] [1744953720.702365209] [rosbag2_player]: Adding keyboard callbacks.
568
+ [INFO] [1744953720.702409447] [rosbag2_player]: Press SPACE for Pause/Resume
569
+ [INFO] [1744953720.702423063] [rosbag2_player]: Press CURSOR_RIGHT for Play Next Message
570
+ [INFO] [1744953720.702431404] [rosbag2_player]: Press CURSOR_UP for Increase Rate 10%
571
+ [INFO] [1744953720.702437677] [rosbag2_player]: Press CURSOR_DOWN for Decrease Rate 10%
572
+ Progress bar enabled at 3 Hz.
573
+ Progress bar [?]: [R]unning, [P]aused, [B]urst, [D]elayed, [S]topped
574
+ [INFO] [1744953720.702577680] [rosbag2_player]: Playback until timestamp: -1
575
+
576
+
577
+ ====== Playback Progress ======
578
+ [1744953656.281683207] Duration 9.02/9.02 [R]
579
+
580
+ Your ``fibonacci_action_server `` terminal will once again start printing the following service messages:
581
+
582
+ .. code-block :: console
583
+
584
+ [INFO] [1744953720.815577088] [fibonacci_action_server]: Executing goal...
585
+ [INFO] [1744953720.815927050] [fibonacci_action_server]: Feedback: array('i', [0, 1, 1])
586
+ [INFO] [1744953721.816509658] [fibonacci_action_server]: Feedback: array('i', [0, 1, 1, 2])
587
+ [INFO] [1744953722.817220270] [fibonacci_action_server]: Feedback: array('i', [0, 1, 1, 2, 3])
588
+ [INFO] [1744953723.817876426] [fibonacci_action_server]: Feedback: array('i', [0, 1, 1, 2, 3, 5])
589
+ [INFO] [1744953724.818498515] [fibonacci_action_server]: Feedback: array('i', [0, 1, 1, 2, 3, 5, 8])
590
+ [INFO] [1744953725.819182228] [fibonacci_action_server]: Feedback: array('i', [0, 1, 1, 2, 3, 5, 8, 13])
591
+ [INFO] [1744953726.820032562] [fibonacci_action_server]: Feedback: array('i', [0, 1, 1, 2, 3, 5, 8, 13, 21])
592
+ [INFO] [1744953727.820738690] [fibonacci_action_server]: Feedback: array('i', [0, 1, 1, 2, 3, 5, 8, 13, 21, 34])
593
+ [INFO] [1744953728.821449308] [fibonacci_action_server]: Feedback: array('i', [0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55])
594
+
595
+ This is because ``ros2 bag play `` sends the action goal request data from the bag file to the ``/fibonacci `` action.
596
+
597
+ We can also introspect action communication as ``ros2 bag play `` is playing it back to verify the ``fibonacci_action_server ``.
598
+
599
+ Run this command before ``ros2 bag play `` to see the ``fibonacci_action_server ``.
600
+ You can see the action goal request from the bag file and the service response from ``fibonacci_action_server ``:
601
+
602
+ .. code-block :: console
603
+
604
+ $ ros2 action echo --flow-style /fibonacci
605
+ interface: STATUS_TOPIC
606
+ status_list: [{goal_info: {goal_id: {uuid: [34, 116, 225, 217, 48, 121, 146, 36, 240, 98, 99, 134, 55, 227, 184, 72]}, stamp: {sec: 1744953720, nanosec: 804984321}}, status: 4}]
607
+ ---
608
+ interface: GOAL_SERVICE
609
+ info:
610
+ event_type: REQUEST_RECEIVED
611
+ stamp:
612
+ sec: 1744953927
613
+ nanosec: 957359210
614
+ client_gid: [1, 15, 165, 231, 190, 254, 1, 50, 0, 0, 0, 0, 0, 0, 19, 4]
615
+ sequence_number: 1
616
+ request: [{goal_id: {uuid: [191, 200, 153, 122, 221, 251, 152, 172, 60, 69, 94, 20, 212, 160, 40, 12]}, goal: {order: 10}}]
617
+ response: []
618
+ ---
619
+ interface: GOAL_SERVICE
620
+ info:
621
+ event_type: RESPONSE_SENT
622
+ stamp:
623
+ sec: 1744953927
624
+ nanosec: 957726145
625
+ client_gid: [1, 15, 165, 231, 190, 254, 1, 50, 0, 0, 0, 0, 0, 0, 19, 4]
626
+ sequence_number: 1
627
+ request: []
628
+ response: [{accepted: true, stamp: {sec: 1744953927, nanosec: 957615866}}]
629
+ ---
630
+ interface: STATUS_TOPIC
631
+ status_list: [{goal_info: {goal_id: {uuid: [191, 200, 153, 122, 221, 251, 152, 172, 60, 69, 94, 20, 212, 160, 40, 12]}, stamp: {sec: 1744953927, nanosec: 957663383}}, status: 2}]
632
+ ---
633
+ interface: FEEDBACK_TOPIC
634
+ goal_id:
635
+ uuid: [191, 200, 153, 122, 221, 251, 152, 172, 60, 69, 94, 20, 212, 160, 40, 12]
636
+ feedback:
637
+ sequence: [0, 1, 1]
638
+ ---
639
+ ...
640
+
641
+ >>>>>>> 278c507 (Add $ to Beginner-CLI-Tools and Beginner-Client Libraires (#5359))
430
642
Summary
431
643
-------
432
644
0 commit comments