29 #include "generated/flight_plan.h"
32 #ifndef NAV_HYBRID_MAX_BANK
39 #ifndef NAV_HYBRID_MAX_AIRSPEED
40 #define NAV_HYBRID_MAX_AIRSPEED 15.0f
43 #ifndef NAV_HYBRID_SPEED_MARGIN
44 #define NAV_HYBRID_SPEED_MARGIN 10.0f
47 #define NAV_MAX_SPEED (NAV_HYBRID_MAX_AIRSPEED + NAV_HYBRID_SPEED_MARGIN)
50 #ifndef NAV_HYBRID_GOTO_MAX_SPEED
51 #define NAV_HYBRID_GOTO_MAX_SPEED NAV_MAX_SPEED
54 #ifndef NAV_HYBRID_MAX_DECELERATION
55 #define NAV_HYBRID_MAX_DECELERATION 1.0
58 #ifndef NAV_HYBRID_MAX_ACCELERATION
59 #define NAV_HYBRID_MAX_ACCELERATION 4.0
62 #ifndef NAV_HYBRID_SOFT_ACCELERATION
63 #define NAV_HYBRID_SOFT_ACCELERATION NAV_HYBRID_MAX_ACCELERATION
71 #ifndef NAV_HYBRID_MAX_EXPECTED_WIND
72 #define NAV_HYBRID_MAX_EXPECTED_WIND 5.0f
76 #ifdef NAV_HYBRID_LINE_GAIN
82 #ifndef NAV_HYBRID_NAV_LINE_DIST
83 #define NAV_HYBRID_NAV_LINE_DIST 50.f
86 #ifndef NAV_HYBRID_NAV_CIRCLE_DIST
87 #define NAV_HYBRID_NAV_CIRCLE_DIST 40.f
90 #ifdef GUIDANCE_INDI_POS_GAIN
92 #elif defined(NAV_HYBRID_POS_GAIN)
98 #if defined(NAV_HYBRID_POS_GAIN) && defined(GUIDANCE_INDI_POS_GAIN)
99 #warning "NAV_HYBRID_POS_GAIN and GUIDANCE_INDI_POS_GAIN serve similar purpose and are both defined, using GUIDANCE_INDI_POS_GAIN"
102 #ifndef GUIDANCE_INDI_HYBRID
107 #ifndef NAV_HYBRID_EXT_VISION_SETPOINT_MODE
108 #define NAV_HYBRID_EXT_VISION_SETPOINT_MODE FALSE
112 #ifndef NAV_HYBRID_LIMIT_CIRCLE_RADIUS
113 #define NAV_HYBRID_LIMIT_CIRCLE_RADIUS FALSE
150 #if NAV_HYBRID_EXT_VISION_SETPOINT_MODE
171 Bound(desired_speed, 0.0f, max_h_speed);
180 float length_normalv = length_line;
216 float max_speed_decel = sqrtf(max_speed_decel2);
229 if (approaching_time > 0.f) {
233 VECT2_SMUL(estimated_progress, *speed, approaching_time);
234 VECT2_SUM(estimated_pos, *pos, estimated_progress);
255 return (diff.
x * from_diff.
x + diff.
y * from_diff.
y < 0.f);
268 float sign_radius = (radius > 0.f) ? 1.f : (radius < 0.f) ? -1.f : 0.f;
270 float abs_radius = fabsf(radius);
271 #if NAV_HYBRID_LIMIT_CIRCLE_RADIUS
273 abs_radius = Max(abs_radius, min_radius);
275 if (abs_radius > 0.1f) {
282 NormRadAngle(trigo_diff);
286 Bound(progress_angle, M_PI / 16.f, M_PI / 4.f);
void float_vect2_bound_in_2d(struct FloatVect2 *vect2, float bound)
static float float_vect2_norm(struct FloatVect2 *v)
static void float_vect2_normalize(struct FloatVect2 *v)
normalize 2D vector in place
#define VECT2_ADD(_a, _b)
#define VECT2_SMUL(_vo, _vi, _s)
#define VECT2_DIFF(_c, _a, _b)
#define VECT2_COPY(_a, _b)
#define VECT2_SUM(_c, _a, _b)
#define VECT2_ASSIGN(_a, _x, _y)
#define PPRZ_ISA_GRAVITY
earth-surface gravitational acceleration in m/s^2
static struct EnuCoor_f * stateGetPositionEnu_f(void)
Get position in local ENU coordinates (float).
static struct EnuCoor_f * stateGetSpeedEnu_f(void)
Get ground speed in local ENU coordinates (float).
struct FloatVect3 speed_sp
#define GUIDANCE_INDI_POS_GAIN
float leg_progress
progress over leg
struct EnuCoor_f center
center WP position
float leg_length
leg length
struct EnuCoor_f to
end WP position
float dist2_to_wp
squared distance to next waypoint
struct NavCircle_t circle
struct EnuCoor_f from
start WP position
float radians
incremental angular distance
float radius
radius in meters
struct NavBase_t nav_rotorcraft_base
Basic Nav struct.
float nav_max_deceleration_sp
bool force_forward
forward flight for hybrid nav
static void nav_hybrid_circle(struct EnuCoor_f *wp_center, float radius)
#define NAV_HYBRID_MAX_ACCELERATION
static void nav_hybrid_goto(struct EnuCoor_f *wp)
Implement basic nav function for the hybrid case.
#define NAV_HYBRID_SOFT_ACCELERATION
#define NAV_HYBRID_NAV_LINE_DIST
#define NAV_HYBRID_NAV_CIRCLE_DIST
static void nav_hybrid_route(struct EnuCoor_f *wp_start, struct EnuCoor_f *wp_end)
float nav_hybrid_max_bank
float nav_max_acceleration_sp
#define NAV_HYBRID_MAX_EXPECTED_WIND
float nav_hybrid_max_expected_wind
float nav_hybrid_line_gain
float nav_hybrid_pos_gain
static bool nav_hybrid_approaching(struct EnuCoor_f *wp, struct EnuCoor_f *from, float approaching_time)
static float max_speed_for_deceleration(float dist_to_wp)
Calculate max speed when decelerating at MAX capacity a_max distance travelled d = 1/2 a_max t^2 The ...
void nav_rotorcraft_hybrid_init(void)
Init and register nav functions.
#define NAV_HYBRID_MAX_DECELERATION
float nav_hybrid_max_acceleration
float nav_hybrid_soft_acceleration
Specific navigation functions for hybrid aircraft.
struct FloatVect2 pos_diff
vector in East North Up coordinates Units: meters
Paparazzi atmospheric pressure conversion utilities.
struct RotorcraftNavigation nav
void nav_register_circle(navigation_circle nav_circle)
void nav_register_goto_wp(navigation_goto nav_goto, navigation_route nav_route, navigation_approaching nav_approaching)
Registering functions.
float get_dist2_to_point(struct EnuCoor_f *p)
Returns squared horizontal distance to given point.
Rotorcraft navigation functions.
struct EnuCoor_f speed
speed setpoint (in m/s)
#define NAV_HORIZONTAL_MODE_WAYPOINT
Nav modes these modes correspond to the flight plan instructions used to set the high level navigatio...
#define NAV_HORIZONTAL_MODE_CIRCLE
#define NAV_HORIZONTAL_MODE_ROUTE
#define NAV_SETPOINT_MODE_SPEED
#define DEFAULT_CIRCLE_RADIUS
default nav_circle_radius in meters
#define NAV_SETPOINT_MODE_POS
Nav setpoint modes these modes correspond to submodes defined by navigation routines to tell which se...
struct EnuCoor_f target
final target position (in meters)
#define ARRIVED_AT_WAYPOINT
minimum horizontal distance to waypoint to mark as arrived