Optical Flow 'working' & issues

Hi there, I’m trying to make Optical flow work with on a 450 sized frame with pretty standard components.

The flight controller is one of the Chinese Pixhawk V2.4.8 clones, which flies great under full manual control. I’ve got the Px4flow board, but with a replacement MaxboticI2c Sonar (I read the default one on the board isn’t supported).

I’ve done the focus procedure for the Px4flow and I can values for opt_m_x and opt_m_y which seem to change with +/-0 values as I move the drone around. I also get realistic values from the sonar. Both Px4flow and the sonar are connected to the same I2C bus.

I’ve been through the forums and set a bunch of stuff including:

FLOW_ENABLE = 1
EK2_ALT_SOURCE = range finder
EK2_GPS_TYPE = No Gps (because there isn’t one / it needs to work indoors)

If I hover with the stick in the mid position in manual mode and then set the flight mode to AltHold then I can see it trying to hold altitude so I know my I2C bus is good and that sensor at least is working.

However I can only get Loiter mode to work when it’s attached to the computer with the USB lead, and actually connected to Mission planner via serial. When I go into Loiter mode I can hear one tone and there are no error messages displayed on the Flight Data screen. It needs tuning but it looks like it’s trying to hold position.

However as soon as I disconnect from Mission Planner (just by clicking disconnect) BUT even with the USB lead still plugged in, then I get two tones when I switch mode and it’s clearly in manual mode still.

I read the post below, that suggests it’s a power issue, but I have to stress it only works when the serial link is actually connected to MP. I’ve tried connecting USB power banks during boot (and during flight), but I can never make it go into Loiter mode unless the actual serial connection is there to MP.

…so it looks different to that(?)

I downloaded the logs, but the upload thing here says the file is too big - is there some way to view the log as text / anything I can try to see what the error is?

thanks!

It’s been over a year since I worked on this project, I wish I could be of more help. From what I remember, making sure that everything booted right was the biggest issue.

Check what’s happening on the serial ports maybe.

Sorry for the non-answer!

Thanks, I should probably have mentioned that if it had it working with the serial port connected and then I disconnect it then it stops working, even if I don’t reboot it and the USB cable is still connected to the computer. So I don’t think it’s specifically and boot or power issue.

not had any experience with optical flow but it sounds although its working sometimes at least,

It sounds like your just not being allowed to switch modes. Have you switched off the GPS arming check? You may be able to arm in loiter but not switch to loiter.

Does altitude hold mode work with the sonar? This would confirm the sonar is working correctly, you need both the sonar and flow for loiter.

I assume you mean the pixhawk is connected on USB rather than the Px4flow, all sounds very odd.

A log would defiantly be use full, although I am no expert. It would help to switch on disarmed logging,

I don’t think the sonar is supported any more for optical flow is it? I think you need a proper rangefinder (ie lidar)

Thanks both,

yes I’ve disabled the GPS arming check - and I don’t get any arming error messages when it’s plugged in and connected to MP. Yes AltHold mode works fine so I know the sonar is working and the I2C bus is working which has both sensors connected.

Yes the Pixhawk is connected with USB.

According to the documentation the PX4flow is supported with sonar, just not the sonar it comes with. Unless that’s only for some specific previous version of firmware.

I’ll try to work out how I can upload the log.

Not sure if this is still correct, but I think it is:

On this page:
http://ardupilot.org/copter/docs/common-px4flow-overview.html

Although the sensor may be supplied with a built-in Maxbotix LZ-EZ4 sonar to measure height, this has not been reliable enough over a range of surfaces in testing, so its readings are not used. It is recommended to purchase a PX4Flow device without the sonar. Instead a separate Range Finder such as the LightWare SF10b should also be attached to the vehicle.

James,

It’s great to see you here. I was actually thinking of pinging you about trying to get AP working with opendog. We have recently added support for balance bots which is clearly still very different but a walking robot would be a lot of fun.

