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

Rostopic node in launch files

asked 2015-08-18 06:05:24 -0600

palfaro gravatar image

I'm trying to add a rostopic -pub node into a launch file, but I don't know what I have to put in the launch file command line.

I guess this has to be the structure:

<node pkg="rostopic" type="pub" name="arbitrary_name" args=" /pkg_topic pkg_executable_file/message" output="screen"/>

Thank you for your comments.

edit retag flag offensive close merge delete

3 Answers

Sort by ยป oldest newest most voted
5

answered 2015-08-18 08:26:53 -0600

dornhege gravatar image

Actually the binary, i.e., type is also rostopic. The pub is just an argument passed to that. So, if you just move the pub to args, it should work:

<node pkg="rostopic" type="rostopic" name="arbitrary_name" args="pub /pkg_topic pkg_executable_file/message" output="screen"/>
edit flag offensive delete link more

Comments

one example could also be args="pub /my_controller/command std_msgs/Float64 50". In this case I am publishing an std_msgs/Float64 with data = 50 to topic /my_controller/command even though I didn't type data

ignacio gravatar image ignacio  ( 2021-04-07 06:25:15 -0600 )edit
1

answered 2018-05-25 13:27:16 -0600

Markus gravatar image

I use it like this:

<node pkg="rostopic" type="rostopic" name="default_camera_info" args="pub /openni2_grabber/camera/rgb/camera_info sensor_msgs/CameraInfo --latch --file=$(find openni2_grabber)/launch/default_high.camera_info" output="screen"/>
edit flag offensive delete link more
0

answered 2015-08-25 02:03:12 -0600

palfaro gravatar image

updated 2018-05-26 00:08:50 -0600

jayess gravatar image

It works, but when I use command lines I have to write a option of a integer list in which each one sends a message for different actions, for example 1 writes hello world, 2 writes have a nice day and 3 writes goodbye.

My command line is something like this

$ rostopic pub -1 /pkg_topic /pkg_executable_file/Message -- 1 "none"

So I write the launch file like this

<node pkg="rostopic" type="rostopic" name="arbitrary_name" args="pub /pkg_topic pkg_executable_file/message > -- 1 " output="screen"/>

When I try to add the last two commands the window closes.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2015-08-18 06:05:24 -0600

Seen: 6,830 times

Last updated: May 26 '18