Robotics StackExchange | Archived questions

rostopic pub and echo in launch file

Hi I would like to test a node publishing things and seeing if they are arrived. What is the structure the launch file should have? I would like to modify the arguments as I want.

Asked by v.leto on 2019-10-29 07:26:55 UTC

Comments

Is #q216036 what you are looking for ?

Asked by Delb on 2019-10-29 07:53:54 UTC

I have read this answer but I don't understand what I should put in args=" /pkg_topic pkg_executable_file/message". My topic is /GPS/Data, my message type is wmcs_lib/GPSData with fields: float64 UTCTime wmcs_lib/LLD Position uint8 Fix float32 HDOP. I would like to print on one of these fileds.

Asked by v.leto on 2019-10-29 08:05:33 UTC

how i can put multi or many publisher in the same file launch, this tuto explain only on waya https://www.youtube.com/watch?v=K3hQekBi5qY

thanks

Asked by Siphax on 2021-11-25 21:16:36 UTC

Answers

To expand on the answer of #q216036 : you can use rostopic in your launch file exactly like you are using it in command line. You just need to set the attributes pkg and type to rostopic, then you can use the attribute args to pub/echo/info/list etc..with the propper arguments corresponding.

For example you can do :

<node pkg="rostopic" type="rostopic" name="name" args="list" output="screen"/>

This will simply output the result of rostopic list.

If you want to echo a topic, the template would be :

<arg name="topic_name"     default="A_TOPIC_NAME"/>
<node pkg="rostopic" type="rostopic" name="name" 
    args="echo $(arg topic_name)" output="screen"/>

Like that you can call your launch file and specify the topic in command line :

roslaunch YOUR_PACKAGE YOUR_LAUNCH_FILE topic_name:=YOUR_TOPIC

Asked by Delb on 2019-10-29 08:26:13 UTC

Comments