This is a discussion of getting the PX4Flow sensor working with Copter-3.3.1 (or higher).

Views: 23061

Reply to This

Replies to This Discussion

Thanks for putting this here Randy!

I have been working on new hardware for this that is CAN based. And would love to see more people using flow on their copters!
Thank you!
Mounted to an Alien 680mm frame, with a hawk loaded with 3.3 r1, Lidar lite installed and functioning well...

Having followed the Ardupilot wiki for the PX4flow...

PX4flow loaded with the Ardupilot recommended firmware.

Optical Flow enabled in Mission Planner.

PX4flow focused through Q ground.

Connected to the i2c expansion board shared by the GPS compass and remote USB and mode light indicator.

Loging set per wiki to log OF and log while disarmed.

Powering up the multi by connecting the battery, the PX4flow lights flash.


Having got this far I have not been able to get any useful data to be displayed in the OF log.
All I get is a single flat line in the log.

I have tried different start up procedures:

Connect battery, arm safety switch, do tilt cycles, disarm safety switch, unplug battery, connect USB download log.
I have also tried connecting USB first, waiting for hawk to start up, then connect battery, arming safety switch, doing tilt cycles, disarming safety switch, unplugging battery, connecting USB, downloading logs.

Is there a way to verify that the PX4flow is working properly apart from the logs?
A line to look for in the mission Planner Stats?

I have had this PX4flow sensor for more than a year, bought it the first time I saw it on the Hobby King website. Then found out that there was very little support for sensor at that time.

Now I am very eager to get the sensor working, what should I try next?
http://copter.ardupilot.com/wiki/common-px4flow-overview/


Please note the following....
Load the correct firmware as per the instructions
Focus the camera as per the instructions (look for a red box explaining this)
Tune the flow sensor to ensure sensor rates, and gyro rates are co-ordinated.

Ensure sensor orientation is set correctly for your frame....
The correct firmware has been installed, the camera has been focused.

What I am not seeing is any useful data being generated by the sensor in the logs.

Is there a way to see live data to verify that the PX4flow sensor is working correctly?

What's the difference in flying performance between optical flow and Lidar lite?

It's been a month or so since I've messed with the px4flow. I was at a very similar place with OF that you are now, Wes. It took me a while before someone over on the Px4 Groups on Google told me that the only sure fire way to confirm the OF Data is through enabling the full log bitmask and viewing the log, using FlightPlot or LogMuncher to view the OF Data.


My first mistakes were; Not having a distance sensor working in sync with the OF sensor (bought a LIDAR-Lite), after that I found out I was using Mission Planner Stable and not the Dev/Beta loaded in the Hawk, then I was told that QGroundControl w/ the PX4 Firmware is the preferred firmware for OF. So that brings me here, I've uploaded logs onto log muncher which didn't help me much more than FlightPlot.(Log from test flight). I'm breaking out multiple SD cards tomorrow and starting over with different firmware's and settings. Hopefully I'll uncover something to contribute. 

@SwitchedMode,

I think it depends upon who you talk to.. so if you talk with the px4 developers they'll lead you the way that they know (i.e. QGC+px4stack), while Paul and I would steer you towards ardupilot + mission planner.  So this thread is really for the ardupilot+MP method that hopefully Paul and I can help you with.

Lidar is a very accurate sensor for measuring distance, maintaining a specific distance from the ground.

Optical flow is a whole different animal, a down facing camera looks at the ground to determine movement and then processes the movement in to a flight path correction.

Optical flow, when it is fully implemented will allow for a non GPS based position hold.
The optical flow requires a ranging sensor, so it uses something like a LIDAR for this.

Just in case it might be useful to someone trying to get OF to work, here's a copy of my notes on getting OpticalFlow working with Copter v3.3.

I have it kinda/sorta working (with some intermittent issues), and I'm not 100% sure if everything is setup correctly and I'm sure I've missed something, so any feedback will be greatly appreciated.

Thanks!

Download PX4FLOW Firmware

Download the APM's version of PX4FLOW Firmware from: http://ardupilot.com/downloads/?did=118
(The expanded firmware should be px4flow-klt-06Dec2014.px4)

Flash PX4FLOW firmware

  • Connect PX4Flow to PC via USB
  • Make sure I2C cable between PX4FLOW and Pixhawk is disconnected.
  • Use QGroundControl to load the binary firmware downloaded in the previous section.

NOTE: Some versions of QGroundControl are missing the menu to upload custom firmware from local filesystem. Use the latest version (v2.8.0) in order to upload the custome firmware to PX4FLOW. v2.8.0 also has PX4FLOW specific settings menu with auto-video streaming. If you want to run an older version of QGroundControl, use v2.5.2 or earlier in order to be able to load custom firmware to PX4FLOW.

All release versions of QGroundControl can be found here

