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

Failed to get parameters after launching .launch file from another .launch file? [closed]

asked 2021-04-17 19:40:15 -0600

aarsh_t gravatar image

updated 2021-04-19 02:20:22 -0600

I have .launch (turtlebot3.launch) file in which I am launching a node, that needs parameters. I take parameters as argument in launch file (turtlebot3.launch) such as x, y, radius etc under node /spawn. I am launching this file multiple times with other launch file (multi_robots.launch).

<group ns="$(arg robot1)">
    <include file="$(find path_planning)/launch/turtlebot3.launch">
        <arg name="robot" value="$(arg robot1)"/>
        <arg name="radius" value="0.08"/>
        <arg name="x" value="5."/>
        <arg name="y" value="6."/>
        <arg name="theta" value="0."/>
        <arg name="x_goal" value="6."/>
        <arg name="y_goal" value="2."/>
        <arg name="theta_goal" value="0."/>
        <arg name="robot_color" value="[50,50,50]"/>
        <arg name="laser_color" value="[0,255,0]"/>
    </include>
</group>

Basically, args passed here above are parameters for another launch file.

Now there are parameters for robot1/spawn such as x, y, radius. But when I try to get parameters

rospy.get_param('/robot1/spawn/radius')

It raises KeyError: '/robot1/spawn/radius'

They are not shown in the rosparam list either.

I am not sure If something like this is possible or not. If not, is there any suggestions I can try? I need parameters(mainly radius and start) for each robots in one node.

ROS noetic, Python3

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by aarsh_t
close date 2021-04-26 06:22:56.489126

2 Answers

Sort by ยป oldest newest most voted
0

answered 2021-04-19 11:35:30 -0600

aarsh_t gravatar image

It was noticed that spawn was being shut down before I access the parameters from /spawn due to that I was unable to catch the relative parameters of spawn node. As a solution, I defined same parameters under node I was using that parameter. I am passing these parameters as arguments in other launch file, It was just a small edit in launch file. Thank you @gvdhoorn for direction.

edit flag offensive delete link more
0

answered 2021-04-19 03:01:05 -0600

gvdhoorn gravatar image

But when I try to get parameters

rospy.get_param('/robot1/spawn/radius')

It raises KeyError: '/robot1/spawn/radius'

They are not shown in the rosparam list either.

that's because arg are not necessarily (ros)param.

args are arguments that get passed to the .launch file you include.

Whether they end up as parameters on the parameter server depends on what the included .launch file does with them.

edit flag offensive delete link more

Comments

they ends up as parameters in other launch file. Let me share snippet of other launch file (turtlebot3.launch)

<arg name="robot" default="waffle1"/>
<arg name="radius" default="0.08"/>
<arg name="x" default="2."/>
<arg name="y" default="1."/>
<arg name="theta" default="0."/>
<node pkg="map_simulator" type="spawn" name="spawn" output="screen">
    <param name="zero_joints" value="true"/>
    <param name="static_tf_odom" value="true"/>
    <param name="radius" value="$(arg radius)"/>
    <param name="x" value="$(arg x)"/>
    <param name="y" value="$(arg y)"/>
    <param name="theta" value="$(arg theta)"/>
</node>
aarsh_t gravatar image aarsh_t  ( 2021-04-19 03:46:36 -0600 )edit

It was noticed that spawn was being shut down before I access the parameters from /spawn due to that I was unable to catch the relative parameters of spawn node. As a solution, I defined same parameters under node I was using that parameter. I am passing these parameters as arguments in other launch file, It was just a small edit in launch file. Thank you @gvdhoorn for direction.

aarsh_t gravatar image aarsh_t  ( 2021-04-19 11:37:30 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2021-04-17 19:16:44 -0600

Seen: 782 times

Last updated: Apr 19 '21