geo fence back in for arducopter

320 views
Skip to first unread message

Randy Mackay

unread,
Apr 27, 2013, 12:10:24 AM4/27/13
to drones-discuss

     A simplified version of limits/geofencing is back in arducopter.  It still need to be reviewed so there will likely be some changes but this is how it works:

         FENCE_ENABLE: set to 1 to enable
         FENCE_TYPE:     set to 1 to enable only the alt fence, set to 7 to enable altitude and circle fence
         FENCE_ALT_MAX: max altitude in cm (we will likely change the scale to meters)
         FENCE_RADIUS:   inner circle radius in cm (we will likely change scale to meters)
         FENCE_ACTION: set to zero to only report, set 1 to RTL when you hit the inner circle and LAND when you breach the outer circle

     I've tested it yesterday and it seems to work.  I think Michael is working on a set-up screen in mission planner.

     Future plans are to add back in support for:
            1. polygon shaped limits
            2. allow copter to bounce off the fence

-Randy
FencePic2.png

Kevin Hester

unread,
Apr 27, 2013, 1:21:18 AM4/27/13
to drones-discuss
Cool!  A few questions:
  • does it send msg_fence_status (like plane)? - I ask so andropilot can properly yell at the user (like it does with planes)
  • what about using FENCE_ACTION instead of FENCE_TYPE - so it works a bit more like plane?  Also, this is how I detect that the vehicle supports geofencing.  I think that even if the 'full' fence stuff isn't included in arducopter that just having renaming FENCE_TYPE to FENCE_ACTION and using the following enum values would allow andropilot to 'just work' with this new feature:
enum FENCE_ACTION
{
FENCE_ACTION_NONE=0, /* Disable fenced mode | */
FENCE_ACTION_GUIDED=1, /* Switched to guided mode to return point (fence point 0) - not supported on arducopter | */
FENCE_ACTION_REPORT=2, /* Report fence breach, but don't take action - not supported on arducopter | */
FENCE_ACTION_ALTONLY=3, // Proposal - so arducopter can work more like arduplane
FENCE_ACTION_ALTANDCIRCLE=4 // for arducopter
};


--
You received this message because you are subscribed to the Google Groups "drones-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to drones-discus...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Randy Mackay

unread,
Apr 27, 2013, 2:27:46 AM4/27/13
to drones-...@googlegroups.com
Kevin, All,

     aha.  I didn't realise there was both a "limits" message and "geofence" mavlink message - it's currently using the limits one but I'll switch to using the fence message so it'll be just like the plane.

     I was thinking we needed both TYPE and ACTION parameters.  TYPE parameter says what type of fences are active while the ACTION says what to do if you breach a fence.  I thought people would want to be able to choose different behaviour including:
        1) bounce off the barrier
        2) RTL
        3) fly to a predetermined point
     ....but maybe we don't really need all those choices.  Maybe we don't need "bounce" if we make it so that in loiter, guided and alt-hold modes the target position and/or altitude can never move outside the fence.  So in these modes you just can't get outside the fence unless something goes horribly wrong in which case it will RTL.  In stabilize & acro it will RTL if you go outside.

     Thanks for the feedback, I'll combine it in with the feedback I'm expecting from Tridge and do the adjustments at the same time.

      By the way, the thing that I really like about this simple circle method is that it moves easily with you.  No need to redefine the limit everytime you move to a new flying field because the fence is always relative to home.  This makes it more like a failsafe that we could leave on all the time.

-Randy


From: Kevin Hester <kev...@geeksville.com>
To: drones-discuss <drones-...@googlegroups.com>
Sent: Saturday, April 27, 2013 2:21 PM
Subject: Re: [drones-discuss] geo fence back in for arducopter

Marco Robustini

unread,
Apr 27, 2013, 3:06:51 AM4/27/13
to drones-...@googlegroups.com, Randy Mackay
Thanks Randy, I try this week, but there is still the problem that when it comes to limit the quad wheel yaw and go to the home?
The ideal would be simply that "rebounds" and not go beyond, without doing anything else.
I have not looked closely at the changes that you made to the code.

Marco

Randy Mackay

unread,
Apr 27, 2013, 3:18:43 AM4/27/13
to Marco Robustini, drones-...@googlegroups.com
Marco,

     It uses the regular RTL controller but you know we've recently added a WP_YAW_BEHAVIOR parameter that you can set to zero to disable the autopilot from ever changing the yaw.

-Randy


From: Marco Robustini <robusti...@gmail.com>
To: drones-...@googlegroups.com
Cc: Randy Mackay <rmac...@yahoo.com>
Sent: Saturday, April 27, 2013 4:06 PM
Subject: Re: geo fence back in for arducopter

Marco Robustini

unread,
Apr 27, 2013, 3:22:45 AM4/27/13
to drones-...@googlegroups.com, Marco Robustini, Randy Mackay
Ok, that's fine, but when i reach the limit and the quad go to home is possible to break this "auto navigation"?

