Skip to content

设计:rosbag2 录制与回放 action

本设计描述如何基于当前架构实现该功能,以及如何扩展现有命令参数。

action 的实现基于三个服务(goal、result、cancel)和两个话题(status、feedback)。对于服务部分,当启用服务自省时,rosbag2 可以通过服务事件话题录制服务数据(参见服务录制与回放设计)。因此,与 action 相关的所有数据均可被录制。

  • goal 服务

    [NameSpace/]ActionName/_action/send_goal
    服务事件话题: [NameSpace/]ActionName/_action/send_goal/_service_event

  • result 服务

    [NameSpace/]ActionName/_action/get_result
    服务事件话题: [NameSpace/]ActionName/_action/get_result/_service_event

  • cancel 服务

    [NameSpace/]ActionName/_action/cancel_goal
    服务事件话题: [NameSpace/]ActionName/_action/cancel_goal/_service_event

  • status 话题

    [NameSpace/]ActionName/_action/status

  • feedback 话题

    [NameSpace/]ActionName/_action/feedback

对于一个 action,需要录制上述五个相关话题。

新增参数:

参数名描述
—actions ActionName [ActionName …]要录制的 action 列表,以空格分隔。
—all-actions通过服务事件话题和隐藏的 action 话题录制所有 action。
—exclude-actions ActionName [ActionName …]不录制的 action 列表,以空格分隔。在 —all、—all-actions、—actions 或 —regex 的基础上生效。

更新的参数:

参数名描述
-a, —all录制所有话题、服务和 action(排除隐藏话题)。
-e REGEX, —regex REGEX只录制包含给定正则表达式的话题、服务和 action。注意:—all、—all-topics、—all-services 或 —all-actions 会覆盖 —regex。
—exclude-regex EXCLUDE_REGEX排除包含给定正则表达式的话题、服务和 action。在 —all、—all-topics、—all-services、—all-actions、—topics、—services、—actions 或 —regex 的基础上生效。

新增 action 相关信息。

不带 -v 或 --verbose 参数时,info 命令的输出示例如下:

Files: <bag_name>.mcap
Bag size: 39.9 KiB
Storage id: mcap
ROS Distro: rolling
Duration: 4.835s
Start: Mar 18 2024 16:42:14.323 (1710805334.323)
End: Mar 18 2024 16:42:19.159 (1710805339.159)
Messages: 39
Topic information: Topic: /events/write_split | Type: rosbag2_interfaces/msg/WriteSplitEvent | Count: 0 | Serialization Format: cdr
Topic: /parameter_events | Type: rcl_interfaces/msg/ParameterEvent | Count: 0 | Serialization Format: cdr
Topic: /rosout | Type: rcl_interfaces/msg/Log | Count: 39 | Serialization Format: cdr
Services: 1
Service information: Service: /add_two_ints | Type: example_interfaces/srv/AddTwoInts | Event Count: 42 | Serialization Format: cdr
Actions: 2
Action information:
Action: /fibonacci | Type: action_tutorials_interfaces/action/Fibonacci | Topics: 2 | Services: 3 | Serialization Format: cdr
Topic: feedback | Count: 1
Topic: status | Count: 10
Service: send_goal | Event Count: 20
Service: cancel_goal | Event Count: 2
Service: get_result | Event Count: 9
Action: /other | Type: other_action_interfaces/action/Other | Topics: 2 | Services: 3 | Serialization Format: cdr
Topic: feedback | Count: 2
Topic: status | Count: 20
Service: send_goal | Event Count: 40
Service: cancel_goal | Event Count: 4
Service: get_result | Event Count: 9

带 -v 或 --verbose 参数时,info 命令的输出示例如下:

Files: <bag_name>.mcap
Bag size: 39.9 KiB
Storage id: mcap
ROS Distro: rolling
Duration: 4.835s
Start: Mar 18 2024 16:42:14.323 (1710805334.323)
End: Mar 18 2024 16:42:19.159 (1710805339.159)
Messages: 39
Topic information: Topic: /events/write_split | Type: rosbag2_interfaces/msg/WriteSplitEvent | Count: 0 | Serialization Format: cdr
Topic: /parameter_events | Type: rcl_interfaces/msg/ParameterEvent | Count: 0 | Serialization Format: cdr
Topic: /rosout | Type: rcl_interfaces/msg/Log | Count: 39 | Serialization Format: cdr
Services: 1
Service information: Service: /add_two_ints | Type: example_interfaces/srv/AddTwoInts | Request Count: 20 | Response Count: 22 | Serialization Format: cdr
Actions: 2
Action information:
Action: /fibonacci | Type: action_tutorials_interfaces/action/Fibonacci | Topics: 2 | Services: 3 | Serialization Format: cdr
Topic: feedback | Count: 1
Topic: status | Count: 10
Service: send_goal | Request Count: 10 | Response Count: 10
Service: cancel_goal | Request Count: 1 | Response Count: 1
Service: get_result | Request Count: 5 | Response Count: 4
Action: /other | Type: other_action_interfaces/action/Other | Topics: 2 | Services: 3 | Serialization Format: cdr
Topic: feedback | Count: 2
Topic: status | Count: 20
Service: send_goal | Request Count: 20 | Response Count: 20
Service: cancel_goal | Request Count: 2 | Response Count: 2
Service: get_result | Request Count: 5 | Response Count: 4

新增参数:

参数名描述
—actions action [action …]要回放的 action 列表,以空格分隔。
—exclude-actions action [action …]不回放的 action 列表,以空格分隔。
—send-actions-as-client分别根据录制的 send_goal、cancel_goal 和 get_result 事件消息发送 send_goal 请求、cancel_goal 请求和 get_result 请求。注意,action 的”status 话题” [NameSpace/]ActionName/_action/status 和”feedback 话题” [NameSpace/]ActionName/_action/feedback 中的消息不会被发送,因为这些消息预计由 action server 一方发送。

更新的参数:

参数名描述
-e REGEX, —regex REGEX只回放与正则表达式匹配的话题、服务和 action。
-x EXCLUDE_REGEX, —exclude-regex EXCLUDE_REGEX从回放中排除话题、服务和 action 的正则表达式。
—service-requests-source {service_introspection,client_introspection}确定要回放的服务请求的来源。该选项仅在设置了 “—publish-service-requests” 或 “—send-actions-as-client” 选项时才有意义。默认情况下,服务请求从录制的服务自省消息回放。