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

Why Rviz2 not confused when ydlidar publishes static tf2?

asked 2021-09-21 19:01:06 -0500

RobotDreams gravatar image

updated 2021-09-22 18:48:03 -0500

I am building a ROS2 Foxy robot with the YDLIDAR X4 for 360 degree range scans. I'm a ROS2 noob and not comfortable that I understand what the robot_state_publisher and joint_state_publisher generate from the URDF.

I have been launching robot_state and joint_state publisher nodes on my ROS2 desktop when I launch Rviz2.

I was looking at the YDLIDAR ROS2 node running on the bot, and surprised to see that the launch file contains a static transform publisher:

tf2_node = Node(package='tf2_ros',
                    executable='static_transform_publisher',
                    name='static_tf_pub_laser',
                    arguments=['0', '0', '0.02','0', '0', '0', '1','base_link','laser_frame'],
                    )

    return LaunchDescription([
        params_declare,
        driver_node,
        tf2_node,

and my URDF has:

 <!-- LIDAR -->
  <link name="laser_frame">
    <visual>
      <origin xyz="0 0 0" rpy="0 0 0" />
      <geometry>
          <cylinder length="0.020" radius="0.0325" />
      </geometry>
      <material name="blue" />
    </visual>
  </link>

  <joint name="joint_ydlidar" type="fixed">
    <parent link="base_link"/>
    <child link="laser_frame"/>
    <origin xyz="-0.014 0 0.200" rpy="0 0 0" /> 
  </joint>

Why does the ydlidar pub that static transform?
Why does Rviz2 not get confused?

Is it because I launch the robot_state pub, joint_state pub, and Rviz2 after the bot and LIDAR are already running, so the LIDAR tf2 was pub'd into the ether with no subscriber at the time?)

C:\fakepath\Rviz2_LIDAR_Ultrasonic_V53L0X.png

ubuntu@rosdesk:~/handsonros2$ ros2 run tf2_ros tf2_echo base_link laser_frame

[INFO] [1632353862.239498120] [tf2_echo]: Waiting for transform base_link ->  laser_frame: Invalid frame ID "base_link" passed to canTransform argument target_frame - frame does not exist

(this is after the bot and LIDAR start up)

At time 0.0
- Translation: [0.000, 0.000, 0.020]
- Rotation: in Quaternion [0.000, 0.000, 0.000, 1.000]
At time 0.0
- Translation: [0.000, 0.000, 0.020]
- Rotation: in Quaternion [0.000, 0.000, 0.000, 1.000]

(this is after robot_state and joint_state pubs, and rviz2 start up)
At time 0.0
- Translation: [-0.014, 0.000, 0.200]
- Rotation: in Quaternion [0.000, 0.000, 0.000, 1.000]
At time 0.0
- Translation: [-0.014, 0.000, 0.200]
- Rotation: in Quaternion [0.000, 0.000, 0.000, 1.000]
At time 0.0
- Translation: [-0.014, 0.000, 0.200]
- Rotation: in Quaternion [0.000, 0.000, 0.000, 1.000]
edit retag flag offensive close merge delete

Comments

1

This is very interesting. Could you edit your question to include your tf tree and the output of ros2 run tf2_ros tf2_echo base_link laser_frame AFTER you have launched everything?

janindu gravatar image janindu  ( 2021-09-22 18:06:22 -0500 )edit

Thank you @janindu for not just answering my question but showing me how to answer the question.

RobotDreams gravatar image RobotDreams  ( 2021-09-22 20:28:59 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2021-09-22 20:43:18 -0500

RobotDreams gravatar image

updated 2021-09-22 20:44:15 -0500

I'm guessing the LIDAR manufacturer may have put a "stock" transform publishing into their node to make it convenient for folks bringing up just the LIDAR node for testing on their desk before integration into a robot.

Thanks to the suggestion of @janindu as to how to watch the transform publishing stream, it appears that it does not matter that the node publishes an invalid-for-my-bot transform as long as I start the robot_state and joint_state publisher after starting the lidar node.

I probably should comment out the publisher in the node and the launch files to prevent this confusing anyone that will look at my code. (There are a couple of us building ROS bots on the GoPiGo3 robot platform.)

edit flag offensive delete link more

Comments

1

" it appears that it does not matter that the node publishes an invalid-for-my-bot transform as long as I start the robot_state and joint_state publisher after starting the lidar node"

Not quite. You should not have wrong static transforms broadcasted. I ran the following test.

  1. Create 3 static transform publishers publishing three different transforms from frame A to frame B
  2. Echo the tf from A to B

I noticed that the tf echo outputs different transforms when I execute it multiple times. However, on a single execution it continues to publish the same transform. This seems to be because the tf listener caches static transforms (this is why RVIZ doesn't get confused). For personal interest I will dig deeper, but for your case, you should only have one static tf from base_link to laser_frame or otherwise you will have unpredictable behavior between different runs of your system.

janindu gravatar image janindu  ( 2021-09-23 18:42:06 -0500 )edit

Question Tools

2 followers

Stats

Asked: 2021-09-21 19:01:06 -0500

Seen: 248 times

Last updated: Sep 22 '21