Marco

Randy Mackay

unread,
Apr 27, 2013, 3:55:39 AM4/27/13
to Marco Robustini, drones-...@googlegroups.com
Marco,

    Yes, you can regain control by switching flight modes.  This clears the event and signals, "pilot wants to re-take control".  The fence code will not wrestle back control from the pilot unless he/she comes back within the circle and then breaks through it again.  So if the pilot is messing with the flight mode switches it is possible for the copter to get away.  I can imagine this situation:
               1. pilot gets confused about the copter orientation and it flies off
               2. copter breaks through the fence, switches automatically to RTL
               3. Pilot is panicking and switches the flight modes.  This clears the event and puts the pilot back in control
               4. Pilot is still confused and copter continues flying away
               5. Copter breaks through 2nd "Big fence" which is twice the normal circle radius.  Automatically switches to LAND.
               6. Pilot is still flicking the flight modes thus "clearing" the 2nd event but he's still confused and can't bring the copter home
               7. copter is out of sight and pilot complains that he lost his copter
     So in this imaginary case, if the copter was flying ok, the pilot would have been better off just leaving it to come home.

     I'm also not saying that this fence is going to stop every flyaway.  To some extent it still relies upon the copter knowing it's orientation, location and it's flying fairly well.

-Randy


Cc: Marco Robustini <robusti...@gmail.com>; Randy Mackay <rmac...@yahoo.com>
Sent: Saturday, April 27, 2013 4:22 PM

Subject: Re: geo fence back in for arducopter

DaveC

unread,
Apr 27, 2013, 6:31:12 AM4/27/13
to drones-...@googlegroups.com, Marco Robustini, Randy Mackay
If the pilot is confused with orientation and/or the quad flying off, then the simplest and safest course of action would be to change to RTL.

As long as pilot initiated RTL works after a RTL initiated from hitting the fence then all the actions below should still result in the copter coming home safely, provided as you say it's set up and is flying well.

Kevin Hester

unread,
Apr 27, 2013, 10:41:24 AM4/27/13
to drones-discuss
yeah - simple circle sounds great.  It would be really useful for planes too.  I see now that you mentioned _ACTION in your original email - I missed that before, so keeping _TYPE makes sense.

Stefan Gofferje

unread,
Apr 27, 2013, 11:42:13 AM4/27/13
to drones-...@googlegroups.com
On 04/27/2013 07:10 AM, Randy Mackay wrote:
> and LAND when you breach the outer circle

Is it wise to have a copter LAND automatically beyond the line of sight
of the pilot? When the outer circle was broken, it might very well be
that the copter is somewhere over populated area.
If you really go through with this autoland, I would try to increase
safety by e.g. activating the beeper to emit a very fast signal and/or
have the copter land expressively slowly to give potential traffic a
chance to get out of the way.

I personally would do it a bit differently... I would set the copter to
RTL which can't be reset until it's back within the inner circle or
within x meters of the launch position, to make sure a panicking pilot
can safely regain control.

IMHO autolanding beyond line of sight (unless in a flightplan, of
course) is a can of worms of the size of a football-stadium...

-S

Randy Mackay

unread,
Apr 27, 2013, 9:59:31 PM4/27/13
to drones-...@googlegroups.com
Stefan,

>> I would set the copter to RTL which can't be reset until it's back within the inner circle or within x meters of the launch position, to make sure a panicking pilot can safely regain control.

     I agree that would probably be the right thing to do with a novice pilot but what if the pilot was Marco or DaveC?  I worry we're stepping into dangerous ground if we start ignoring pilot input.

     Leonard and I had a brain storming session this morning and came up with the idea that when you first break through the inner circle it triggers the RTL but then reset the circle radius wider by 20m (or 50m).  This will cause the automated RTLs to be triggered again and again if the copter keeps moving away from home and should make it harder for a panicking pilot to mess things up.  A good pilot will have already regained control and started to bring the copter home so he/she won't notice an annoying autopilot wrestling control from them.

>> Is it wise to have a copter LAND automatically beyond the line of sight
of the pilot?

     The copter's coming down somewhere...once it's that far away it's just whether it's controlled or uncontrolled.  Flashing lights and beeping is a very good idea.  An emergency mode in the LEDs code could handle that.

     Thanks for the response...definitely good to get more input on how this should work.

-Randy


From: Stefan Gofferje <stefan....@gmail.com>
To: drones-...@googlegroups.com
Sent: Sunday, April 28, 2013 12:42 AM

Subject: Re: [drones-discuss] geo fence back in for arducopter
--
You received this message because you are subscribed to the Google Groups "drones-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to drones-discuss+unsub...@googlegroups.com.

Olivier ADLER

unread,
Apr 28, 2013, 5:00:22 AM4/28/13
to drones-...@googlegroups.com, Randy Mackay


If the outer circle is broken, then for copters with parachute a solution would be to stop motors and trig the parachute output.

