Ask Your Question
3

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

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

NEngelhard gravatar image

Hey

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
4

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

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.

Try:

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

Or:

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

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

hamid gravatar image

Try this:

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

Comments

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 imageNEngelhard ( 2014-05-28 05:06:07 -0500 )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

1 follower

Stats

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

Seen: 2,819 times

Last updated: May 28 '14