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

Spawning via gazebo_ros spawn_entity seems to not put /tf into namespace

asked 2022-08-30 03:16:05 -0600

Zeckurbo gravatar image

updated 2022-08-30 03:39:24 -0600

Hello,

I want to spawn a robot dynamically via

ros2 run gazebo_ros spawn_entity.py -entity robot1 -x 0 -y 0 -z 0 -file ~/turtlebot3_ws/install/turtlebot3_gazebo/share/turtlebot3_gazebo/models/turtlebot3_waffle_pi/model.sdf -robot_namespace robot1

but when I do so, the /tf topic seems to be outside of the namespace. I did an echo of it with 2 robots running, but I could not distinguish data from the header of the messages.

Many documentation and tutorials only cover the general purpose, but I was not able to get any information wether /tf should be /robot1/tf so far. Do you know if this is ok, or how I can remap etc.?

Edit: Because its the same .sdf file, and /tf only transforms relations for the robots parts, this could be ok, right?

Thank you very much

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2022-08-30 03:38:53 -0600

ljaniec gravatar image

updated 2022-08-30 03:51:42 -0600

It should look similar to this:

  • In your launch files:

    remappings = [('/tf', 'tf'), ('/tf_static', 'tf_static')]

  • and then in each of your nodes using /tf:

    Node(
        package='your_package',
        executable='your_package_executable',
        namespace=namespace,
        parameters=[parameters],
        remappings=remappings
    ),
    
  • in your urdf.xacro you should have:

<xacro:property name="robot_namespace" value="/$(arg namespace)"/>

  • in your YAML config files for e.g. Nav2 and in Python launchers - use from launch.substitutions import LaunchConfiguration, PythonExpression, Command, TextSubstitution and from nav2_common.launch import ReplaceString, RewrittenYaml, something like:

odom_topic: /namespace/odom etc. in YAML and namespaced_params= ReplaceString(source_file=param_dir, replacements={"/namespace":("/",namespace)}) in Python launch files.

I used it to distinguish themes, services and actions for two and more robots in ROS2 Gazebo simulation. It works ok, so I think such a thing should be at least acceptable :)

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2022-08-30 03:16:05 -0600

Seen: 2,073 times

Last updated: Aug 30 '22