Optical FLow uxrce ros2 pixhawk 6c - Set Position

Hello community, I’m trying to fly the drone by using only optical flow with ROS 2, UXRCE DDS architecture, and uORB Topics. I’m following the instructions provided in the PX4 documentation:

*UXRCE DDS architecture:
*uORB topics:

I’m using the VL53L1X rangefinder to measure the distance from the drone to the ground, along with a Raspberry Pi camera. Both are connected to the Jetson Orin.

My node receives data from the VL53L1X rangefinder and images from the camera. With this information, the node calculates the optical flow quality, flow_x, and flow_y in radians.

After calculating the flow, I publish the data using the SensorOpticalFlow message type (UORB message)
(SensorOpticalFlow (UORB message) | PX4 User Guide (main)).

I publish the message on this topic:

  - topic: /fmu/in/sensor_optical_flow
    type: px4_msgs::msg::SensorOpticalFlow

This message type requires the distance from the rangefinder (local_distance).

Then I set the parameters in the pixhawk by ground control:
Screenshot from 2024-03-21 19-14-35

After that:

  • I successfully run the UXRCE DDS agent on the onboard computer.

  • I successfully start the UXRCE DDS client on the Pixhawk.
    Screenshot from 2024-03-21 18-55-18

  • I execute my node, and then in the Mavlink Inspector, I can see the optical flow data (although I’m not sure why I cannot see the sensor_id and time_delta_distance_us ).
    Screenshot from 2024-03-21 18-56-25

The distance changes correctly in OPTICAL_FLOW_RAD when I move the drone in the z-axis. However, when I check the ODOMETRY & LOCAL_POSITION_NED, the value in the z-axis is different.
Screenshot from 2024-03-21 19-09-59

My question :

  • How should I set up the Pixhawk to fly using optical flow?
  • Do I need to publish only the value of the rangefinder to another node?
  • What is the purpose of publishing the distance into the topic /fmu/in/sensor_optical_flow with this structure type: px4_msgs::msg::SensorOpticalFlow?

Thank you in advance.

1 Like