Sunday, December 1, 2024

Robot Operating System - ROS 2 - publish data to two topics once time

We want to publish data to your topic only once (rather than continuously)? To publish your command just once add the --once option. 








We have list of topic:

/ThuyTrang/cmd_vel

/ThuyTrang/color_sensor

/ThuyTrang/pose

/parameter_events

/rosout

/turtle1/cmd_vel

/turtle1/color_sensor

/turtle1/pose



We can use 3 command line look like

1. ros2 topic pub --once /turtle1/cmd_vel geometry_msgs/msg/Twist "{linear: {x: 2.0, y: 0.0, z: 0.0}, angular: {x: 0.0, y: 0.0, z: 1.8}}"

2. ros2 topic pub --once /turtle1/cmd_vel geometry_msgs/msg/Twist "{linear: {x: 2.0, y: 0.0, z: 0.0}, angular: {x: 0.0, y: 0.0, z: 3.6}}"

3. ros2 topic pub --once /ThuyTrang/cmd_vel geometry_msgs/msg/Twist "{linear: {x: 2.0, y: 0.0, z: 0.0}, angular: {x: 0.0, y: 0.0, z: 1.8}}"




Clip of the first public data to topic /turtle1/cmd_vel
1. ros2 topic pub --once /turtle1/cmd_vel geometry_msgs/msg/Twist "{linear: {x: 2.0, y: 0.0, z: 0.0}, angular: {x: 0.0, y: 0.0, z: 1.8}}"





Clip of second public data to topic /turtle1/cmd_vel
2. ros2 topic pub --once /turtle1/cmd_vel geometry_msgs/msg/Twist "{linear: {x: 2.0, y: 0.0, z: 0.0}, angular: {x: 0.0, y: 0.0, z: 3.6}}"



Clip of third public data to topic /turtle1/cmd_vel
3. ros2 topic pub --once /ThuyTrang/cmd_vel geometry_msgs/msg/Twist "{linear: {x: 2.0, y: 0.0, z: 0.0}, angular: {x: 0.0, y: 0.0, z: 1.8}}"





Computer Vision + Robot Operating System (ROS 2) + Natural Language Processing service + Generative AI Chatbot +  Machine Learning + Mobile App + Web App? Yes, I do provide!


Call me: +84854147015

WhatsApp: +601151992689

https://amatasiam.web.app

Email: ThomasTrungVo@Gmail.Com

No comments:

Post a Comment