I think I can give another explanation for the error:
`[INFO] [1647531775.937463391] [rviz]: Message Filter dropping message: frame ‘camera_bot_base_link’ at time 2936.389 for a reason ‘the time stamp on the message is earlier than all the data in the transform cache.’
If I am wrong, please correct me.
We can print the current time and the time stamp of the odometry with the following code.
def _callback_cam_bot_odom(self, msg: Odometry): self.cam_bot_odom = msg self.get_logger().info( f"Current time is: {self.get_clock().now().to_msg()}.") self.get_logger().info( f"Time stamp in odometry is: {self.cam_bot_odom.header.stamp}.")
As shown in the above figure, the current time is T1 =1659319692; however, the time stamp of the odometry T2 is 2930.
Time T1 is so big because a lot of time has passed from the beginning of the time to this moment. I have heard a lot of stories about the beginning of the time. Some stories consider it the birthday of a great god that leads humans to reason and light (If I’m wrong, please forgive my ignorance). In a country with a high percentage of atheists, the beginning of the time is the birthday of a great leader and scientist. In another story, it may be a provision of international treaties.
Which story of the beginning of the time is used in ROS2?
Time T2 is so small because its time is counted from the beginning of the simulation. The Gazebo told all the nodes involved in the simulation should use this time.
Directly comparing T1 and T2 without transformation will be wrong because the beginning of time is different. If we consider T1 and T2 are time stamps of two pieces of the message, T1 is very young; however, T2 is too old.
When we chose the frame World as the fixed frame on the rviz2, the rviz2 starts to calculate where the frame rgb_camera_link_frame is. It calculates camera_bot_base_link, then chassis, then rgb_camera_link_frame.
It finds we have given the information between the Frame World and the Frame camera_bot_base_link through TransformStamped(), which is quite new with stamp T1. However, the calculation cannot go through because the information about camera_bot_base_link and chassis is too old with stamp T2. The chassis may be long gone. The information in the TF cache, which takes time stamp T2, comes too early and becomes too old. So here comes the error.