ardupilot/ArduPlane/avoidance_adsb.h
Peter Barker 2784f8fa7f Plane: remove persistent guided_WP_loc state
So instead of updating plane.guided_WP_loc and then calling
set_guided_WP(void) to copy that state into plane.next_WP_loc we pass
the new location in the call to set_guided_WP(const Location &loc).

avoidance was the only place which was not entirely over-writing
plane.guided_WP_loc.  However, plane.next_WP_loc was updated to be the
current location when we entered guided mode.  If we update the
horizontal/vertical avoidance now it is relative to the current
location, not the guided wp location, which could be quite important.
2022-03-22 10:14:40 +11:00

37 lines
1.3 KiB
C++

#pragma once
#include <AP_Avoidance/AP_Avoidance.h>
// 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
// functionality - for example, not doing anything while landed.
class AP_Avoidance_Plane : public AP_Avoidance {
public:
using AP_Avoidance::AP_Avoidance;
/* Do not allow copies */
AP_Avoidance_Plane(const AP_Avoidance_Plane &other) = delete;
AP_Avoidance_Plane &operator=(const AP_Avoidance_Plane&) = delete;
protected:
// override avoidance handler
MAV_COLLISION_ACTION handle_avoidance(const AP_Avoidance::Obstacle *obstacle, MAV_COLLISION_ACTION requested_action) override;
// override recovery handler
void handle_recovery(RecoveryAction recovery_action) override;
// check flight mode is avoid_adsb
bool check_flightmode(bool allow_mode_change);
// vertical avoidance handler
bool handle_avoidance_vertical(const AP_Avoidance::Obstacle *obstacle, bool allow_mode_change, Location &new_loc);
// horizontal avoidance handler
bool handle_avoidance_horizontal(const AP_Avoidance::Obstacle *obstacle, bool allow_mode_change, Location &new_loc);
// control mode before avoidance began
enum Mode::Number prev_control_mode_number = Mode::Number::RTL;
};