roslaunch pass args from a python script [closed]
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.