view_frame.py can not receive the tf_static

asked 2021-11-01 06:51:14 -0500

JonyK gravatar image

I'm using dashing ubuntu 18.04 with robot_state_publisher on jetson nano

I've written a launch file to publish tf and tf_static by loading a urdf file through robot_state_publisher and joint_state_publisher node.

I can see the data by ros2 topic echo /tf and ros2 topic echo /tf_static

But I can neither see the tf_static in view_frame.py nor lookup_transform function

For example. here are the transforms of base_footprint to base_link and base_link to imu_link

image description

The strange thing is I can't see the static tf in the tf tree, image description

and I cannot see the static tf through lookup_transformation.

Traceback (most recent call last):
...
tf2.LookupException: "base_foorprint" passed to lookupTransform argument target_frame does not exist.

If necessary:

Here is my launch file

import os
import sys
from ament_index_python.packages import get_package_share_directory
from launch import LaunchDescription, LaunchService
from launch_ros.actions import Node
from launch.substitutions import LaunchConfiguration
from launch.actions import DeclareLaunchArgument
from launch.conditions import IfCondition, UnlessCondition
def generate_launch_description():

    urdf_file = os.path.join(get_package_share_directory('tianracer_description'), \
        'urdf/tianracer_compact.urdf')
    gui = LaunchConfiguration('gui', default=False)
    use_rviz = LaunchConfiguration('use_rviz', default=False)

    return LaunchDescription([
        DeclareLaunchArgument(
            name='gui',
            default_value="False",
            description="Flag to enable joint_state_publisher_gui"
        ),
        DeclareLaunchArgument(
            name='use_rviz',
            default_value="False",
            description="Flag to enable rviz"
        ),
        Node(
            package='robot_state_publisher',
            node_executable='robot_state_publisher',
            node_name='robot_state_publisher',
            output='screen',
            arguments=[urdf_file],
            parameters=[{"publish_frequency": 20.0}]
        ),
        Node(
            condition=UnlessCondition(gui),
            package='joint_state_publisher',
            node_executable='joint_state_publisher',
            node_name='joint_state_publisher',
            output='screen',
            arguments=[urdf_file]
        ),
        Node(
            condition=IfCondition(gui),
            package='joint_state_publisher_gui',
            node_executable='joint_state_publisher_gui',
            node_name='joint_state_publisher_gui',
            output='screen',
        ),
        Node(
            condition=IfCondition(use_rviz),
            package="rviz2",
            node_executable="rviz2",
            node_name="rviz2",
            output="screen",
        )
    ])

Any help is appreciated!

edit retag flag offensive close merge delete

Comments

It looks like a syntax error: tf2.LookupException: "base_foorprint" passed to lookupTransform argument target_frame does not exist. it should be base_footprint vs base_foorprint

osilva gravatar image osilva  ( 2021-11-01 08:02:44 -0500 )edit

Thanks for your careful inspection. But it is indeed not for this reason. Because the view_frame.py can't receive static tf either

This is the new log after I fix the typo Could not find a connection between 'base_link' and 'base_footprint' because they are not part of the same tree.Tf has two or more unconnected trees.

It comes from my test code

class Tf_test(Node):
    def __init__(self) -> None:
        super().__init__("listener")
        self.buffer = Buffer()
        self.listener = TransformListener(self.buffer, self)
        self.timer = self.create_timer(1.0, self.on_timer)

    def on_timer(self):
        now = rclpy.time.Time()
        trans = self.buffer.lookup_transform(
            "base_footprint",
            "base_link",
            now
        )
        print(trans)


def main():
    rclpy.init()
    node = Tf_test()
    rclpy.spin(node)
JonyK gravatar image JonyK  ( 2021-11-01 09:29:22 -0500 )edit

Please take a look at previous question

osilva gravatar image osilva  ( 2021-11-01 09:34:42 -0500 )edit