Ask Your Question
3

How to rostopic pub multiple line for std_msgs/String type topic

asked 2016-11-23 21:51:13 -0600

updated 2016-12-22 00:10:46 -0600

How to use rostopic pub to publish multiple line or \n or \r\r for std_msgs/String typed topic.

I tried as YAML commandLine said. but nothing works.

Thank you!!!

$ rostopic pub /send_BTSVR std_msgs/String ['test'] --- ['test2'] ---

Usage: rostopic pub /topic type [args...]

rostopic: error: no such option: ---

$ rostopic pub /send_BTSVR std_msgs/String ['test'] --- ['test2'] ---

Usage: rostopic pub /topic type [args...]

rostopic: error: no such option: ---

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
2

answered 2016-12-22 03:29:04 -0600

gvdhoorn gravatar image

Not sure about the approach the wiki describes, but at least in a Bash shell, the following works for me:

$ rostopic pub /send_BTSVR std_msgs/String "data: '\
first line

second line

third line
'"

note the \ after the '. This allows you to continue on the next line.

edit flag offensive delete link more
0

answered 2016-12-22 03:03:37 -0600

rbbg gravatar image

updated 2016-12-22 03:07:17 -0600

I never got the multi-line pub to work either. The only way I figured out how to send multiline strings using rostopic pub is to make a file like this (named test.yaml):

"first line

second line

third line"

and then use rostopic pub /send_BTSVR std_msgs/String -f test.yaml

Note that there is an empty line between the lines. I am pretty sure there's an easier/better way, but I don't know it and would love to hear if anyone has an idea?

edit flag offensive delete link more

Comments

gvdhoorn's answer seems work for me. you can have a try.

sonictl gravatar imagesonictl ( 2016-12-22 20:51: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

2 followers

Stats

Asked: 2016-11-23 21:51:13 -0600

Seen: 3,461 times

Last updated: Dec 22 '16