Ardupilot: Copter: allow px4flow sensor's sonar to be used as range finder

Created on 8 Dec 2014  Â·  39Comments  Â·  Source: ArduPilot/ardupilot

The PX4Flow sonar includes a sonar. We should allow this sonar to be used just like a stand-alone sonar/rangefinder (i.e. maxbotix analog, i2c or lidar-lite led rangefinder)

Copter Enhancement Plane

Most helpful comment

I write a new rangefinder code in libraries/AP_RangeFinder. It just subscribe distance_sensor orb and feed it to rangefinder state. It just serve as a "proxy" to px4 firmware orb topic

my test flights looks OK (compare to lightware sf10)

AP_RangeFinder_proxy::AP_RangeFinder_proxy(RangeFinder &_ranger, uint8_t instance, RangeFinder::RangeFinder_State &_state) : AP_RangeFinder_Backend(_ranger, instance, _state) { _rngfnd_sub = orb_subscribe(ORB_ID(distance_sensor)); } bool AP_RangeFinder_proxy::detect(RangeFinder &_ranger, uint8_t instance) { return true; } void AP_RangeFinder_proxy::update(void) { bool updated = false; orb_check(_rngfnd_sub, &updated); if (updated) { if (orb_copy(ORB_ID(distance_sensor), _rngfnd_sub, &_rngfnd_data) == OK) { set_status(RangeFinder::RangeFinder_Good); state.distance_cm = _rngfnd_data.current_distance * 100; } } }

All 39 comments

@rmackay9 this is the wrong forum I'm sure but does the px4flow need the sonar to work on pixhawk? I have one minus the sonar in the post, I also have a lidarlite incoming which I thought would have better accuracy. Thoughts?

@nicegraham,
With the latest code (i.e. the development version after AC3.2) the px4flow's sonar can't be used. So in fact, you must have a lidar-lite or a separate external sonar to use the px4flow for position control.

Thanks @rmackay9! good news for me so. Is it a matter of plugging the new sensors in on >AC3.2 or will I need to do some config fettling?

Out of interest, why is the built in sonar unusable now? I've read the stock sonar is less than great but is it not better than nothing?

We had to change interfaces to the flow sensor to get it working with the EKF. The work required at the PX4 firmware level to enable the inbuilt sonar to be handled the same as other external sonars/rangefinders still needs to be done.

My testing has shown the built in sonar to be effectively useless over grass surfaces, although it does provide a useful height measurement for a limited height range over paved surfaces. Because the in-built sonar data quality is so variable and we didn't want bad sonar confusing the issue with the initial EKF optical flow roll-out, enabling use of the in-built sonar has been delayed until we are confident my optical flow results can be replicated on other setups.

@priseborough what's the status on this? if I recall, you had this working?

The wiki says:
"To use this flow sensor to perform optical flow loiter as seen in the following video, you will need to purchase a separate range finder. Our testing has been performed using the Pulsed Light unit "

There's the flow sensor in general but this issue is specific to the sonar rangefinder. I'm not sure if it is all-encompassing where the optical flow sensor just utilized is and integrates it into the result without the pixhawk knowing.

apologies, spot on.

So it is still required to have a distance sensor (LIDAR-Lite, maxsonar...etc) in order to use the Px4Flow? I bought the Px4Flow without the sonar because I have LIDAR-Lite coming in soon. So I've been testing like a mad-dog, bypassing filters and altering hundreds of lines of code just to figure out why optical flow isn't being utilized. But it comes down to 'it needs a sonar too'? fml lol, so many hours...

@SwitchedMode, I've never used one of the clone PX4Flow sensors that is missing the sonar but I would have thought that, as long as you have a LidarLite on the vehicle, that it would work. I think it would be best to post logs (if you haven't already) to drones-discuss.

It's an actual Px4Flow, but they sell without a range module for cheaper.
Didnt know It required one. I went ahead and bought Lidar-Lite V2 anyways.
Thx man.

On Tue, Sep 8, 2015 at 1:19 AM, Randy Mackay [email protected]
wrote:

