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

Why can't I send "123" via rostopic pub?

asked 2014-05-28 02:03:01 -0600

NEngelhard gravatar image


I'm using an std_msgs/String topic to send some messages between nodes. During testing, I tried to send the string "123" via rostopic pub:

rostopic pub /topic_name std_msgs/String "123"

My rostopic echo received nothing, and I got the msg: [WARN] [WallTime: 1401278233.697819] Inbound TCP/IP connection failed: field data must be of type str

So i tried to do: rostopic pub /topic_name std_msgs/String "123a"

And the msg was sent perfectly.

Is there any reason for this behaviour? "123" is a valid string so there should be no reason to throw this error.

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted

answered 2014-05-28 07:44:31 -0600

tfoote gravatar image

The command line arguments are interpreted as yaml. However bash is parsing it before it runs. You either need to escape the quotes or quote the quotes otherwise they yaml parser will interpret it as a integer, which does not match str type.


$ rostopic pub /topic_name std_msgs/String \"123\"


$ rostopic pub /topic_name std_msgs/String "'123'"
edit flag offensive delete link more

answered 2014-05-28 03:23:47 -0600

Hamid Didari gravatar image

Try this:

$rostopic pub -1 topic_name std_msgs/Char '123'
edit flag offensive delete link more


No. It's a String-Topic so that I get a Could not process inbound connection: topic types do not match: [std_msgs/String] vs. [std_msgs/Char]{'message_definition': 'string data\n\n', 'callerid': '/listener', 'tcp_nodelay': '0', 'md5sum': '99d1', 'topic': '/poll_sub', 'type': 'std_msgs/String'}

NEngelhard gravatar image NEngelhard  ( 2014-05-28 05:06:07 -0600 )edit

Question Tools

1 follower


Asked: 2014-05-28 02:03:01 -0600

Seen: 6,016 times

Last updated: May 28 '14