Rover: Make guided operate the same way as Plane/Copter.

This is a safety change.  Lets say you have a GCS which is in
followme mode which is really GUIDED mode with continually updated
waypoints.  If the user then changes mode with the RC transmitter to
HOLD or anything else then the Rover should STOP listening to the
updated guided mode waypoints.  This is how Plane/Copter work.
This commit is contained in:
Grant Morphett 2015-06-03 22:31:31 +10:00 committed by Andrew Tridgell
parent 32994a5b1e
commit f314b243ee
2 changed files with 11 additions and 2 deletions

View File

@ -789,10 +789,13 @@ GCS_MAVLINK::data_stream_send(void)
void GCS_MAVLINK::handle_guided_request(AP_Mission::Mission_Command &cmd)
{
if (rover.control_mode != GUIDED) {
// only accept position updates when in GUIDED mode
return;
}
rover.guided_WP = cmd.content.location;
rover.set_mode(GUIDED);
// make any new wp uploaded instant (in case we are already in Guided mode)
rover.rtl_complete = false;
rover.set_guided_WP();

View File

@ -306,6 +306,11 @@ void Rover::set_mode(enum mode mode)
case GUIDED:
rtl_complete = false;
/*
when entering guided mode we set the target as the current
location. This matches the behaviour of the copter code.
*/
guided_WP = current_loc;
set_guided_WP();
break;
@ -329,6 +334,7 @@ bool Rover::mavlink_set_mode(uint8_t mode)
case HOLD:
case LEARNING:
case STEERING:
case GUIDED:
case AUTO:
case RTL:
set_mode((enum mode)mode);