[ROS2] equivalent of "textfile" argument from ROS1 launch file

asked 2022-06-01 06:02:40 -0500

torydebra gravatar image

updated 2022-06-02 06:12:32 -0500

I am developing a ROS2 version of a package, but I am stuck with the launch file. What I had for ROS1 is this:

<arg name="robot_name"/>
<param name="robot_description" textfile="/path/to/$(arg robot_name).urdf"/>

This permitted to read the urdf and to load its content in the robot_description parameter.
In ROS2 xml launches, textfile is not supported anymore.

Options are:

  1. Some tricks to still using xml (with the "command" argument?)
  2. Using the python launchfile. In this case I have trouble because I can not concatenate LaunchConfiguration and str. From https://docs.ros.org/en/foxy/Tutorial... I tried something like:

    robot_name = LaunchConfiguration('robot_name')
    urdf_path = "/path/to/$(arg robot_name)" urdf = os.path.join("/path/to/", robot_name)
    with open(urdf, 'r') as infp: robot_desc = infp.read()

But I can not join the path with the hand name

Any suggestions? Thanks

edit retag flag offensive close merge delete

Comments

Would the turtlebot solution work for you? They use an environment set in Ubuntu and concatenate them as shown in the link.

Joe28965 gravatar image Joe28965  ( 2022-06-02 06:46:06 -0500 )edit

Thanks, this is a nice workaround:

TURTLEBOT3_MODEL = os.environ['TURTLEBOT3_MODEL']
torydebra gravatar image torydebra  ( 2022-06-02 07:19:54 -0500 )edit