Re: [ardupilot] Copter: Follow-me safety (#1068)

121 views
Skip to first unread message

Emile Castelnuovo

unread,
May 15, 2014, 3:44:47 AM5/15/14
to diydrones/ardupilot, drones-...@googlegroups.com
As suggested by Randy I'll raise this to the drone discuss too.
In making the VRPad Station we encountered a problem during Follow me mode where the GCS would just stuck and send guided messages continuously.
As Arthur correctly stated this event will not allow a regain in control of the vehicle with standard RC radio.

The solution would be to set the GUIDED mode via GCS and not switch to guided at every guided message.
This is what we have done in our follow me project.

There is a small problem though. The GCS should first set a guided point or a guided point just after setting the mode change otherwise the navigation point could be 0,0,0 and the copter will try to go home at 0 altitude.
This of course until the next follow me point is sent.

So either we set the guided point to the current location in case it is 0,0,0 and when switching to GUIDED or the GCS should be aware of flight mode and send message correctly.

Emile

2014-05-14 19:58 GMT+02:00 Arthur Benemann <notifi...@github.com>:

There is a problem with follow-me with DroidPlanner (haven't tested with AndroPilot), that the user cannot switch off from follow-me via the RC controller. It's somewhat related to #619.

The Problem

This is what's happening:

  • when in follow-me the GCS is constantly sending GUIDED waypoints to the drone, at a high rate (more than 1Hz).
  • If the GCS sees a mode change (to something different than GUIDED), it will switch off follow-me
  • Mode changes are detected by the heartbeat packet

So when in follow me the guided point's force a mode override at a very fast rate. When the user changes the mode via RC it takes until the next heartbeat for the GCS to detect the change. At which point the drone most certainly has already switched back to GUIDED, which makes the next heartbeat to say it`s on GUIDED. This makes the GCS totally unaware of the mode change.

The only way out of this is if Follow-me is switched off on the GCS, sdo mode changes can be correctly detected.

The solution

A possible solution was proposed on #65, but it was refused (and it's outdated now). But the main idea is to have two kinds of Guided Waypoints:

  • One that works as it is now, forcing a change to guided and setting the guided coord.
  • And other that only updates the guided coordinate, but just if in GUIDED mode.

Related code

At current master these seam to be the files involved in this problem:
Receives the guided message from the Ground Station:
https://github.com/diydrones/ardupilot/blob/2acddb9696fec77180863f3915080a69245084ec/libraries/GCS_MAVLink/GCS_Common.cpp#L681-L689
Does a little tour here:
https://github.com/diydrones/ardupilot/blob/416e9457ce11ae37200e6380834b1c5f3a4cd2e5/ArduCopter/GCS_Mavlink.pde#L1031-L1034
And finally lands here:
https://github.com/diydrones/ardupilot/blob/d857427444d8e8ffedd18add3075f370a36be41d/ArduCopter/commands_logic.pde#L777-L792

I will submit a PR later, hopefully we can get it into AC3.2 so users can have a safer follow-me.


Reply to this email directly or view it on GitHub.


Ben Nizette

unread,
May 15, 2014, 4:33:11 AM5/15/14
to drones-...@googlegroups.com
Hi Emile,

The 0,0,0 case is true the first time someone switches to guided, but how about the second? It'll probably then shoot off to an 'old' guided point which by now could have a person standing in it.  As such, I don't think it's safe to special-case 0,0,0 unless it's accompanied by some timeout mechanism.

Another option would be to differentiate between "switch to guided and move to" and just "move to", i.e. have two guided message types, only one of which changes modes.  I guess this is partially what you were referring to in that the GCS has to be aware not just of whether the craft is in GUIDED mode already, but whether the GCS should try and override things if it isn't.  That last point, when to do a switch-to, I think would simply be during an explicit user interaction such as first click or user explicitly resets.  At least in the first instance.

As an implementation detail, this would be easy be extended the guided mode "hack" that we've currently got, a parameter value of '2' is guided, could become switch-and-mve-to to preserve current behaviour; a value of '3' perhaps could be move-to only. Unless now is a good time to rework the whole guided thing, as some have been threatening for a while!

Ben.


--
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/d/optout.

Randy Mackay

unread,
May 15, 2014, 8:02:54 AM5/15/14
to drones-...@googlegroups.com

 

    I agree this is a problem and I think either of the solutions is ok at least as a temporary fix:

        Solution #1: GCS sends guided waypoint, then sends mode change to Guided (just the first time)

        Solution #2: hack the GCS_MAVLink so if the “current” packet is some other new value (can’t be “3” but maybe probably “4”) then it’s treated as a guided mode target update (i.e. no mode change).  By the way, this hacky bit of code has been moved into GCS_MAVLink library’s GCS_Common.cpp around line 681.

                  https://github.com/diydrones/ardupilot/blob/master/libraries/GCS_MAVLink/GCS_Common.cpp#L681

        Solution #3: write a new do-follow-me command and possibly deal with it differently

 

     The good thing about Solution #1 is I think it’s partially backwards compatible.  I.e. New GCS + Old ArduPIlot code will work but Old GCS + New ArduPilot code won’t.  I’d like to hear Tridge’s opinion because Plane and MavProxy are affected as well.

 

     Regarding reworking guided mode, we generally need it to handle all (or most) of the commands that can appear in missions.  To do that I think we need to extend the commands_logic.pde’s do_guided function so that instead of just setting the guided destination it needs to record that command somewhere, then check what the command is and pass it into a big switch statement like Auto does.

           https://github.com/diydrones/ardupilot/blob/master/ArduCopter/commands_logic.pde#L778

    Then we need to add a “verify_guided” which comes back again and again to ensure the command is progressing.

 

-Randy

C Wong

unread,
May 15, 2014, 8:20:16 PM5/15/14
to drones-...@googlegroups.com
Yes... is this switch to guided/follow me from stabilize/althold? 

In our follow-me code, we only allow to [followme] from a loiter state (always storing the current location as the 1st wp automatically, so it's not 0.0,0) then immediately (or via GCS user invocation) send guided or what I'm looking [now] at is option #3 that Randy mentioned. Basically I'm creating a followme variable set by a long command, then use MAVLINK_MSG_ID_GPS_RAW_INT packets (going to the APM) instead of wp packets, while still setting guided mode and add the gps packet as a the guided wp. Runs fine at a 3Hz update rate and preserves the normal guided mode behavior (e.g. from Mission Planner).

Now having the Tx switch get out of follow-me is tricky: you essentially have 2 masters (GCS and Tx) where as the APM is the slave. Best case is an event msg must be sent back to the GCS in order to turn off follow-me (when the user hits the Tx switch). Hence why I'm looking at option #3 as it avoids that guided mode situation between GCS and Tx and even allows you to immediately switch back to follow me if the Tx is switched back to the last state (i.e. if that's the desired behavior you want).

Randy Mackay

unread,
May 16, 2014, 11:12:29 PM5/16/14
to drones-...@googlegroups.com

 

     As a starting point at least I’ve merged Arthur’s change into master (the spelling mistake of “acceept” is my contribution J).

             https://github.com/diydrones/ardupilot/commit/e1b7e53c046049742ff40a6ddb0308de144fa1f6

 

     So this means that to work with AC3.2 the ground stations will need to first send a command to switch into Guided mode and follow that with a guided mode waypoint.  When copter switches to guided mode it initialises the guided mode target to a reasonable stopping point so no need to worry about it heading off into the sunset.

 

     I’m not sure how plane will react though.  We should try it in SITL.  Just set up a flight mode to be guided mode (“param set FLTMODE1 15”) put a plane into the air and switch it into Guided mode (“switch 1”)…or it maybe you can just type “GUIDED” into the mavproxy command prompt.

 

-Randy

 

From: drones-...@googlegroups.com [mailto:drones-...@googlegroups.com] On Behalf Of C Wong
Sent: May 16, 2014 9:20 AM
To: drones-...@googlegroups.com
Subject: Re: [drones-discuss] Re: [ardupilot] Copter: Follow-me safety (#1068)

 

Yes... is this switch to guided/follow me from stabilize/althold? 

--

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/d/optout.

Reply all
Reply to author
Forward
0 new messages