ros2 / geometry2

A set of ROS packages for keeping track of coordinate transforms.
BSD 3-Clause "New" or "Revised" License
118 stars 195 forks source link

Added overriding namespaces in tf2_ros_py #641

Closed delihus closed 8 months ago

delihus commented 8 months ago

Related with https://github.com/ros2/geometry2/issues/433 and https://github.com/ros2/geometry2/issues/389 It gives the compatibility with nav2 (https://github.com/ros-planning/navigation2/blob/main/nav2_bringup/launch/navigation_launch.py#L60) architecture which gives every tf topic for every robot e. g.: robot1: /robot1/tf robot2: /robot2/tf

Added test passes:

colcon test --packages-select tf2_ros_py
Starting >>> tf2_ros_py
Finished <<< tf2_ros_py [1.32s]          

Summary: 1 package finished [1.51s]
clalancette commented 8 months ago

You can already do this remapping:

ros2 run robot_state_publisher robot_state_publisher --ros-args -r /tf_static:=/foo/tf_static -p robot_description:='<robot name="foo"><link name="link1"/></robot>'

So I don't think we need to take this. But I'll leave it open for a little while longer to get more comments.

buckleytoby commented 8 months ago

I'll give a concrete example as to why it would be very nice to have this system over using tf_prefixes: I have an avatar robot and an operator robot. I publish their respective tf trees on separate tf topics /avatar/tf and /operator/tf for clarity and to make debugging with rviz easier by reducing the total number of frames within the tree. Within one node, I want to have two transform listeners, one for /avatar/tf and one for /operator/tf so that I can see how the operator transforms have changed and then apply that change to the avatar's transforms so that the avatar replicates the operator's motion. Currently this is impossible, instead I have to use prefixes for each published tf and my listener subscribes to /tf. While this allows my avatar to replicate operator movement, it's undesirable as my tf-tree is flooded with frames making it harder to see what's going on on each side.

delihus commented 8 months ago

Thank you for the explanation. Solving my issue I used cli_args in rclpy.

Node(
    name,
    namespace=namespace,
    cli_args=["--ros-args", "-r", "/tf:=tf", "-r", "/tf_static:=tf_static"],
)