roslaunch pass args from a python script [closed]

asked 2020-01-25 12:30:15 -0600

davidem gravatar image

updated 2020-01-27 04:20:44 -0600

I have a multirobot navigation and I've defined a main.launch file where I include robot.launch, which is the single robot launch file that runs the spawner, amcl and move_base.
robot.launch requires 4 arguments (x,y,z coords + its namespace) which up to now have been given by the parent main.launch in this way:

<group ns="$(arg robot_1)">
    <include file="$(find my_pkg)/launch/robot.launch">
        <arg name="robot_ns" value="$(arg robot_1)" />
        <arg name="x_pos" value="-1" />
        <arg name="y_pos" value="1" />
        <arg name="z_pos" value="0" />
    </include>
</group>

I now wrote a gui script that lets the user decide how many robots to spawn. After inserting, for each robot, the necessary parameters, I thought it was sufficient to use the subprocess module to call something like:
roslaunch my_pkg robot.launch robot_ns:=VALUE x_pos:=VALUE y_pos:=VALUE z_pos:=VALUE

but since inside robot.launch there are other nested launch files (for amcl and move_base, which are very long files due to a huge amount of remapping tags) the arguments seem to not get passed to such files.

Is there a way to pass these args without needing to "refactor" the robot.launch, meaning that I have to paste the code from all the nested launch files?
I'm guessing roslaunch API could be useful, but when I imported the module in my script, following the docs example:

import roslaunch
import rospy

rospy.init_node('en_Mapping', anonymous=True)
uuid = roslaunch.rlutil.get_or_generate_uuid(None, False)
roslaunch.configure_logging(uuid)

my editor says that the roslaunch.rlutil.get_or_generate_uuid function doesn't exist in the module.

edit retag flag offensive reopen merge delete

Closed for the following reason question is off-topic or not relevant. Please see http://wiki.ros.org/Support for more details. by davidem
close date 2020-01-29 08:16:04.175313