Optical Flow Sensor for ArduRover

Hi,

I have an optical flow sensor that I would like to incorporate onto the ArduRover software. The optical flow sensor is a PMW3901 based break out board that uses SPI from Pimoroni PMW3901 Optical Flow Sensor Breakout (pimoroni.com)

As the Ardupilot code already has a library for the Pixart breakout board which uses SPI, I’ve went ahead and connect the OF sensor directly onto the ardupilot via SPI but I am not receiving any output.

In Adding OF sensor support to Rover it seems that Rover nows support the use of optical flow sensor, but in the Mission Planner I am unable to tick the Optical Flow check box (enable it) under the optional hardware tab. I have set the ‘FLOW_TYPE’ parameter to ‘2’ but the optical flow sensor is still 0. Can anyone please help?

Which flight controller are you using? Support for the PMW3901 isn’t always included by default.

Hi @stephendade I am using a Matek H743 - Wing V3 Flight Controller.

I’d assumed that since the libraries are available for Rover, the support for PMW3901 would be included. The Pixart breakout board also uses the PMW3901 chip. Is there a way to enable the support for PMW3901? What other options are there available?

No optical flow support is included in any stable Rover firmware. Run a 4.4 beta release to get basic support. As for enabling that specific chipset on SPI…I’ll leave that to someone more knowledgeable.

I am using a Matek H743 - Wing V3 Flight Controller.

You’re in luck. The Matek H743 (when running the 4.4 Beta) is supported.

According to the hwdef for the Matek H743 (ardupilot/libraries/AP_HAL_ChibiOS/hwdef/MatekH743/hwdef.dat at master · ArduPilot/ardupilot · GitHub), the sensor needs to be on the SPI3 bus, with the CS (Cable Select) on pin PD4.

Hi @stephendade

Thank you for the advice. I have connected the MISO, MOSI, CS, SCK pins to the sensor.

However, I am unable to select ‘Optical Flow’ from the Mission planner.

I think this might be the reason the sensor is not working as shown in Line 4 in ardupilot/libraries/AP_OpticalFlow/AP_OpticalFlow.cpp at master · ArduPilot/ardupilot (github.com). Most of the cases require ‘Optical Flow enable’ which I assumed must be done from Mission Planner.

Go to Config → Full Parameter List → FLOW_TYPE and set to 2

Hi @stephendade , I have done exactly that, but when I go back to the ‘Optional Hardware’ tab the Optical Flow Sensor is still not enabled (no tick).

After uploading the firmware to the 4.4 beta version, the Flow_Type parameter has no selection options i.e. it did not list out the value and it’s corresponding optical flow board. The description tab is also empty. (But I’ve still set it to 2 anyways as it corresponds to Pixart)

Am I doing something wrong here? Is there anything else that needs to be configured after I update the board parameter?

That’s a bug in Mission Planner. It’s not able to show that control correctly.

You may need to update to the latest Mission Planner beta to get the correct labels.

After setting FLOW_TYPE, follow the instructions at Optical Flow Sensor Testing and Setup — Rover documentation to configure the sensor.

@stephendade I have successfully configured the Optical Flow Sensor. The checkbox will never be ‘ticked’ as I think there may be a bug with the GUI.

What I did was set the ‘Flot_Type’ = 2, clicking the ‘Enable Optical Flow’, and unplug and reconnect the flight controller to the mission planner. That’s how I got it to work.

Mission Planner probably assumes that optical flow is a Copter only feature. You have full access to all parameters that would ordinarily exist on the optical flow tab within the full parameter list, so there’s nothing stopping you from using the feature on your autopilot. It’s just an annoyance within the UI.

You could start a GitHub issue to remedy this for Rover in Mission Planner.