ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

How to find formating for rosmsg publishing on command line

asked 2023-06-16 15:56:25 -0500

RichardVZ gravatar image

updated 2023-06-18 09:37:03 -0500

lucasw gravatar image

I want to publish messages to my robot in order to get it to move in the command line but I can't figure out how to format the rostopic pub /topic /type <data>. I'm having issue with the data and how to find the format for it. I'll include a specific example below. Command Line Input:

$ rosmsg show gazebo_msgs/ModelStates
string[] name
geometry_msgs/Pose[] pose
  geometry_msgs/Point position
    float64 x
    float64 y
    float64 z
  geometry_msgs/Quaternion orientation
    float64 x
    float64 y
    float64 z
    float64 w
geometry_msgs/Twist[] twist
  geometry_msgs/Vector3 linear
    float64 x
    float64 y
    float64 z
  geometry_msgs/Vector3 angular
    float64 x
    float64 y
    float64 z

This is what I'm thinking. Someone please help!

rostopic pub -10 /gazebo/model_states gazebo_msgs/ModelStates '"Hello" [] [] [] []"
edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
1

answered 2023-06-17 08:34:03 -0500

Mike Scheutzow gravatar image

updated 2023-06-17 08:39:26 -0500

This terminal command will show you high-level help with various options:

$ rostopic pub --help
Usage: rostopic pub /topic type [args...]
...

The [args...]syntax is a yaml dictionary, which is explained here: http://wiki.ros.org/ROS/YAMLCommandLine

Also, it's a bad idea to publish to some topics if some node is already publishing. You may seriously confuse the subscribers to that topic.

edit flag offensive delete link more

Comments

This page helps a lot. Thank you!

RichardVZ gravatar image RichardVZ  ( 2023-06-20 12:58:55 -0500 )edit
1

answered 2023-06-18 00:20:51 -0500

Mostafa _1995 gravatar image

I think more clarification on what you exactly trying to achieve will be great.

But from what I understand if you have a problem with the message format on the terminal, when you use (rostopic pub), you can simply write

rostopic pub -10 /gazebo/model_states gazebo_msgs/ModelStates

Then press TAB button on your keyboard it will autocomplete with the message format required then you can change it with the required values.

edit flag offensive delete link more

Comments

This will work! I didn't know that this was possible thank you.

RichardVZ gravatar image RichardVZ  ( 2023-06-20 12:58:19 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2023-06-16 15:56:25 -0500

Seen: 94 times

Last updated: Jun 17 '23