Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Ardupilot
GitHub Repository: Ardupilot/ardupilot
Path: blob/master/libraries/AC_WPNav/AC_WPNav_OA.h
9916 views
1
#pragma once
2
3
#include "AC_WPNav_config.h"
4
5
#if AC_WPNAV_OA_ENABLED
6
7
#include <AC_WPNav/AC_WPNav.h>
8
#include <AC_Avoidance/AP_OAPathPlanner.h>
9
#include <AC_Avoidance/AP_OABendyRuler.h>
10
11
class AC_WPNav_OA : public AC_WPNav
12
{
13
14
public:
15
/// Constructor
16
AC_WPNav_OA(const AP_AHRS_View& ahrs, AC_PosControl& pos_control, const AC_AttitudeControl& attitude_control);
17
18
// Returns the object-avoidance-adjusted waypoint location (in global coordinates).
19
// Falls back to original destination if OA is not active.
20
bool get_oa_wp_destination(Location& destination) const override;
21
22
// Sets the waypoint destination using NEU coordinates in centimeters.
23
// See set_wp_destination_NED_m() for full details.
24
bool set_wp_destination_NEU_cm(const Vector3f& destination_neu_cm, bool is_terrain_alt = false) override;
25
26
// Sets the waypoint destination using NED coordinates in meters.
27
// - destination_ned_m: NED offset from EKF origin in meters.
28
// - is_terrain_alt: true if the destination_ned_m is relative to the terrain surface.
29
// arc_rad specifies the signed arc angle in radians for an ARC_WAYPOINT segment (0 for straight path)
30
// - Resets OA state on success.
31
bool set_wp_destination_NED_m(const Vector3p& destination_ned_m, bool is_terrain_alt = false, float arc_rad = 0.0) override;
32
33
// Returns the horizontal distance to the final destination in centimeters.
34
// See get_wp_distance_to_destination_m() for full details.
35
float get_wp_distance_to_destination_cm() const override;
36
37
// Returns the horizontal distance to the final destination in meters.
38
// Ignores OA-adjusted targets and always measures to the original final destination.
39
float get_wp_distance_to_destination_m() const override;
40
41
// Returns the bearing to the final destination in centidegrees.
42
// See get_wp_bearing_to_destination_rad() for full details.
43
int32_t get_wp_bearing_to_destination_cd() const override;
44
45
// Returns the bearing to the final destination in radians.
46
// Ignores OA-adjusted targets and always calculates from original final destination.
47
virtual float get_wp_bearing_to_destination_rad() const override;
48
49
// Returns true if the vehicle has reached the final destination within radius threshold.
50
// Ignores OA-adjusted intermediate destinations.
51
bool reached_wp_destination() const override;
52
53
// Runs the waypoint navigation update loop, including OA path planning logic.
54
// Delegates to parent class if OA is not active or not required.
55
bool update_wpnav() override;
56
57
protected:
58
59
// oa path planning variables
60
AP_OAPathPlanner::OA_RetState _oa_state; // state of object avoidance, if OA_SUCCESS we use _oa_destination to avoid obstacles
61
Vector3p _origin_oabak_ned_m; // backup of _origin_ned_m so it can be restored when oa completes
62
Vector3p _destination_oabak_ned_m; // backup of _destination_ned_m so it can be restored when oa completes
63
Vector3p _next_destination_oabak_ned_m; // backup of _next_destination_ned_m so it can be restored when oa completes
64
bool _is_terrain_alt_oabak; // true if backup origin and destination z-axis are terrain altitudes
65
Location _oa_destination; // intermediate destination during avoidance
66
Location _oa_next_destination; // intermediate next destination during avoidance
67
};
68
69
#endif // AC_WPNAV_OA_ENABLED
70
71