You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
39 lines
1.3 KiB
39 lines
1.3 KiB
9 years ago
|
#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
|
||
7 years ago
|
bool Copter::ModeAvoidADSB::init(const bool ignore_checks)
|
||
9 years ago
|
{
|
||
|
// re-use guided mode
|
||
7 years ago
|
return Copter::ModeGuided::init(ignore_checks);
|
||
9 years ago
|
}
|
||
|
|
||
7 years ago
|
bool Copter::ModeAvoidADSB::set_velocity(const Vector3f& velocity_neu)
|
||
9 years ago
|
{
|
||
|
// check flight mode
|
||
9 years ago
|
if (_copter.control_mode != AVOID_ADSB) {
|
||
9 years ago
|
return false;
|
||
|
}
|
||
|
|
||
|
// re-use guided mode's velocity controller
|
||
7 years ago
|
Copter::ModeGuided::set_velocity(velocity_neu);
|
||
9 years ago
|
return true;
|
||
|
}
|
||
|
|
||
|
// runs the AVOID_ADSB controller
|
||
7 years ago
|
void Copter::ModeAvoidADSB::run()
|
||
9 years ago
|
{
|
||
|
// 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
|
||
7 years ago
|
Copter::ModeGuided::run();
|
||
9 years ago
|
}
|