ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | Q&A
Ask Your Question

How to publish a ROS msg on Linux terminal

asked 2015-10-07 18:00:21 -0600

Hossein gravatar image

I have a ros msg as follows

int32 x int32 y char type

I want to give values to them on linux terminal. Something like this:

rostopic pub /topic message -- 2 3 'x'

But it doesn't work. I am using ROS Diamond.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2015-10-08 06:50:50 -0600

theNerd247 gravatar image

The ROS wiki gives this as an answer example.

$ rostopic pub -r 10 /cmd_vel geometry_msgs/Twist  '{linear:  {x: 0.1, y: 0.0, z: 0.0}, angular: {x: 0.0,y: 0.0,z: 0.0}}'

Depending on your message type you can simply follow the pattern given above; in which case you won't need -- in your command. Instead wrap the message data in single quotation marks and use the YAML map syntax. For example:

$ rostopic pub /topic package/msg_type '{x: 1, y: 2, c: a, type: string}'
edit flag offensive delete link more


Im trying to publish this exact same msg using unity3d via RosBridge. But its not publishing. When i try publishing in ros ,it works. But doesnt publish using unity(which sends a JSON string)...

PS using ROS Kinetic along with unity 4.6.

shree_123 gravatar image shree_123  ( 2018-03-23 06:53:17 -0600 )edit

Thanks for the answer. For the command...

$ rostopic pub /topic package/msg_type '{x: 1, y: 2, c: a, type: string}'

it's worth mentioning that pay close attention to space(s)!! e.g. x: 1 will work but x:1 won't.

Milan gravatar image Milan  ( 2020-10-06 18:13:36 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools



Asked: 2015-10-07 18:00:21 -0600

Seen: 44,861 times

Last updated: Oct 08 '15