Back to optical flow… altitude hold will work just using the barometer of course so althold working isn’t necessarily a good test of whether the range finder is working. Still, if the range finder has been attached and enabled then if it’s not working you’ll likely see a “Bad Lidar health” on the ground station’s HUD (aka the globe part that shows the vehicle’s attitude).

re sharing logs, maybe put it in dropbox or google drive and provide a link here and we can have a look.

@rmackay could you please confirm if the sonar is supported or not with optical flow?

@fnoop,

We don’t support the sonar that is attached to the px4flow sensor directly so a separate sonar must be used.

By the way, we think that one of these other optical flow sensors may also work because the same sensor is on the 2018/2019 skyrocket drones. We just haven’t had anyone test if they work yet.

I’ve also been thinking we should add support for using the OpenMV camera as an optical flow sensor. I have this on my to-do list but it could be a while before I get to it.

1 Like

Thanks for clarifying!

Hello Randy,
I have curiosity on those sensors. Would I2C connection of those sensors work like px4flow ? I understand that optical range might be short without optics.

Hi Hattori-san,

I think those sensors mostly use an SPI connection so it will only be possible with a board that has an exposed SPI port like the Pixhawk1.

Nice to see you here and thank you for reply. I found SPI connection on Pixhawk1. I will get some and give a try.

1 Like

Thanks everyone!

I did a new test today and generated some clean logs which are here:

https://drive.google.com/open?id=11IbktkHreYjQTVVW5UapOieBLstjw2Er

The first one was a clean power on with USB plugged in first, then the drone battery which has a 5v/12v distro board to power everything. It armed ok but then it wouldn’t switch modes to loiter. I launched and connected MP and then it allowed me to arm and switch modes. I tried flying with the USB cable attached, but it’s pretty tricky to tell what’s going on.

On the second test I did the same and then pulled the USB cable before attempting flying which I think worked. It looks like it was trying to hold altitude and position before crashing into the wall - I was doing this indoors because the ground is wet outside and I don’t want to mess around with my laptop on the ground to get it running. The drone can probably see its own shadow under it though which won’t help with position hold, and the altitude hold definitely needs tuning, but it seems to be trying to hold it. I’d rather be doing this outside really with lots of space so I can tune it.

I originally did get ‘bad lidar health’ when setting the drone up, but it goes away if you pick the drone up a bit. I’ve set the minimum range finder distance to 5cm, although it’s closer to the ground than that, so for now I’ve just disabled the re-flight check. But does this mean it’ll never use the range finder, or is it fine once it’s in the air?. I could always put longer legs on the drone if I need to get the range finder higher up to start with…

Hello,
I have been flying OF indoor iwith a 450 since a few years now.
Here is what you need to do:

  • Make sure you have a good texteured non reflective surface , I am flying over rug
    https://www.youtube.com/watch?v=QlkUJnPcOTo&t=4s

  • Feed the PX4FLOW and Rangefinder on a dedicated UBEC with good filtering

  • Set EK3 in order to set EKF HOME

  • Connect to Mission Planner and right click to set home & EKF Home

  • You should see the vehicle appears

  • Take the quad on you hand and walk it around the room , it will show the displacement on the screen and altitude must be correct.
    (I used to walk a square or a 8 pattern and this must be showned on screen)
    -Then you can takeoff alt-hold and switch to loiter, once you confirmed working you can takeoff loiter or guided

Patrick,

txs for all this, one thing - I wonder if it’s really necessary to use the EK3 though. EKF2 should work fine I think.

Unless something changed, you could not set EKF origin in GPS denied with EK2

Thanks for this, so I followed the steps, but my drone doesn’t draw the pattern how I move it. I still haven’t resolved why it won’t change modes when it’s disconnected but I’ll try a different power supply.

So it looks like I need to do the calibration as per: http://ardupilot.org/copter/docs/common-px4flow-overview.html#calibrating-the-sensor

Is there a guide on downloading and plotting the logs - are these just the normal logs like the ones I uploaded, which files do I need and how do I plot them?

thanks