diff --git a/ArduPlane/GCS_MAVLink_Plane.cpp b/ArduPlane/GCS_MAVLink_Plane.cpp index 9dad1e1446c..ac22ee8c3b2 100644 --- a/ArduPlane/GCS_MAVLink_Plane.cpp +++ b/ArduPlane/GCS_MAVLink_Plane.cpp @@ -545,7 +545,7 @@ MAV_RESULT GCS_MAVLINK_Plane::handle_command_preflight_calibration(const mavlink void GCS_MAVLINK_Plane::packetReceived(const mavlink_status_t &status, const mavlink_message_t &msg) { -#if HAL_ADSB_ENABLED +#if AP_ADSB_AVOIDANCE_ENABLED plane.avoidance_adsb.handle_msg(msg); #endif GCS_MAVLINK::packetReceived(status, msg); diff --git a/ArduPlane/Parameters.cpp b/ArduPlane/Parameters.cpp index e64339f07c9..42cfafd2083 100644 --- a/ArduPlane/Parameters.cpp +++ b/ArduPlane/Parameters.cpp @@ -802,11 +802,13 @@ const AP_Param::Info Plane::var_info[] = { // @Group: ADSB_ // @Path: ../libraries/AP_ADSB/AP_ADSB.cpp GOBJECT(adsb, "ADSB_", AP_ADSB), +#endif // HAL_ADSB_ENABLED +#if AP_ADSB_AVOIDANCE_ENABLED // @Group: AVD_ // @Path: ../libraries/AP_Avoidance/AP_Avoidance.cpp GOBJECT(avoidance_adsb, "AVD_", AP_Avoidance_Plane), -#endif +#endif // AP_ADSB_AVOIDANCE_ENABLED #if HAL_QUADPLANE_ENABLED // @Group: Q_ diff --git a/ArduPlane/Plane.cpp b/ArduPlane/Plane.cpp index ec6bb434507..7a2803ce0db 100644 --- a/ArduPlane/Plane.cpp +++ b/ArduPlane/Plane.cpp @@ -131,9 +131,9 @@ const AP_Scheduler::Task Plane::scheduler_tasks[] = { SCHED_TASK_CLASS(AP_Logger, &plane.logger, periodic_tasks, 50, 400, 138), #endif SCHED_TASK_CLASS(AP_InertialSensor, &plane.ins, periodic, 50, 50, 141), -#if HAL_ADSB_ENABLED +#if HAL_ADSB_ENABLED || AP_ADSB_AVOIDANCE_ENABLED SCHED_TASK(avoidance_adsb_update, 10, 100, 144), -#endif +#endif // HAL_ADSB_ENABLED || AP_ADSB_AVOIDANCE_ENABLED SCHED_TASK_CLASS(RC_Channels, (RC_Channels*)&plane.g2.rc_channels, read_aux_all, 10, 200, 147), #if HAL_BUTTON_ENABLED SCHED_TASK_CLASS(AP_Button, &plane.button, update, 5, 100, 150), diff --git a/ArduPlane/Plane.h b/ArduPlane/Plane.h index 18a09aa0d73..c1915d81a4d 100644 --- a/ArduPlane/Plane.h +++ b/ArduPlane/Plane.h @@ -78,6 +78,7 @@ #include // Optical Flow library #include #include +#include // "ADSB" avoidance library #include #include #include // Landing Gear library @@ -117,9 +118,9 @@ #include "RC_Channel_Plane.h" // RC Channel Library #include "Parameters.h" -#if HAL_ADSB_ENABLED +#if AP_ADSB_AVOIDANCE_ENABLED #include "avoidance_adsb.h" -#endif +#endif // AP_ADSB_AVOIDANCE_ENABLED #include "AP_Arming_Plane.h" #include "pullup.h" #include "systemid.h" @@ -703,10 +704,12 @@ private: FUNCTOR_BIND_MEMBER(&Plane::update_flight_stage, void)}; #if HAL_ADSB_ENABLED AP_ADSB adsb; +#endif // HAL_ADSB_ENABLED +#if AP_ADSB_AVOIDANCE_ENABLED // avoidance of adsb enabled vehicles (normally manned vehicles) AP_Avoidance_Plane avoidance_adsb{adsb}; -#endif +#endif // AP_ADSB_AVOIDANCE_ENABLED // Outback Challenge Failsafe Support #if AP_ADVANCEDFAILSAFE_ENABLED diff --git a/ArduPlane/avoidance_adsb.cpp b/ArduPlane/avoidance_adsb.cpp index b758eb13660..93c633a8e95 100644 --- a/ArduPlane/avoidance_adsb.cpp +++ b/ArduPlane/avoidance_adsb.cpp @@ -2,14 +2,19 @@ #include #include "Plane.h" -#if HAL_ADSB_ENABLED +#if HAL_ADSB_ENABLED || AP_ADSB_AVOIDANCE_ENABLED void Plane::avoidance_adsb_update(void) { +#if HAL_ADSB_ENABLED adsb.update(); +#endif // HAL_ADSB_ENABLED +#if AP_ADSB_AVOIDANCE_ENABLED avoidance_adsb.update(); +#endif // AP_ADSB_AVOIDANCE_ENABLED } +#endif // HAL_ADSB_ENABLED || AP_ADSB_AVOIDANCE_ENABLED - +#if AP_ADSB_AVOIDANCE_ENABLED MAV_COLLISION_ACTION AP_Avoidance_Plane::handle_avoidance(const AP_Avoidance::Obstacle *obstacle, MAV_COLLISION_ACTION requested_action) { MAV_COLLISION_ACTION actual_action = requested_action; @@ -223,5 +228,4 @@ bool AP_Avoidance_Plane::handle_avoidance_horizontal(const AP_Avoidance::Obstacl return false; } -#endif // HAL_ADSB_ENABLED - +#endif // AP_ADSB_AVOIDANCE_ENABLED diff --git a/ArduPlane/avoidance_adsb.h b/ArduPlane/avoidance_adsb.h index 3fbc8c771c9..009c14ce93a 100644 --- a/ArduPlane/avoidance_adsb.h +++ b/ArduPlane/avoidance_adsb.h @@ -2,6 +2,8 @@ #include +#if AP_ADSB_AVOIDANCE_ENABLED + // Provide Plane-specific implementation of avoidance. While most of // the logic for doing the actual avoidance is present in // AP_Avoidance, this class allows Plane to override base @@ -33,3 +35,5 @@ protected: // control mode before avoidance began enum Mode::Number prev_control_mode_number = Mode::Number::RTL; }; + +#endif // AP_ADSB_AVOIDANCE_ENABLED