0
$\begingroup$

Rosanswers logo

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 . 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" [] [] [] []"

Originally posted by RichardVZ on ROS Answers with karma: 1 on 2023-06-16

Post score: 0

$\endgroup$

2 Answers 2

1
$\begingroup$

Rosanswers logo

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.


Originally posted by Mike Scheutzow with karma: 4903 on 2023-06-17

This answer was NOT ACCEPTED on the original site

Post score: 1


Original comments

Comment by RichardVZ on 2023-06-20:
This page helps a lot. Thank you!

$\endgroup$
0
$\begingroup$

Rosanswers logo

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.


Originally posted by Mostafa _1995 with karma: 11 on 2023-06-18

This answer was NOT ACCEPTED on the original site

Post score: 1


Original comments

Comment by RichardVZ on 2023-06-20:
This will work! I didn't know that this was possible thank you.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.