38 #include <mathlib/mathlib.h> 46 _obstacle_avoidance(this)
96 const float yawrate_max =
math::radians(_param_mpc_yawrauto_max.get());
103 const float dyaw_max = yawrate_max *
_deltatime;
189 bool triplet_update =
true;
198 triplet_update =
false;
274 if (_param_com_obs_avoid.get()
292 switch (_param_mpc_yaw_mode.get()) {
320 if (PX4_ISFINITE(v.
length())) {
343 return (PX4_ISFINITE(sp.
lat) && PX4_ISFINITE(sp.
lon) && PX4_ISFINITE(sp.
alt));
378 return PX4_ISFINITE(
_reference_altitude) && PX4_ISFINITE(ref_lat) && PX4_ISFINITE(ref_lon);
396 bool velocity_valid = PX4_ISFINITE(vx) && PX4_ISFINITE(vy) &&
399 if (velocity_valid) {
419 if (u_prev_to_target * pos_to_target < 0.0
f) {
constexpr _Tp constrain(_Tp val, _Tp min_val, _Tp max_val)
matrix::Vector3f _velocity
current vehicle velocity
matrix::Vector3f _next_wp
The next waypoint after target (local frame).
bool _isFinite(const position_setpoint_s &sp)
Checks if all waypoint triplets are finite.
virtual bool activate(vehicle_local_position_setpoint_s last_setpoint)
Call once on the event where you switch to the task.
virtual void _setDefaultConstraints()
Set constraints to default values.
float _deltatime
passed time in seconds since the task was last updated
bool activate(vehicle_local_position_setpoint_s last_setpoint) override
Call once on the event where you switch to the task.
Map from global triplet to local quadruple.
uORB::SubscriptionData< position_setpoint_triplet_s > _sub_triplet_setpoint
static constexpr float SIGMA_NORM
struct position_setpoint_s next
bool updateFinalize() override
Call after update() to constrain the generated setpoints in order to comply with the constraints of t...
bool updateInitialize() override
Call before activate() or update() to initialize time and input data.
void checkAvoidanceProgress(const matrix::Vector3f &pos, const matrix::Vector3f &prev_wp, float target_acceptance_radius, const matrix::Vector2f &closest_pt)
Checks the vehicle progress between previous and current position waypoint of the triplet...
void _updateInternalWaypoints()
Depending on state of vehicle, the internal waypoints might differ from target (for instance if offtr...
matrix::Vector2f _closest_pt
closest point to the vehicle position on the line previous - target
matrix::Vector3f _triplet_target
current triplet from navigator which may differ from the intenal one (_target) depending on the vehic...
struct position_setpoint_s previous
bool _evaluateGlobalReference()
Check is global reference is available.
matrix::Vector3f _position_setpoint
Setpoints which the position controller has to execute.
void _set_heading_from_mode()
Vehicle is in normal tracking mode from triplet previous to triplet target.
WaypointType
This enum has to agree with position_setpoint_s type definition The only reason for not using the str...
struct position_setpoint_s current
Vehilce is behind previous waypoint.
uORB::SubscriptionData< home_position_s > _sub_home_position
bool _evaluateTriplets()
Checks and sets triplets.
matrix::Vector3f _triplet_next_wp
next triplet from navigator which may differ from the intenal one (_next_wp) depending on the vehicle...
matrix::Vector2f _getTargetVelocityXY()
only used for follow-me and only here because of legacy reason.
void _limitYawRate()
Limits the rate of change of the yaw setpoint.
float get_weathervane_yawrate()
bool _yaw_lock
if within acceptance radius, lock yaw to current yaw
matrix::Vector3f _target
Target waypoint (local frame).
hrt_abstime _time_stamp_reference
time stamp when last reference update occured.
constexpr T radians(T degrees)
Vector< float, 6 > f(float t, const Matrix< float, 6, 1 > &, const Matrix< float, 3, 1 > &)
virtual bool updateInitialize()
Call before activate() or update() to initialize time and input data.
Vector2< float > Vector2f
ObstacleAvoidance _obstacle_avoidance
class adjusting setpoints according to external avoidance module's input
void _setDefaultConstraints() override
Set constraints to default values.
matrix::Vector3f _position
current vehicle position
matrix::Vector3f _velocity_setpoint
uORB::SubscriptionData< vehicle_local_position_s > _sub_vehicle_local_position
bool _compute_heading_from_2D_vector(float &heading, matrix::Vector2f v)
Computes and sets heading a 2D vector.
vehicle_constraints_s _constraints
Vehicle constraints.
float _reference_altitude
Altitude relative to ground.
WaypointType _type
Type of current target triplet.
matrix::Vector3f _triplet_prev_wp
previous triplet from navigator which may differ from the intenal one (_prev_wp) depending on the veh...
constexpr _Tp min(_Tp a, _Tp b)
Type wrap_pi(Type x)
Wrap value in range [-π, π)
float _target_acceptance_radius
Acceptances radius of the target.
virtual bool _checkTakeoff()
Determine when to trigger a takeoff (ignored in flight)
matrix::Vector2f _lock_position_xy
if no valid triplet is received, lock positition to current position
Vector3< float > Vector3f
void updateAvoidanceDesiredWaypoints(const matrix::Vector3f &curr_wp, const float curr_yaw, const float curr_yawspeed, const matrix::Vector3f &next_wp, const float next_yaw, const float next_yawspeed, const bool ext_yaw_active, const int wp_type)
Updates the desired waypoints to send to the obstacle avoidance system.
int map_projection_project(const struct map_projection_reference_s *ref, double lat, double lon, float *x, float *y)
State _getCurrentState()
Computes the current vehicle state based on the vehicle position and navigator triplets.
Vehicle is more than cruise speed away from track.
matrix::Vector3f _prev_wp
Previous waypoint (local frame).
map_projection_reference_s _reference_position
Structure used to project lat/lon setpoint into local frame.
float _yaw
current vehicle yaw heading
Vehicle is in front of target.
uORB::SubscriptionData< manual_control_setpoint_s > _sub_manual_control_setpoint
matrix::Vector3f _prev_prev_wp
Pre-previous waypoint (local frame).
float _mc_cruise_speed
Requested cruise speed.
int map_projection_init(struct map_projection_reference_s *ref, double lat_0, double lon_0)
Initializes the map transformation given by the argument and sets the timestamp to now...
WeatherVane * _ext_yaw_handler
external weathervane library, used to implement a yaw control law that turns the vehicle nose into th...
uORB::SubscriptionData< vehicle_status_s > _sub_vehicle_status