123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164 |
- #pragma once
- #include <AP_Common/AP_Common.h>
- #include <APM_Control/AR_AttitudeControl.h>
- #include <AP_Navigation/AP_Navigation.h>
- #include <AC_Avoidance/AP_OAPathPlanner.h>
- const float AR_WPNAV_HEADING_UNKNOWN = 99999.0f;
- class AR_WPNav {
- public:
-
- AR_WPNav(AR_AttitudeControl& atc, AP_Navigation& nav_controller);
-
- void update(float dt);
-
- float get_desired_speed() const { return _desired_speed; }
-
- void set_desired_speed(float speed) { _desired_speed = MAX(speed, 0.0f); }
-
- void set_desired_speed_to_default() { _desired_speed = _speed_max; }
-
- bool get_reversed() const { return _reversed; }
- void set_reversed(bool reversed) { _reversed = reversed; }
-
- float get_speed() const { return _desired_speed_limited; }
- float get_turn_rate_rads() const { return _desired_turn_rate_rads; }
-
- float get_lat_accel() const { return _desired_lat_accel; }
-
-
- bool set_desired_location(const struct Location& destination, float next_leg_bearing_cd = AR_WPNAV_HEADING_UNKNOWN) WARN_IF_UNUSED;
-
- bool set_desired_location_to_stopping_location() WARN_IF_UNUSED;
-
- bool set_desired_location_NED(const Vector3f& destination, float next_leg_bearing_cd = AR_WPNAV_HEADING_UNKNOWN) WARN_IF_UNUSED;
-
- bool reached_destination() const { return _reached_destination; }
-
- float get_distance_to_destination() const { return _distance_to_destination; }
-
- bool is_destination_valid() const { return _orig_and_dest_valid; }
-
- const Location &get_destination() { return _destination; }
-
- const Location &get_oa_destination() { return _oa_destination; }
-
- float wp_bearing_cd() const { return _wp_bearing_cd; }
- float nav_bearing_cd() const { return _desired_heading_cd; }
- float crosstrack_error() const { return _cross_track_error; }
-
- float oa_wp_bearing_cd() const { return _oa_wp_bearing_cd; }
-
- void set_turn_params(float turn_max_g, float turn_radius, bool pivot_possible);
-
- void set_default_overshoot(float overshoot);
-
- float get_default_speed() const { return _speed_max; }
- float get_radius() const { return _radius; }
- float get_overshoot() const { return _overshoot; }
- float get_pivot_rate() const { return _pivot_rate; }
-
- static const struct AP_Param::GroupInfo var_info[];
- private:
-
- bool is_active() const;
-
- void update_distance_and_bearing_to_destination();
-
-
- void update_steering(const Location& current_loc, float current_speed);
-
-
-
- void update_desired_speed(float dt);
-
-
- bool get_stopping_location(Location& stopping_loc) WARN_IF_UNUSED;
-
- bool use_pivot_steering_at_next_WP(float yaw_error_cd) const;
-
- bool use_pivot_steering(float yaw_error_cd);
-
- void apply_speed_min(float &desired_speed);
- private:
-
- AP_Float _speed_max;
- AP_Float _speed_min;
- AP_Float _radius;
- AP_Float _overshoot;
- AP_Int16 _pivot_angle;
- AP_Int16 _pivot_rate;
-
- AR_AttitudeControl& _atc;
- AP_Navigation& _nav_controller;
-
- float _turn_max_mss;
- float _turn_radius;
- bool _pivot_possible;
- bool _pivot_active;
-
- uint32_t _last_update_ms;
- Location _origin;
- Location _destination;
- bool _orig_and_dest_valid;
- bool _reversed;
- float _desired_speed_final;
-
- float _desired_speed;
- float _desired_speed_limited;
- float _desired_turn_rate_rads;
- float _desired_lat_accel;
- float _desired_heading_cd;
- float _wp_bearing_cd;
- float _cross_track_error;
-
- float _distance_to_destination;
- bool _reached_destination;
-
- bool _oa_active;
- Location _oa_origin;
- Location _oa_destination;
- float _oa_distance_to_destination;
- float _oa_wp_bearing_cd;
- };
|