Adjust PX4FLOW

  • Connect PX4FLOW to QGroundControl via USB.
  • With the latest version of QGroundControl, video is automatically streamed and displayed in the PX4FLOW specific settings menu.
  • From the parameters menu, set VIDEO_ONLY=1 in order to view high-resolution video for adjusting lens focus.
  • While view the video stream via USB, twist the focus ring on the PX4FLOW lens so that the image is focused and edges are sharp at around 3 meters (or your average hovering height, which is 1m in my case).
  • Tighten the focus ring screw once focus has been adjusted.
  • Disable high-resolution video streaming mode by setting VIDEO_ONLY parameter to 0.

Connect PX4FLOW to Pixhawk/PXF

  • Use DF13 4 pos connector to connect I2C port of PX4FLOW to I2C port of Pixhawk/PXF.
  • If you want to use the sonar on-board PX4FLOW, use analog pins and connect it to ADC input of Pixhawk (details to be filled).

Update Copter Firmware

Configure OpticalFlow

Via APM Planner 2.0 / Mission Planner

  • Initial Setup -> Optional Setup -> Optical Flow -> Check the "Enable" checkbox
  • Cofig/Tuning -> Full Parameter List

Change the following parameters:

EKF_GPS_TYPE -> 3
FLOW_ENABLE -> 1
FLOW_FXSCALER -> 0
FLOW_FYSCALER -> 0
FLOW_ORIENT_YAW -> 0 if you've mounted PX4FLOW's x axis facing forward (xyz axis marker is printed on the backside of PX4FLOW PCB board). If x is not facing forward, adjust this. Value Must be between -18000 and 18000 centidegrees.

# Disable GPS pre-arm check
GPS_HDOP_GOOD -> 9999
# Enable Pre-ARM Logging (All + FastATT, including pre-arm logging)
LOG_BITMASK -> 131071

# If you want to use built-in barometer instead of external range finder (NOT recommended).
EKF_ALT_SOURCE -> 0 # Set this to 1 if you have external range finder (LiDAR, etc.)
RNGFND_GNDCLEAR -> set this according to your rangefinder's spec.

Testing

Check mount orientation and tweak the scaler parameters according to the instructions in the wiki

Check dataflash logs (NOT telemetry logs) and make sure:

  • OF.flowX, OF.flowY, OF.bodyX, OF.bodyY are responding to aircraft movements.
  • EKF5.meaRng is not flat-lined and responding to height changes.
  • EKF5.FIX and EKF5.FIY are not flat-lined (flat-line indicates OF readings are not used in EKF).
  • EKF4.SS bit 7 is false (inidicates constant position mode when true)
  • EKF4.SS bit 3 is true (indicates relative position mode when true)

NOTE: OF.flowX and OF.flowY don't get updated in the telemetry log, so make sure to check the dataflash logs.
NOTE: Don't use OF_LOITER mode as they've been removed a long time ago from the firmware. APM Planner 2.0 still has this mode in the drop-down menu, presumably in order to support older versions.

Issues

  • If you don't take off immediately after arming and bring your copter to at least about 1 meter, EKF will stop using OF data and you'll be flying manually.
  • Sometimes OF drops out suddenly mid-flight when readings are off, but there's no warning or indication. Only way to know is to look at the dataflash logs.
  • When flying with OF, the aircraft starts to drift off as time goes by. It appears EKF5.FIX and EKF5.FIY gets too large over time.
  • Loiter mode feels a little "sluggish" compared to stabilize, etc., and it's easy to get confused and panic as it seems like the copter is not responding to your RC input at all.
  • If you are getting nothing in the logs (make sure you are looking at the dataflash logs and not the telemetry logs), fire up NSH, and issue px4flow status command to see if the PX4FLOW module is detected on I2C and the driver is loaded. You should see a bunch of readouts if it's functioning correctly and error message otherwise.
  • At least one of the PX4FLOW clones (one without the on-board sonar module, bought from China) did not work when connected via I2C. It can be very confusing as it appears to be working just fine when connected directly to the PC via USB. PX4FLOW with sonar (bought direct from 3DR) doesn't have this problem.

Questions

Misc. Notes

  • The PX4FLOW firmware binary APM Recommended Version above is apparently built from the source code here, but the resulting binary built from the soure does not work with APM:Copter.
  • The latest upstream version, when built from the source does not seem to work with APM:Copter. OPTICAL_FLOW.flow_comp_m_x etc. in both telemetry and dataflash logs didn't look right.
  • In both cases, the values reported by the Copter didn't look right (values were too small, biased towards one direction only, less frequently updated, etc.). Although they look OK if you connect to PX4FLOW and look at the mavlink data directly.

References

Wow, to Philip and Goro, thank you!

That is some of the best and most complete diagnostic and set up information that I have seen on the PX4flow to date!

Thank you again!

Reply to Discussion

RSS

© 2019   Created by Chris Anderson.   Powered by

Badges  |  Report an Issue  |  Terms of Service