0
$\begingroup$

Rosanswers logo

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.


Originally posted by NEngelhard on ROS Answers with karma: 3519 on 2014-05-28

Post score: 3

$\endgroup$

2 Answers 2

0
$\begingroup$

Rosanswers logo

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'"

Originally posted by tfoote with karma: 58457 on 2014-05-28

This answer was ACCEPTED on the original site

Post score: 5

$\endgroup$
0
$\begingroup$

Rosanswers logo

Try this:

$rostopic pub -1 topic_name std_msgs/Char '123'

Originally posted by Hamid Didari with karma: 1769 on 2014-05-28

This answer was NOT ACCEPTED on the original site

Post score: 1


Original comments

Comment by NEngelhard on 2014-05-28:
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'}

$\endgroup$

Your Answer

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