No optical flow data from PX4Flow with Pixhawk 4

Hello all,

I have a PX4Flow and a pixhawk4. I connected the PX4Flow to the pixhawk 4 via I2C per the instruction below.
Link: https://docs.px4.io/v1.9.0/en/sensor/px4flow.html
The green, blue, and orange LED lights on PX4Flow were flashing when connected.
However, I do not see any optical flow data on QGC.

When I connect the PX4Flow to PC via USB cable, I see optical flow data on QGC.

Could anyone tell me how I can use PX4Flow with Pixhawk4?

Thanks in advance.

Hello,

If you do not have any other positioning device connected, are you having Local Position data in Mavlink Inspector?

Thank you very much for your reply.
I have a LightWare SF11/C laser rangefinder connected and see the distance data in Mavlink Inspector. GPS is not connected.
Also, I set the EKF2_AID_MASK as 2 (use optical flow).
I really appreciate your help.

In newer versions of px4 there is an optical flow enable parameter that has to be set to one. To see this parameter QGC needs to be up to date.

Thank you very much for your help.
I updated QGC and set the optical flow enable parameter to one.
Now, I see the optical flow message in the MAVlink Inspector, however I get zero values for most of the parameters of the optical flow as shown in the attached image below.
Do you have any idea why it’s happening?

1 Like

When the camera does not see enough contrast to identify movement the px4flow board returns 0’s. You can use the usb port on the flow sensor to see if the lens is focused in QGC. Unplug the flow sensor from the pixhawk when you do this of you can damage the i2c power out on the pixhawk. For indoor flight I had to mount a pretty bright led to the bottom of the airframe.

I really appreciate your prompt response.
When I connect the px4flow via USB cable, I can see the nonzero values in QGC as shown in the attached image below.
However, when I connect the px4flow using I2C cable, I do not receive any values for x/y parameters as shown in my previous post. It seems that I get the distance value from the sonar sensor from the px4flow.

There are a bunch of conditions that need to be met for the data to be sent including the distance being valid and minimum image qualities being met. If you focus the lens to about 6ft and go outside on a sunny day over a highly textured surface it will send the data packet. If you want to do stuff like fly near the ground you have to modify and rebuild the code and replace the sonar with something that works closer to the ground.

Thank you very much for your advise.

I did the following two tests under the same condition (indoor).
However, I get different results and px4flow with I2c does not receive full values.

(Test 1) px4flow connected to QGC via USB cable
Result:
most of the parameter values received except for flow_rate_x and flow_rate_y
QGC MAVlink Inspector Screenshot:
https://discuss.px4.io/uploads/default/original/2X/5/55f9ff0d74316289e43cb5f42733779437a8e73a.png

(Test 2) px4flow connected to pixhawk 4 via I2C cable.
Result:
no values received except for distance value
QGC MAVlink Inspector Screenshot:
https://discuss.px4.io/uploads/default/original/2X/1/16921266dbad0ecfca4be0dad5e494d578047c21.png

Make the scenario where the quality goes to 255 with the usb in. My drone with optical flow has a huge led light on the bottom of it. The px4flow tab should be the video stream so get the focus really sharp and show it a non reflective surface with a lot of texture and contrast.

Thank you very much for your advise.
I did the tests below after the focus is adjusted.
I’m still wondering why the Test 2 result (with I2C cable) is different from the Test 1 result (with USB) under the same environment with lighting and surface condition.

Test Results:

I did the following two tests under the same condition (indoor).
However, I get different results and px4flow with I2c does not receive full values.

(Test 1) px4flow connected to QGC via USB cable
Result:
most of the parameter values received except for flow_rate_x and flow_rate_y
QGC MAVlink Inspector Screenshot:
https://discuss.px4.io/uploads/default/original/2X/5/55f9ff0d74316289e43cb5f42733779437a8e73a.png

(Test 2) px4flow connected to pixhawk 4 via I2C cable.
Result:
no values received except for distance value
QGC MAVlink Inspector Screenshot:
https://discuss.px4.io/uploads/default/original/2X/1/16921266dbad0ecfca4be0dad5e494d578047c21.png

There is logic on the px4flow boards microcontroller that will declare the data invalid and replace its measured data with 0’s to prevent false data from crashing the vehicle. In the screenshot with the i2c data showing 0’s the distance is 0.3 which is invalid because the sonar will report false data at that distance. In both screenshots the quality is below 200 which isn’t great. You need to focus the lens to the height you will be flying at which needs to be more that 0.7m without modifying the firmware. I have found that normal indoor lighting is not enough for this camera so either taking it outside or getting a really bright light is needed.

I’m sorry for my late reply. It took me a while to investigate. I appreciate your help.

↑ Thank you for this information.

When I got the screenshots in my previous post, the distance was about 0.3m. But, even at around 2m, the i2c data with the focus adjusted shows 0’s all the time although the USB data shows nonzero values.

I understand the normal indoor lighting may not be enough, but I don’t understand why USB data shows nonzero values and the i2c data shows 0’s values under the same lighting condition.

The data packet usb is not the same as i2c.


If you go through the code and comment out anytime data_valid is set false it would not send the 0’s but you would crash your drone because it would send the flight controller velocity figures that are not real and cause the ekf to reset. The flow board is basically saying to the flight controller just keep integrating imu data for velocity until I get a good reading. It is possible that the firmware has been updated on the px4flow board which can be flashed from QGC or a desktop build and newer versions of the PX4 firmware may help with dealing with optical flow.
1 Like

Thank you very much for your help. I really appreciate it. I will investigate it more.

Hellow
Can You help me how you enable optical Flow Parameter

Hello,
we have DOCs for it.

https://docs.px4.io/v1.9.0/en/sensor/px4flow.html

Hi, I am facing a similar issue:

  • Pixhawk 4 mini
  • PX4flow v1.3
  • connection: USART3 of PX4Flow <=> UART&I2C b port of the pixhawk mini
  • Parameter: SENS_EN_PX4FLOW set to 1
  • connection via USB works nicely and everything is in QGC

So far all good, but then:

  • mavlink console: px4flow start shows “ERROR [SPI_I2C] need to specify a bus type”
  • mavlink inspector: Optical_flow_rad does not show up

Any hints or ideas?

PS: USART3 is correct according to the manual (see below), but in ardupilot, they recommend to use the I2C port of the PX4flow

@ticotico have you solved this yet?