2016-07-21 09:44:09 -03:00
|
|
|
#include "Copter.h"
|
|
|
|
|
|
|
|
/*
|
|
|
|
* control_avoid.cpp - init and run calls for AP_Avoidance's AVOID flight mode
|
|
|
|
*
|
|
|
|
* This re-uses GUIDED mode functions but does not interfere with the GCS or companion computer's
|
|
|
|
* use of guided mode because the velocity requests arrive from different sources (i.e MAVLink messages
|
|
|
|
* for GCS and Companion Computers vs the AP_Avoidance_Copter class for adsb avoidance) and inputs from
|
|
|
|
* each source are only accepted and processed in the appropriate flight mode.
|
|
|
|
*/
|
|
|
|
|
|
|
|
// initialise avoid_adsb controller
|
2019-05-09 23:18:49 -03:00
|
|
|
bool ModeAvoidADSB::init(const bool ignore_checks)
|
2016-07-21 09:44:09 -03:00
|
|
|
{
|
|
|
|
// re-use guided mode
|
2019-05-09 23:18:49 -03:00
|
|
|
return ModeGuided::init(ignore_checks);
|
2016-07-21 09:44:09 -03:00
|
|
|
}
|
|
|
|
|
2019-05-09 23:18:49 -03:00
|
|
|
bool ModeAvoidADSB::set_velocity(const Vector3f& velocity_neu)
|
2016-07-21 09:44:09 -03:00
|
|
|
{
|
|
|
|
// check flight mode
|
2018-02-07 22:21:09 -04:00
|
|
|
if (copter.control_mode != AVOID_ADSB) {
|
2016-07-21 09:44:09 -03:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// re-use guided mode's velocity controller
|
2019-05-09 23:18:49 -03:00
|
|
|
ModeGuided::set_velocity(velocity_neu);
|
2016-07-21 09:44:09 -03:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// runs the AVOID_ADSB controller
|
2019-05-09 23:18:49 -03:00
|
|
|
void ModeAvoidADSB::run()
|
2016-07-21 09:44:09 -03:00
|
|
|
{
|
|
|
|
// re-use guided mode's velocity controller
|
|
|
|
// Note: this is safe from interference from GCSs and companion computer's whose guided mode
|
|
|
|
// position and velocity requests will be ignored while the vehicle is not in guided mode
|
2019-05-09 23:18:49 -03:00
|
|
|
ModeGuided::run();
|
2016-07-21 09:44:09 -03:00
|
|
|
}
|