@SwitchedMode https://github.com/SwitchedMode, I've never used one of
the clone PX4Flow sensors that is missing the sonar but I would have
thought that, as long as you have a LidarLite on the vehicle, that it would
work. I think it would be best to post logs (if you haven't already) to
drones-discuss.

—
Reply to this email directly or view it on GitHub
https://github.com/diydrones/ardupilot/issues/1672#issuecomment-138436643
.

In our lab here we have sonar-friendly surfaces and we would really like to use the PX4Flow built-in sonar. I understand that there's work to be done so we would like to help out to get this working. @priseborough would you show us to what the firmware level work would involve? @ssoRL

No firmware work required. Connect the ground and analogue signal pin from the sonar to the analogue input on the pixhawk and set it up in the parameters the same as if you had a separate analogue sonar fitted.

On 16 Sep 2015, at 8:04 am, John Lian [email protected] wrote:

In our lab here we have sonar-friendly surfaces and we would really like to use the PX4Flow built-in sonar. I understand that there's work to be done so we would like to help out to get this working. @priseborough https://github.com/priseborough would you show us to what the firmware level work would involve? @ssoRL https://github.com/ssoRL
—
Reply to this email directly or view it on GitHub https://github.com/diydrones/ardupilot/issues/1672#issuecomment-140559673.

Thanks @priseborough , now we can get started on the testing. Still though we would like to see the PX4Flow sonar working directly and are open to help out if needed :)

Beyond the wiki, is there an active forum for people who are actually using the PX4flow and lidar lite v2?

I have the lidar working, but finding optical flow info is like looking for a needle in a hay stack.

No forum that I'm aware of.

@jistforfun I've found this thread helpful https://groups.google.com/forum/#!topic/drones-discuss/VgHuSh7Yjuo

The link was very helpful, thank you!

Oct 5 was the last entry...

I wonder what priority OF is in the grand scheme of things...

@jistforfun The lead maintainers appear to be quite busy with other things for now. Since APM is an open effort we can all help make things work. I have not posted back into the google groups but I did get the lidar to work with PX4Flow. Are you having any problems with that? Currently we are seeing if we can get APM to fallback to OF when GPS is bad and also seeing if we make use out of the built-in sonar better (the analogue method didn't work out very well for us).

I have the Lidar working and like it, hoping the developers have the time to more fully integrate it in to arducopter even ahead OF.

I do under stand the nature of Open source projects and greatly appreciate their efforts!

I have had the PX4flow setting on the bench for a year now and would like to get it working. From my reading the current development level for OF suggests this feature should be reserved for a beater quad and is not yet ready for use on a camera ship. Lidar is on the camera ship, might have to remount it to a beater to play with the PX4flow.

Thanks for the update!

Copter 3.3 has OF support and in my tests it works quite well with the lidar. Try it outdoors first with good GPS and see if you notice improvements. We've tried it indoors with GPS turned off and saw good results as well, but in order for that to work you have to takeoff in Alt_Hold and switch to Loiter mid-flight, which can be scary.

I mounted the px4flow, connected to i2c, enabled OF in Mission Planner, lights flash but I can not get any data from it yet.

I have read through the wiki about a dozen times today and am stuck at step requiring reviewing the flow logs. When I graph the the qual and flow values I am not getting any data. Just a single flat line.

Logging set per wiki, I have tried both with the safety switch armed and disarmed.

Tried going back to Qground and reflashed the the board with the stable auto update for the px4flow. Made sure I could get video out through Qground.

Do I need to be in a particular flight mode for logging of flow data?

Can you please create a thread for this in drones discuss so yourself and other early adopters of the optical flow feature can share experiences and flight logs. Also we are now off-topic for this PR.

Yes, we need a dedicated support/tinkerers thread ^. Has anyone created or seen one yet? What we REALLY need above all is a set list of criteria needed to make the Px4Flow work. I'm talking about a logical flow or even a diagram showing information like; What flight modes OF is used in and OF flight mode details, Supported AP Firmware for Px4Flow, known working OF set-ups. True, you can find most of the information you need for the Px4Flow on the web, BUT, it is scattered throughout multiple pages, most of which contain deprecated information or false/redacted statements about the operation of the Px4Flow. I even had trouble while creating a map of relevant information for the Px4Flow. This was just to make sure every setting was correct for basic operation. The ambiguity of the system had me befuddled, and i'm an electrical engineer for Christs sake.
The OCD lunatic in me craves a well-balanced web-page of all known Px4Flow information.

Perhaps Jilian or one of those who has had success with the PX4flow could start a tinkers/ Beta users Thead.

I am not even sure which forum would be best, Google groups, Drones Discussed or DIY drones.

DIY has a couple of Dead threads-others trying to find the same info Switchmode and I have searching for, but with out success.

Please help us stop these off topics posts by linking an appropriate forum for this off topic discussion:)

