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

Use param for remapping in launch file

asked 2017-02-28 10:40:40 -0500

solosito gravatar image

Hello,

I have several nodes with common parameters so I tought it would be nice for debugging to have all of them just in one file and not in all of them. This is working fine but the problem is that remapping it is not able to retrieve this parameters. Is there any way for doing this? Either using the ROS API either scripting? This is an example of what I am trying to do:

<launch>
<node pkg="move_base" type="move_base" respawn="false" name="move_base" output="screen">
    <rosparam file="$(find car_navigation)/param/teb_local_planner_params.yaml" command="load" />

    <!-- Here are the params shared by several nodes -->
    <rosparam file="$(find car_bringup)/param/common_params.yaml" command="load" />

    <!-- Here is getting the parameter from the previous file and working properly-->
    <param name="x_size"            value="$(arg x_size)" />

    <!-- Here I am having the problem when remapping -->
    <remap from="cmd_vel"           to="$(arg vel_cmd_topic)"/>
    <remap from="max_speed"         to="$(arg max_speed)"/>
</node>

</launch>

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2017-03-26 01:48:49 -0500

jayess gravatar image

It looks like you're missing some <arg> tags above your <node> tag. Try this:

<launch>
<!-- name is the name of the variable, default is the default value if no value is specified -->
<arg name="vel_cmd_topic" default="default_topic"/>
<arg name="max_speed" default="a.bc"/>
<node pkg="move_base" type="move_base" respawn="false" name="move_base" output="screen">
    <rosparam file="$(find car_navigation)/param/teb_local_planner_params.yaml" command="load" />

    <!-- Here are the params shared by several nodes -->
    <rosparam file="$(find car_bringup)/param/common_params.yaml" command="load" />

    <!-- Here is getting the parameter from the previous file and working properly-->
    <param name="x_size"            value="$(arg x_size)" />

    <!-- Here I am having the problem when remapping -->
    <remap from="cmd_vel"           to="$(arg vel_cmd_topic)"/>
    <remap from="max_speed"         to="$(arg max_speed)"/>
</node>
</launch>

From the terminal, type:

roslaunch package_name launch_file_name.launch vel_cmd_topic:=topic_name max_speed:=x.yz

and replace these placeholders with your own values. I've never done this with <remap> tags, but I don't see why it wouldn't work.

edit flag offensive delete link more

Comments

I am not missing any argument, actually that's the point of my question. I am asking if there is any way to get the vel_cmd_topic and max_speed parameters from common_params.yaml for the remapping as I am doing with the x_size parameter.

solosito gravatar image solosito  ( 2017-03-27 09:28:35 -0500 )edit

Why don't you post your common_params.yaml?

jayess gravatar image jayess  ( 2017-03-27 09:47:51 -0500 )edit

Here you are:

#Common parameters
size_x: &size_x 0.8
vel_cmd: &vel_cmd 7
speed_max: &speed_max 0.9

#Params for motor1 and motor2
x_size: *size_x
vel_cmd_topic: *vel_cmd
max_speed: *speed_max

solosito gravatar image solosito  ( 2017-03-28 06:11:43 -0500 )edit

It is working for size_x but not for vel_cmd_topic neither for max_speed

solosito gravatar image solosito  ( 2017-03-28 06:15:29 -0500 )edit

Do you have to load these through a file? I know for sure that my method works for remapping topic names. I have a feeling that the way you're trying to do it won't work because you're loading the names as parameters and not as arguments, which is what you really want.

jayess gravatar image jayess  ( 2017-03-28 10:01:50 -0500 )edit

It would be a really big improvement for testing because that parameters are being used in a lot of independent nodes, so when I want to test with another value for it, I have to go through all the files and change them there.

solosito gravatar image solosito  ( 2017-03-28 10:51:26 -0500 )edit

hello have you managed to find a solution to this? cause i want to do exactly the same.

mustafaismail gravatar image mustafaismail  ( 2019-01-13 10:12:33 -0500 )edit

@mustafaismail not sure as this question is nearly two years old. You should ask a new question and reference this one.

jayess gravatar image jayess  ( 2019-01-13 14:53:37 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2017-02-28 10:40:40 -0500

Seen: 2,952 times

Last updated: Mar 26 '17