How to get depth data from the PX4 Gazebo simulation and visualize it in RVIZ2?

I started the simulation using make px4_sitl gz_x500_depth and able to control the simulated drone using QGroundControl as well.

I used the ros_gz_bridge to publish camera and point cloud data.

ros2 run ros_gz_bridge parameter_bridge /camera@sensor_msgs/msg/Image@ignition.msgs.Image /camera_info@sensor_msgs/msg/CameraInfo@ignition.msgs.CameraInfo /depth_camera/points@sensor_msgs/msg/PointCloud2@gz.msgs.PointCloudPacked /depth_camera@sensor_msgs/msg/Image@ignition.msgs.Image

I added objects infront of the camera and able to visualize the images in RVIZ2.

I added the PointCloud2 topic into RVIZ2 display but there is no depth point cloud displayed. I am seeing a warning message that says “Fixed Frame No tf data. Actual error: Frame [base_link] does not exist” in the Global Status widget.

Any help is much appreciated. Thank you.

do you solve it?i don’t know how to subscribe the topic of camera,and i use ros2 topic list i can not see the topic of depth camera

@mrh did you end up solving this?

I also have this problem , did you end up solving this?

No I did not. Honestly, I feel like Gazebo Classic just runs better on my machine. I was able to get depth data and raw rgb with it, but the issue now is, I cannot run multiple UAVs at a time.

Thanks for your response! Now I think I’ve discovered my problem,The key lies in the version issues of Gazebo and ros_gz-bridge, my ros2 version is humble and my gazebo version is harmonic.Instruction: sudo apt install ros-humble-ros-gzharmonic should be used ,but I installed ros-humble-ros-gz incorrectly.

i also got the same problem when i used different custom sdf file to run the depth simulation , and got tf2 error , rviz2 uses default frame as “map” u have to find correct tf2 frame and change it i dont know how to find it , but from my sdf file i added the camera link address like “base_link/depth_camera_link” and after that i was able to visualize the depth data in rviz2

hope this helps someone

Thank you @Pratik_Wagh.

I want to add one more thing about that “correct tf2 frame”. One hint I have been using is checking the terminal with Message Filter dropping message, you can actually use the frame it mentions as Fixed Frame in rviz2 for quick check. For example:

[INFO] [1774406417.562504108] [rviz]: Message Filter dropping message: frame 'x500_depth_0/camera_link/StereoOV7251' at time 2058.312 for reason 'discarding message because the queue is full'

By using the exact frame x500_depth_0/camera_link/StereoOV7251 I can see the PointCloud2 in rviz2.

For later usage, you can do tf2 transformation between that frame and your whatever world frame is, based on the pose of the sensor in your sdf .

i also got to know about that after a while . thanks !