Ask Your Question
5

Use rosparam get in launch file

asked 2015-07-08 09:44:19 -0500

cbandera gravatar image

Hi I am trying to launch a static_transform_publisher from the tf package. It has the following syntax:

static_transform_publisher x y z yaw pitch roll frame_id child_frame_id period_in_ms

which should be called from a launch file like this

<launch>
    <node pkg="tf" type="static_transform_publisher" name="link1_broadcaster" args="1 0 0 0 0 0 1 link1_parent link1 100" />
</launch>

What I am trying to achieve is to load the parameters x y z yaw pitch roll from a calibration (.yaml) file, just as I can load rosparams using the rosparam load syntax:

<rosparam command="load" file="$(find rosparam)/example.yaml" />

But I can't find a way to use the values from the parameter server and pass them via the args= Argument. I am hoping to find a launchfile-based solution instead of writing a node, that basicaly does the same as the static_transform_publisher node.

Does anyone have a solution?

PS: I do not want to hardcode the values into the launch file, because they might change. Not during runtime, but in between runs.

edit retag flag offensive close merge delete

Comments

My guess is that this is not possible.

dornhege gravatar imagedornhege ( 2015-07-08 10:06:09 -0500 )edit

You may want to edit the source so that those arguments are instead loaded via the parameter server instead of through the launch file.

luc gravatar imageluc ( 2015-07-08 12:53:32 -0500 )edit

1 Answer

Sort by » oldest newest most voted
1

answered 2015-11-06 09:16:57 -0500

Mathias Lüdtke gravatar image

Just stumbled upon this questions..

I would go for launch file arguments ( http://wiki.ros.org/roslaunch/XML/arg ):

<launch>
    <arg name="args" default="1 0 0 0 0 0 1 link1_parent link1 100"/>
    <node pkg="tf" type="static_transform_publisher" name="link1_broadcaster" args="$(arg args)"/>
</launch>

Maybe you should use one argument per parameter.

If you really want to use parameters, you can use this hackish solution that uses bash to append the arguments read by rosparam:

<launch>
    <param name="myargs" value="1 0 0 0 0 0 1 link1_parent link1 100"/> <!-- or elsewhere -->
    <node pkg="tf" type="static_transform_publisher" name="link1_broadcaster" launch-prefix="/bin/bash -c '$* `rosparam get myargs`' --"/>
</launch>
edit flag offensive delete link more

Comments

Hi, thanks for your replay. I will test this next time. In the meantime, I have written my own "static_transform_publisher_node" which is able to accept rosparams, and can even read from our custom file format. So this solved it for me.

cbandera gravatar imagecbandera ( 2015-11-06 09:43:22 -0500 )edit

It seems that the second hack doesn't work for me (ros indigo)

GuillaumeB gravatar imageGuillaumeB ( 2017-01-09 12:27:54 -0500 )edit

I have just run a test on kinetic and it works. And I am pretty sure I have tested it with indigo as well..

Mathias Lüdtke gravatar imageMathias Lüdtke ( 2017-01-14 15:29:21 -0500 )edit

Sorry, I just retried and it work. I don't know what was my test. Even the param overwrite work. Thx

GuillaumeB gravatar imageGuillaumeB ( 2017-01-16 05:16:43 -0500 )edit

This hackish solution works for me. How can I use it with a namespace? For example get /"namespace"/sensor_pos_0' <group ns="tower_0"> <node pkg="tf" type="static_transform_publisher" name="sensor_pose_0" launch-prefix="/bin/bash -c '$*rosparam get /tower_0/sensor_pos_0`' --"/>

</group>

Chrisando gravatar imageChrisando ( 2017-01-26 11:53:03 -0500 )edit

rosparam retrieve its data relative the to namespace of the <node>. rosparam get /tower_0/param should work as well as rosparam get param. Please do not name your parameter the same as your node as it turns sensor_pos_0 into a namespace.

Mathias Lüdtke gravatar imageMathias Lüdtke ( 2017-01-27 06:44:47 -0500 )edit

Thank you @Mathias Lüdtke I works as you said.

Chrisando gravatar imageChrisando ( 2017-01-27 07:21:09 -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

3 followers

Stats

Asked: 2015-07-08 09:44:19 -0500

Seen: 3,157 times

Last updated: Nov 06 '15