# Obstacle Distance Message

**URL:** <https://discuss.px4.io/t/obstacle-distance-message/33352>\
**Category:** PX4 Autopilot\
**Created:** [July 20, 2023, 12:28pm UTC](https://discuss.px4.io/t/obstacle-distance-message/33352 "2023-07-20T12:28:21Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![pwn](https://discuss.px4.io/user_avatar/discuss.px4.io/pwn/32/13923_2.png) [@pwn](https://discuss.px4.io/u/pwn)\
**Post date:** [July 20, 2023, 12:28pm UTC](https://discuss.px4.io/t/obstacle-distance-message/33352/1 "2023-07-20T12:28:21Z")

</div>

I am trying to send obstacle distance camera from a companion computer running ROS2 Humble with uXRCE-DDS bridge. I can see via ros2 topic list and ros2 topic info and ros2 topic echo /fmu/in/obstacle\_distance that the data is being published, but in QGC I cannot find any indication that the obstacle distance is going through.  
Not sure if my code is wrong or not  
Currently using PX4\_SITL x500\_depth model on 1.14 branch

Code:

```
rclcpp::Publisher<px4_msgs::msg::ObstacleDistance>::SharedPtr distance_sensor_publisher_;
px4_msgs::msg::ObstacleDistance msg2{};

msg2.timestamp = this->get_clock()->now().nanoseconds() / 1000;
msg2.frame = 12U; //MAV_FRAME_BODY_FRD
msg2.sensor_type = 1U;
msg2.distances.fill(UINT16_MAX);
msg2.distances[0] = middleaveragedistance;
msg2.increment = 30;
msg2.min_distance = 70;
msg2.max_distance = 800;
msg2.angle_offset = 0;
distance_sensor_publisher_->publish(msg2);

```

---

<div class="post-metadata">

**Author:** ![bhaskar-glitch1](https://discuss.px4.io/user_avatar/discuss.px4.io/bhaskar-glitch1/32/9387_2.png) [@bhaskar-glitch1](https://discuss.px4.io/u/bhaskar-glitch1)\
**Post date:** [August 18, 2023, 5:54pm UTC](https://discuss.px4.io/t/obstacle-distance-message/33352/2 "2023-08-18T17:54:48Z")

</div>

Hi Did u tried implementing the code on drone?? is it working?? actually i also want to implement collision prevention sort of things on my drone using depth camera and ROS1 i need some help in sending obstacle distance message can you please help me out
