#pragma once12#include "AC_WPNav_config.h"34#if AC_WPNAV_OA_ENABLED56#include <AC_WPNav/AC_WPNav.h>7#include <AC_Avoidance/AP_OAPathPlanner.h>8#include <AC_Avoidance/AP_OABendyRuler.h>910class AC_WPNav_OA : public AC_WPNav11{1213public:14/// Constructor15AC_WPNav_OA(const AP_AHRS_View& ahrs, AC_PosControl& pos_control, const AC_AttitudeControl& attitude_control);1617// Returns the object-avoidance-adjusted waypoint location (in global coordinates).18// Falls back to original destination if OA is not active.19bool get_oa_wp_destination(Location& destination) const override;2021// Sets the waypoint destination using NEU coordinates in centimeters.22// See set_wp_destination_NED_m() for full details.23bool set_wp_destination_NEU_cm(const Vector3f& destination_neu_cm, bool is_terrain_alt = false) override;2425// Sets the waypoint destination using NED coordinates in meters.26// - destination_ned_m: NED offset from EKF origin in meters.27// - is_terrain_alt: true if the destination_ned_m is relative to the terrain surface.28// arc_rad specifies the signed arc angle in radians for an ARC_WAYPOINT segment (0 for straight path)29// - Resets OA state on success.30bool set_wp_destination_NED_m(const Vector3p& destination_ned_m, bool is_terrain_alt = false, float arc_rad = 0.0) override;3132// Returns the horizontal distance to the final destination in centimeters.33// See get_wp_distance_to_destination_m() for full details.34float get_wp_distance_to_destination_cm() const override;3536// Returns the horizontal distance to the final destination in meters.37// Ignores OA-adjusted targets and always measures to the original final destination.38float get_wp_distance_to_destination_m() const override;3940// Returns the bearing to the final destination in centidegrees.41// See get_wp_bearing_to_destination_rad() for full details.42int32_t get_wp_bearing_to_destination_cd() const override;4344// Returns the bearing to the final destination in radians.45// Ignores OA-adjusted targets and always calculates from original final destination.46virtual float get_wp_bearing_to_destination_rad() const override;4748// Returns true if the vehicle has reached the final destination within radius threshold.49// Ignores OA-adjusted intermediate destinations.50bool reached_wp_destination() const override;5152// Runs the waypoint navigation update loop, including OA path planning logic.53// Delegates to parent class if OA is not active or not required.54bool update_wpnav() override;5556protected:5758// oa path planning variables59AP_OAPathPlanner::OA_RetState _oa_state; // state of object avoidance, if OA_SUCCESS we use _oa_destination to avoid obstacles60Vector3p _origin_oabak_ned_m; // backup of _origin_ned_m so it can be restored when oa completes61Vector3p _destination_oabak_ned_m; // backup of _destination_ned_m so it can be restored when oa completes62Vector3p _next_destination_oabak_ned_m; // backup of _next_destination_ned_m so it can be restored when oa completes63bool _is_terrain_alt_oabak; // true if backup origin and destination z-axis are terrain altitudes64Location _oa_destination; // intermediate destination during avoidance65Location _oa_next_destination; // intermediate next destination during avoidance66};6768#endif // AC_WPNAV_OA_ENABLED697071