This could be a first developpement phase to add a parachute output that could be completed later by other abnormal conditions to trig it.


Olivier

Randy Mackay

unread,
Apr 28, 2013, 5:42:25 AM4/28/13
to drones-...@googlegroups.com
Olivier,

    Yes, very possible.  I've actually just ordered a parachute from opale paramodels and hopefully I'll be able to integrate it into a future version of AC.

-Randy


From: Olivier ADLER <cont...@nerim.net>
Sent: Sunday, April 28, 2013 6:00 PM

Subject: Re: [drones-discuss] geo fence back in for arducopter
To unsubscribe from this group and stop receiving emails from it, send an email to drones-discus...@googlegroups.com.

Stefan Gofferje

unread,
Apr 28, 2013, 6:50:25 AM4/28/13
to drones-...@googlegroups.com
Randy,

On 04/28/2013 04:59 AM, Randy Mackay wrote:
>>> I would set the copter to RTL which can't be reset until it's back
> within the inner circle or within x meters of the launch position, to
> make sure a panicking pilot can safely regain control.
>
> I agree that would probably be the right thing to do with a novice
> pilot but what if the pilot was Marco or DaveC? I worry we're stepping
> into dangerous ground if we start ignoring pilot input.

I see it this way: An experienced pilot sets the geofence radius and
activates the geofence function itself with some degree of deliberation.
Thus, I would assume, when the copter leaves the outer circle, something
_did_ go wrong and ignoring pilot input until the copter is back inside
the inner circle won't be a bad thing because the pilot himself decided
on that inner circle and to activate the function in the first place.
After all, from the APM's point of view, a receiver going into failsafe
due to RFI or a dead TX battery is also "pilot input".

> Leonard and I had a brain storming session this morning and came up
> with the idea that when you first break through the inner circle it
> triggers the RTL but then reset the circle radius wider by 20m (or
> 50m). This will cause the automated RTLs to be triggered again and
> again if the copter keeps moving away from home and should make it
> harder for a panicking pilot to mess things up. A good pilot will have
> already regained control and started to bring the copter home so he/she
> won't notice an annoying autopilot wrestling control from them.

That sounds like a good compromise to me.

>>> Is it wise to have a copter LAND automatically beyond the line of sight
> of the pilot?
>
> The copter's coming down somewhere...once it's that far away it's
> just whether it's controlled or uncontrolled.

That's a good point. However, I'd personally feel more comfortable with
the copter trying to return home in any case instead of just landing
somewhere out of sight.

Besides, there might be operator liabilities involved.
A copter flying away and falling out of the sky due to, let's say, RFI
is an accident.
A copter initiating an autoland sequence because the operator activated
that function, might be seen as aggravated negligence by a judge.
Knowing the European press, I'd also assume that a copter which falls
out of the sky due to some technical problems is no news but if it turns
out that the copter that injured that child was in some unsupervised,
beyond-line-of-sight autoland mode, THAT would go high.

-Stefan

Olivier ADLER

unread,
Apr 28, 2013, 8:31:31 AM4/28/13
to drones-...@googlegroups.com

Stefan, if there is too much wind or a mechanical problem, it is not always possible to go home. In this case it is better to land in a more or less controlled manner, rather than a full crash after trying to go home without success because of wind drift or a dead motor.


The energy of a crashing copter running into ground people will be higher than the energy of a landing copter, even if the landing is not perfect.


Olivier






That's a good point. However, I'd personally feel more comfortable with
the copter trying to return home in any case instead of just landing
somewhere out of sight.


Randy Mackay

unread,
Apr 28, 2013, 9:01:23 AM4/28/13
to drones-...@googlegroups.com

     Yes, it's actually very likely that if the copter breaks through the big-circle that it doesn't know it's orientation for some reason.  I tried in the simulator to see roughly how it would react with different levels of compass error

        less than 45 degree error: made it home and landed

        45 ~ 90 degrees error: gets home but then flies circles (sometimes is radius of 50m) around the home position.  never lands because it never reaches the home location

       more than 90 degree error: flies off in the wrong direction after switching into RTL.  "Lands" (or more accurately "crashes") into the ground usually within 100m breaching the 2nd barrier.  Because all it's inputs to try and slow it's horizontal speed are backwards it sometimes crashed into the ground at high speed (7m/s ~ 15m/s).

     What we really need is an algorithm that we can actually implement that can navigate based on GPS but without a compass.  I've heard some ideas including:
           a) measuring the accelerometer based acceleration vector vs an acceleration derived from the gps position change or velocity.
           b) a watcher that compares the copter's lean angle to gps velocity (or change in position if the gps doesn't provide velocity directly).

-Randy


From: Olivier ADLER <cont...@nerim.net>
To: drones-...@googlegroups.com
Sent: Sunday, April 28, 2013 9:31 PM

Subject: Re: [drones-discuss] geo fence back in for arducopter
--
You received this message because you are subscribed to the Google Groups "drones-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to drones-discus...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages