ardupilot/ArduCopter/mode_avoid_adsb.cpp
Peter Barker b4537bebd8 Copter: move control_mode_t into being Mode::Number enum class
Fixes this compiler error:

In file included from ../../ArduCopter/sensors.cpp:1:
In file included from ../../ArduCopter/Copter.h:195:
../../ArduCopter/mode.h:1291:9: fatal error: declaration shadows a variable in the global namespace [-Wshadow]
        AUTO,           // after A and B defined, pilot toggle the switch from one side to the other, vehicle flies autonomously
        ^
../../ArduCopter/defines.h:38:5: note: previous declaration is here
    AUTO =          3,  // fully automatic waypoint control using mission commands
    ^
1 error generated.
2019-09-13 13:12:08 +09:00

39 lines
1.3 KiB
C++

#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
bool ModeAvoidADSB::init(const bool ignore_checks)
{
// re-use guided mode
return ModeGuided::init(ignore_checks);
}
bool ModeAvoidADSB::set_velocity(const Vector3f& velocity_neu)
{
// check flight mode
if (copter.control_mode != Mode::Number::AVOID_ADSB) {
return false;
}
// re-use guided mode's velocity controller
ModeGuided::set_velocity(velocity_neu);
return true;
}
// runs the AVOID_ADSB controller
void ModeAvoidADSB::run()
{
// 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
ModeGuided::run();
}