It's super easy to create a discussion on DIYDrones so I've created one here. http://diydrones.com/forum/topics/optical-flow-discussion-thread

If anyone has anything to contribute. A discussion for implementing Px4Flow/Optical Flow was started on DIYDrones at rmackay9's link above ^.

I write a new rangefinder code in libraries/AP_RangeFinder. It just subscribe distance_sensor orb and feed it to rangefinder state. It just serve as a "proxy" to px4 firmware orb topic

my test flights looks OK (compare to lightware sf10)

AP_RangeFinder_proxy::AP_RangeFinder_proxy(RangeFinder &_ranger, uint8_t instance, RangeFinder::RangeFinder_State &_state) : AP_RangeFinder_Backend(_ranger, instance, _state) { _rngfnd_sub = orb_subscribe(ORB_ID(distance_sensor)); } bool AP_RangeFinder_proxy::detect(RangeFinder &_ranger, uint8_t instance) { return true; } void AP_RangeFinder_proxy::update(void) { bool updated = false; orb_check(_rngfnd_sub, &updated); if (updated) { if (orb_copy(ORB_ID(distance_sensor), _rngfnd_sub, &_rngfnd_data) == OK) { set_status(RangeFinder::RangeFinder_Good); state.distance_cm = _rngfnd_data.current_distance * 100; } } }

@chobitsfan, very cool. The only issue is that we've "in-treed" the drivers. So for AC3.5 (and higher) we won't be using the orb very much. From my point of view, this makes it all a lot easier but perhaps opinions vary. In any case, I see in our new driver we do have the sonar distance but it's not exposed as a range finder (search for "ground_distance" on the link below).
https://github.com/ArduPilot/ardupilot/blob/master/libraries/AP_OpticalFlow/AP_OpticalFlow_PX4Flow.h
Maybe your rangefinder driver could be adjusted to somehow pull from the AP_OpticalFlow_PX4Flow object?

@rmackay9 OK, I will try to do it

@rmackay9, I am thinking add a uint16_t ground_distance in /libraries/AP_HAL/OpticalFlow.h. And AP_OpticalFlow_PX4Flow.c can write ground_distance to nal.opticalflow->ground_distance. So that AP_RangeFinder_PX4Flow.c can read ground_distance from nal.opticalflow->ground_distance. What do you think about it? thank you very much

Hi, I am currently using the latest version of ArduCopter 3.5.3. I am using the px4 flow board with the OF Camera and integrated Maxbotix sonar sensor however I am unable to get any sonar readings. Based on this thread, my understanding is that the sonar on that board was disabled from being used as a rangefinder. Is this this case? If so, was it ever re-enabled, or will I need to purchase a lidar-based sensor?

Great, thank you! I will give it a shot and let you know if it works for me

You can also take the analogue voltage and ground from matbotix header pin, wire it to an analogue input on the pixhawk and use it as a separate analogue range finder.

Looks like it's EZ4 why not use it?

@chobitsfan Great, thanks for implementing it. Can anyone make a pull request, so that all can use the PX4FLOW with sonar with the official ArduPilot repo? (I know this issue is old, but I don't know any better optical flow sensor than PX4FLOW for now)

hi @SaschaIoT thank you
I created #6205 to fix this. It is closed because it is outdated and I am working on other matters.

I don't think we are ever going to implement this. There are much smaller and cheaper flow sensors now (like hereflow) that perform at least as well. The sonar on the px4flow is too short range to be useful I think.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

yanivasy picture yanivasy  Â·  7Comments

lordneeko picture lordneeko  Â·  9Comments

bosskwei picture bosskwei  Â·  3Comments

Hyacinthchou picture Hyacinthchou  Â·  4Comments

JonathanPlasse picture JonathanPlasse  Â·  9Comments