Robotics StackExchange | Archived questions

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

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/Tutorials/URDF/Using-URDF-with-Robot-State-Publisher.html#create-a-launch-file I tried something like:

    robotname = LaunchConfiguration('robotname')
    urdfpath = "/path/to/$(arg robotname)" urdf = os.path.join("/path/to/", robotname)
    with open(urdf, 'r') as infp: robot
    desc = infp.read()

But I can not join the path with the hand name

Any suggestions? Thanks

Asked by torydebra on 2022-06-01 06:02:07 UTC

Comments

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

Asked by Joe28965 on 2022-06-02 06:46:06 UTC

Thanks, this is a nice workaround:

TURTLEBOT3_MODEL = os.environ['TURTLEBOT3_MODEL']

Asked by torydebra on 2022-06-02 07:19:54 UTC

Answers