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

**URL:** <https://discuss.px4.io/t/how-to-get-depth-data-from-the-px4-gazebo-simulation-and-visualize-it-in-rviz2/37916>\
**Category:** Uncategorized\
**Created:** [April 24, 2024, 3:56am UTC](https://discuss.px4.io/t/how-to-get-depth-data-from-the-px4-gazebo-simulation-and-visualize-it-in-rviz2/37916 "2024-04-24T03:56:43Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![rajeshpachaikani](https://discuss.px4.io/user_avatar/discuss.px4.io/rajeshpachaikani/32/16207_2.png) [@rajeshpachaikani](https://discuss.px4.io/u/rajeshpachaikani)\
**Post date:** [April 24, 2024, 3:56am UTC](https://discuss.px4.io/t/how-to-get-depth-data-from-the-px4-gazebo-simulation-and-visualize-it-in-rviz2/37916/1 "2024-04-24T03:56:43Z")

</div>

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.

```auto
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.

---

<div class="post-metadata">

**Author:** ![mrh](https://discuss.px4.io/letter_avatar_proxy/v4/letter/m/3ab097/32.png) [@mrh](https://discuss.px4.io/u/mrh)\
**Post date:** [January 25, 2025, 3:53pm UTC](https://discuss.px4.io/t/how-to-get-depth-data-from-the-px4-gazebo-simulation-and-visualize-it-in-rviz2/37916/2 "2025-01-25T15:53:25Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![lohitoburrito](https://discuss.px4.io/user_avatar/discuss.px4.io/lohitoburrito/32/18634_2.png) [@lohitoburrito](https://discuss.px4.io/u/lohitoburrito)\
**Post date:** [February 28, 2025, 2:52am UTC](https://discuss.px4.io/t/how-to-get-depth-data-from-the-px4-gazebo-simulation-and-visualize-it-in-rviz2/37916/3 "2025-02-28T02:52:42Z")

</div>

@mrh did you end up solving this?

---

<div class="post-metadata">

**Author:** ![YYXGIT-6](https://discuss.px4.io/user_avatar/discuss.px4.io/yyxgit-6/32/18809_2.png) [@YYXGIT-6](https://discuss.px4.io/u/YYXGIT-6)\
**Post date:** [March 15, 2025, 4:26pm UTC](https://discuss.px4.io/t/how-to-get-depth-data-from-the-px4-gazebo-simulation-and-visualize-it-in-rviz2/37916/4 "2025-03-15T16:26:22Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![lohitoburrito](https://discuss.px4.io/user_avatar/discuss.px4.io/lohitoburrito/32/18634_2.png) [@lohitoburrito](https://discuss.px4.io/u/lohitoburrito)\
**Post date:** [March 15, 2025, 4:42pm UTC](https://discuss.px4.io/t/how-to-get-depth-data-from-the-px4-gazebo-simulation-and-visualize-it-in-rviz2/37916/5 "2025-03-15T16:42:20Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![YYXGIT-6](https://discuss.px4.io/user_avatar/discuss.px4.io/yyxgit-6/32/18809_2.png) [@YYXGIT-6](https://discuss.px4.io/u/YYXGIT-6)\
**Post date:** [March 17, 2025, 2:50am UTC](https://discuss.px4.io/t/how-to-get-depth-data-from-the-px4-gazebo-simulation-and-visualize-it-in-rviz2/37916/6 "2025-03-17T02:50:15Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Pratik\_Wagh](https://discuss.px4.io/user_avatar/discuss.px4.io/pratik_wagh/32/18869_2.png) [@Pratik\_Wagh](https://discuss.px4.io/u/Pratik_Wagh)\
**Post date:** [April 24, 2025, 10:17pm UTC](https://discuss.px4.io/t/how-to-get-depth-data-from-the-px4-gazebo-simulation-and-visualize-it-in-rviz2/37916/7 "2025-04-24T22:17:22Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![haiha95](https://discuss.px4.io/letter_avatar_proxy/v4/letter/h/8baadc/32.png) [@haiha95](https://discuss.px4.io/u/haiha95)\
**Post date:** [March 25, 2026, 2:50am UTC](https://discuss.px4.io/t/how-to-get-depth-data-from-the-px4-gazebo-simulation-and-visualize-it-in-rviz2/37916/8 "2026-03-25T02:50:13Z")

</div>

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:

```auto
[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` .

---

<div class="post-metadata">

**Author:** ![Pratik\_Wagh](https://discuss.px4.io/user_avatar/discuss.px4.io/pratik_wagh/32/18869_2.png) [@Pratik\_Wagh](https://discuss.px4.io/u/Pratik_Wagh)\
**Post date:** [April 15, 2026, 2:52pm UTC](https://discuss.px4.io/t/how-to-get-depth-data-from-the-px4-gazebo-simulation-and-visualize-it-in-rviz2/37916/9 "2026-04-15T14:52:01Z")

</div>

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