I am trying to use the optical flow sensor pmw3901 on pixracer. I have recently encountered a problem. Can anyone tell the possible cause of the error?
Why not use the Cheerson CX-OF optical flow sensor? Many people recommend me to use the Cheerson CX-OF optical flow sensor. Indeed, ardupilot has already supported this sensor. However, there is a problem with the supply of Cheerson CX-OF optical flow sensor. This is a product launched by a Chinese manufacturer. I have contacted this manufacturer through many channels. I finally learned that this manufacturer is on the verge of bankruptcy. I have not been able to get this optical flow sensor in China.I think this sensor may be difficult to obtain in the future.
In fact, I have tried the optical flow sensor pmw3901 on pixracer and have had some successful cases. @james_pattison gives a lot of guidance on this issue.In order to use pmw3901 on the pixracer, he made two changes:
https://github.com/ArduPilot/ardupilot/pull/9753 - this adds a check for whether the board has HAL_HAVE_PIXARTFLOW_SPI defined, and if it does, builds in the driver.
https://github.com/ArduPilot/ardupilot/pull/9754 - this disables GPIO and adds in the SPI pin assignments on the wifi port, adds the device to the SPIDEV table and adds the HAL_HAVE_PIXARTFLOW_SPI define. Those changes are commented out, so that this doesn’t effect standard builds.
In the actual test, I made a small modification. The mode of pmw3901 is mode 3. Therefore, I changed the parameters in the spi device table of https://github.com/ArduPilot/ardupilot/pull/9754 to: SPIDEV pixartflow SPI4 DEVID2 FLOW_CS MODE3 2MHZ 2MHZ.
On January 8th, I modified the version of Copter 3.6.4 according to the above method and successfully obtained the data on the pixracer. However, I modified the version of Copter 3.7.0-DEV in the same way and showed it on the MP: bad optflow health. Now, the problem I am having is that I downloaded the latest version of Copter 3.6.4 and used this method to make changes, also showing: bad optflow health. I don’t know if the recent update conflicts with this modification method @rmackay9 ? I also experimented on Copter 3.6.5 and Copter 3.7.0-DEV, and still can’t run pmw3901.
I think that James Pattison’s modification is feasible. I don’t know if I need to make some other changes. Can anyone give me some help?