0
$\begingroup$

I am trying to get the transformation from my forklift robot's base link to the fork frame but I am struggling to understand how I can supply a namespace to rclpy's TransformListener. I have tried to append the namespace directly to the frame when passing it to the constructor i.e. 'forklift_1/fork' and also tried the same without a namespace. However, in both cases I get an error saying that the frame does not exist, even though using tf2_echo through the terminal shows the transform correctly. I am suspecting it has something to do with the namespace?

$\endgroup$

1 Answer 1

0
$\begingroup$

there is a discourse.ros.org discussion on this topic. Essentially, you just put all transform-topics into namespaces. E.g. in a launch.py-file you can pass a remapping to any node making absolute paths /tf and /tf_static to relative paths tf and tf_static

my_node = Node(
        package='my_package',
        executable='my_executable',
        name='my_node_name',
        namespace="my_namespace",
        output='screen',
        parameters=[os.path.join(some_path, 'config.yaml')],
        remappings=[
                    ('/tf', 'tf'),
                    ('/tf_static', 'tf_static'),
                ]
    )

which will result in topics /my_namespace/tf and /my_namespace/tf_static. Do this for both publishers and subscribers of the tf-topics.

There also seems to be a more elegant way, see this Pull request. To see if the namespaces work, you can

ros2 run tf2_tools view_frames --ros-args -r __ns:=/my_namespace -r /tf:=tf -r /tf_static:=tf_static

Disclaimer: This is NOT what you have already tried, which is Option C in the discussion above: using frame-prefixes.

Currently there is no best practice or even better a REP, yet it seems the namespace-way described above is the way to go.

$\endgroup$

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.