Line data Source code
1 : #include "Copter.h" 2 : 3 : #if AP_ADSB_AVOIDANCE_ENABLED 4 : 5 : /* 6 : * control_avoid.cpp - init and run calls for AP_Avoidance's AVOID flight mode 7 : * 8 : * This re-uses GUIDED mode functions but does not interfere with the GCS or companion computer's 9 : * use of guided mode because the velocity requests arrive from different sources (i.e MAVLink messages 10 : * for GCS and Companion Computers vs the AP_Avoidance_Copter class for adsb avoidance) and inputs from 11 : * each source are only accepted and processed in the appropriate flight mode. 12 : */ 13 : 14 : // initialise avoid_adsb controller 15 2 : bool ModeAvoidADSB::init(const bool ignore_checks) 16 : { 17 : // re-use guided mode 18 2 : return ModeGuided::init(ignore_checks); 19 : } 20 : 21 0 : bool ModeAvoidADSB::set_velocity_NEU_ms(const Vector3f& velocity_neu_ms) 22 : { 23 : // check flight mode 24 0 : if (copter.flightmode->mode_number() != Mode::Number::AVOID_ADSB) { 25 0 : return false; 26 : } 27 : 28 : // re-use guided mode's velocity controller 29 0 : ModeGuided::set_vel_NED_ms(velocity_neu_ms); 30 0 : return true; 31 : } 32 : 33 : // runs the AVOID_ADSB controller 34 880 : void ModeAvoidADSB::run() 35 : { 36 : // re-use guided mode's velocity controller 37 : // Note: this is safe from interference from GCSs and companion computer's whose guided mode 38 : // position and velocity requests will be ignored while the vehicle is not in guided mode 39 880 : ModeGuided::run(); 40 880 : } 41 : 42 : #endif // AP_ADSB_AVOIDANCE_ENABLED