ArduPlane: add and use AP_ADSB_AVOIDANCE_ENABLED

this gates the "ADSB" avoidance feature used for macro-level avoidance.  It's not actually limited to ADSB as input...
This commit is contained in:
Peter Barker
2025-06-26 16:32:22 +10:00
committed by Peter Barker
parent 831078bbc2
commit dc65e9ac7f
6 changed files with 24 additions and 11 deletions
+1 -1
View File
@@ -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);
+3 -1
View File
@@ -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_
+2 -2
View File
@@ -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),
+6 -3
View File
@@ -78,6 +78,7 @@
#include <AP_OpticalFlow/AP_OpticalFlow.h> // Optical Flow library
#include <AP_Parachute/AP_Parachute.h>
#include <AP_ADSB/AP_ADSB.h>
#include <AP_Avoidance/AP_Avoidance_config.h> // "ADSB" avoidance library
#include <AP_ICEngine/AP_ICEngine.h>
#include <AP_Landing/AP_Landing.h>
#include <AP_LandingGear/AP_LandingGear.h> // 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
+8 -4
View File
@@ -2,14 +2,19 @@
#include <stdio.h>
#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
+4
View File
@@ -2,6 +2,8 @@
#include <AP_Avoidance/AP_Avoidance.h>
#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