Paparazzi UAS  v7.0_unstable
Paparazzi is a free software Unmanned Aircraft System.
guidance_indi_hybrid.c File Reference

A guidance mode based on Incremental Nonlinear Dynamic Inversion Come to IROS2016 to learn more! More...

+ Include dependency graph for guidance_indi_hybrid.c:

Go to the source code of this file.

Macros

#define GUIDANCE_INDI_SPEED_GAIN   1.8
 
#define GUIDANCE_INDI_SPEED_GAINZ   1.8
 
#define GUIDANCE_INDI_POS_GAIN   0.5
 
#define GUIDANCE_INDI_POS_GAINZ   0.5
 
#define GUIDANCE_INDI_LIFTD_ASQ   0.20
 
#define GUIDANCE_INDI_MAX_PUSHER_INCREMENT   MAX_PPRZ
 
#define GUIDANCE_INDI_LIFTD_P80   (GUIDANCE_INDI_LIFTD_ASQ*12*12)
 
#define GUIDANCE_INDI_LIFTD_P50   (GUIDANCE_INDI_LIFTD_P80/2)
 
#define GUIDANCE_INDI_MIN_AIRSPEED   -10.f
 
#define GUIDANCE_INDI_FWD_CLIMB_SPEED   4.0
 Climb speed when navigation is making turns instead of direct lines. More...
 
#define GUIDANCE_INDI_FWD_DESCEND_SPEED   -4.0
 Descend speed when navigation is making turns instead of direct lines. More...
 
#define GUIDANCE_INDI_QUAD_CLIMB_SPEED   2.0
 Climb speed when navigation is doing direct lines. More...
 
#define GUIDANCE_INDI_QUAD_DESCEND_SPEED   -2.0
 Descend speed when navigation is doing direct lines. More...
 
#define GUIDANCE_INDI_ZERO_AIRSPEED   FALSE
 
#define TURN_AIRSPEED_TH   13.0
 
#define GUIDANCE_INDI_FILTER_CUTOFF   3.0
 
#define GUIDANCE_INDI_AIRSPEED_FILT_CUTOFF   0.5
 
#define GUIDANCE_INDI_MAX_LAT_ACCEL   9.81
 
#define GUIDANCE_INDI_COORDINATED_TURN_MIN_AIRSPEED   10.0
 
#define GUIDANCE_INDI_COORDINATED_TURN_MAX_AIRSPEED   30.0
 
#define GUIDANCE_INDI_COORDINATED_TURN_AIRSPEED_MARGIN   0.0
 
#define GUIDANCE_INDI_VEL_SP_ID   ABI_BROADCAST
 

Functions

static void vel_sp_cb (uint8_t sender_id, struct FloatVect3 *vel_sp)
 ABI callback that obtains the velocity setpoint from a module. More...
 
void guidance_indi_propagate_filters (void)
 Low pass the accelerometer measurements to remove noise from vibrations. More...
 
static void send_eff_mat_guid_indi_hybrid (struct transport_tx *trans, struct link_device *dev)
 
static void send_guidance_indi_hybrid (struct transport_tx *trans, struct link_device *dev)
 
void guidance_indi_init (void)
 Init function. More...
 
void guidance_indi_enter (void)
 Call upon entering indi guidance. More...
 
void guidance_set_min_max_airspeed (float min_airspeed, float max_airspeed)
 
struct StabilizationSetpoint guidance_indi_run (struct FloatVect3 *accel_sp, float heading_sp)
 
static struct FloatVect3 compute_accel_from_speed_sp (void)
 
static float bound_vz_sp (float vz_sp)
 
struct StabilizationSetpoint guidance_indi_run_mode (bool in_flight UNUSED, struct HorizontalGuidance *gh, struct VerticalGuidance *gv, enum GuidanceIndiHybrid_HMode h_mode, enum GuidanceIndiHybrid_VMode v_mode)
 
float WEAK guidance_indi_get_liftd (float airspeed, float theta)
 Get the derivative of lift w.r.t. More...
 

Variables

struct guidance_indi_hybrid_params gih_params
 
float guidance_indi_pitch_pref_deg = 0
 
bool take_heading_control = false
 
bool force_forward = false
 forward flight for hybrid nav More...
 
bool guidance_indi_airspeed_filtering = false
 
struct FloatVect3 sp_accel = {0.0,0.0,0.0}
 
float inv_eff [4]
 
float guidance_indi_max_bank = GUIDANCE_H_MAX_BANK
 
float guidance_indi_min_pitch = GUIDANCE_INDI_MIN_PITCH
 
float gih_coordinated_turn_min_airspeed = GUIDANCE_INDI_COORDINATED_TURN_MIN_AIRSPEED
 
float gih_coordinated_turn_max_airspeed = GUIDANCE_INDI_COORDINATED_TURN_MAX_AIRSPEED + GUIDANCE_INDI_COORDINATED_TURN_AIRSPEED_MARGIN
 
bool coordinated_turn_use_accel = false
 
struct FloatEulers eulers_zxy
 state eulers in zxy order More...
 
float thrust_dyn = 0.f
 
float thrust_act = 0.f
 
Butterworth2LowPass filt_accel_ned [3]
 
Butterworth2LowPass roll_filt
 
Butterworth2LowPass pitch_filt
 
Butterworth2LowPass thrust_filt
 
Butterworth2LowPass accely_filt
 
Butterworth2LowPass guidance_indi_airspeed_filt
 
struct FloatVect2 desired_airspeed
 
float gi_unbounded_airspeed_sp = 0.f
 
float Ga [GUIDANCE_INDI_HYBRID_V][GUIDANCE_INDI_HYBRID_U]
 
struct FloatVect3 euler_cmd
 
float du_gih [GUIDANCE_INDI_HYBRID_U]
 
float v_gih [3]
 
float filter_cutoff = GUIDANCE_INDI_FILTER_CUTOFF
 
float guidance_indi_airspeed_filt_cutoff = GUIDANCE_INDI_AIRSPEED_FILT_CUTOFF
 
float guidance_indi_hybrid_heading_sp = 0.f
 
struct FloatEulers guidance_euler_cmd
 
struct ThrustSetpoint thrust_sp
 
float thrust_in
 
struct FloatVect3 gi_speed_sp = {0.0, 0.0, 0.0}
 
abi_event vel_sp_ev
 
struct FloatVect3 indi_vel_sp = {0.0, 0.0, 0.0}
 
float time_of_vel_sp = 0.0
 

Detailed Description

A guidance mode based on Incremental Nonlinear Dynamic Inversion Come to IROS2016 to learn more!

Definition in file guidance_indi_hybrid.c.

Macro Definition Documentation

◆ GUIDANCE_INDI_AIRSPEED_FILT_CUTOFF

#define GUIDANCE_INDI_AIRSPEED_FILT_CUTOFF   0.5

Definition at line 196 of file guidance_indi_hybrid.c.

◆ GUIDANCE_INDI_COORDINATED_TURN_AIRSPEED_MARGIN

#define GUIDANCE_INDI_COORDINATED_TURN_AIRSPEED_MARGIN   0.0

Definition at line 212 of file guidance_indi_hybrid.c.

◆ GUIDANCE_INDI_COORDINATED_TURN_MAX_AIRSPEED

#define GUIDANCE_INDI_COORDINATED_TURN_MAX_AIRSPEED   30.0

Definition at line 208 of file guidance_indi_hybrid.c.

◆ GUIDANCE_INDI_COORDINATED_TURN_MIN_AIRSPEED

#define GUIDANCE_INDI_COORDINATED_TURN_MIN_AIRSPEED   10.0

Definition at line 204 of file guidance_indi_hybrid.c.

◆ GUIDANCE_INDI_FILTER_CUTOFF

#define GUIDANCE_INDI_FILTER_CUTOFF   3.0

Definition at line 191 of file guidance_indi_hybrid.c.

◆ GUIDANCE_INDI_FWD_CLIMB_SPEED

#define GUIDANCE_INDI_FWD_CLIMB_SPEED   4.0

Climb speed when navigation is making turns instead of direct lines.

Definition at line 86 of file guidance_indi_hybrid.c.

◆ GUIDANCE_INDI_FWD_DESCEND_SPEED

#define GUIDANCE_INDI_FWD_DESCEND_SPEED   -4.0

Descend speed when navigation is making turns instead of direct lines.

Definition at line 93 of file guidance_indi_hybrid.c.

◆ GUIDANCE_INDI_LIFTD_ASQ

#define GUIDANCE_INDI_LIFTD_ASQ   0.20

Definition at line 58 of file guidance_indi_hybrid.c.

◆ GUIDANCE_INDI_LIFTD_P50

#define GUIDANCE_INDI_LIFTD_P50   (GUIDANCE_INDI_LIFTD_P80/2)

Definition at line 71 of file guidance_indi_hybrid.c.

◆ GUIDANCE_INDI_LIFTD_P80

#define GUIDANCE_INDI_LIFTD_P80   (GUIDANCE_INDI_LIFTD_ASQ*12*12)

Definition at line 70 of file guidance_indi_hybrid.c.

◆ GUIDANCE_INDI_MAX_LAT_ACCEL

#define GUIDANCE_INDI_MAX_LAT_ACCEL   9.81

Definition at line 200 of file guidance_indi_hybrid.c.

◆ GUIDANCE_INDI_MAX_PUSHER_INCREMENT

#define GUIDANCE_INDI_MAX_PUSHER_INCREMENT   MAX_PPRZ

Definition at line 62 of file guidance_indi_hybrid.c.

◆ GUIDANCE_INDI_MIN_AIRSPEED

#define GUIDANCE_INDI_MIN_AIRSPEED   -10.f

Definition at line 79 of file guidance_indi_hybrid.c.

◆ GUIDANCE_INDI_POS_GAIN

#define GUIDANCE_INDI_POS_GAIN   0.5

Definition at line 53 of file guidance_indi_hybrid.c.

◆ GUIDANCE_INDI_POS_GAINZ

#define GUIDANCE_INDI_POS_GAINZ   0.5

Definition at line 54 of file guidance_indi_hybrid.c.

◆ GUIDANCE_INDI_QUAD_CLIMB_SPEED

#define GUIDANCE_INDI_QUAD_CLIMB_SPEED   2.0

Climb speed when navigation is doing direct lines.

Definition at line 100 of file guidance_indi_hybrid.c.

◆ GUIDANCE_INDI_QUAD_DESCEND_SPEED

#define GUIDANCE_INDI_QUAD_DESCEND_SPEED   -2.0

Descend speed when navigation is doing direct lines.

Definition at line 107 of file guidance_indi_hybrid.c.

◆ GUIDANCE_INDI_SPEED_GAIN

#define GUIDANCE_INDI_SPEED_GAIN   1.8

Definition at line 48 of file guidance_indi_hybrid.c.

◆ GUIDANCE_INDI_SPEED_GAINZ

#define GUIDANCE_INDI_SPEED_GAINZ   1.8

Definition at line 49 of file guidance_indi_hybrid.c.

◆ GUIDANCE_INDI_VEL_SP_ID

#define GUIDANCE_INDI_VEL_SP_ID   ABI_BROADCAST

Definition at line 292 of file guidance_indi_hybrid.c.

◆ GUIDANCE_INDI_ZERO_AIRSPEED

#define GUIDANCE_INDI_ZERO_AIRSPEED   FALSE

Definition at line 149 of file guidance_indi_hybrid.c.

◆ TURN_AIRSPEED_TH

#define TURN_AIRSPEED_TH   13.0

Definition at line 154 of file guidance_indi_hybrid.c.

Function Documentation

◆ bound_vz_sp()

◆ compute_accel_from_speed_sp()

static struct FloatVect3 compute_accel_from_speed_sp ( void  )
static

◆ guidance_indi_enter()

◆ guidance_indi_get_liftd()

float WEAK guidance_indi_get_liftd ( float  airspeed,
float  theta 
)

Get the derivative of lift w.r.t.

pitch.

Parameters
airspeedThe airspeed says most about the flight condition
Returns
The derivative of lift w.r.t. pitch

Definition at line 883 of file guidance_indi_hybrid.c.

References gih_params, guidance_indi_hybrid_params::liftd_asq, guidance_indi_hybrid_params::liftd_p50, and guidance_indi_hybrid_params::liftd_p80.

Referenced by guidance_indi_calcg_wing().

+ Here is the caller graph for this function:

◆ guidance_indi_init()

◆ guidance_indi_propagate_filters()

void guidance_indi_propagate_filters ( void  )

Low pass the accelerometer measurements to remove noise from vibrations.

The roll and pitch also need to be filtered to synchronize them with the acceleration Called as a periodic function with PERIODIC_FREQ

Definition at line 856 of file guidance_indi_hybrid.c.

References ACCEL_FLOAT_OF_BFP, accely_filt, eulers_zxy, filt_accel_ned, guidance_indi_airspeed_filt, FloatEulers::phi, pitch_filt, roll_filt, stateGetAccelBody_i(), stateGetAccelNed_f(), stateGetAirspeed_f(), FloatEulers::theta, update_butterworth_2_low_pass(), NedCoor_f::x, NedCoor_f::y, and NedCoor_f::z.

+ Here is the call graph for this function:

◆ guidance_indi_run()

struct StabilizationSetpoint guidance_indi_run ( struct FloatVect3 accel_sp,
float  heading_sp 
)
Parameters
accel_spaccel setpoint in NED frame [m/s^2]
heading_spthe desired heading [rad]
Returns
stabilization setpoint structure

main indi guidance function

Definition at line 414 of file guidance_indi_hybrid.c.

◆ guidance_indi_run_mode()

struct StabilizationSetpoint guidance_indi_run_mode ( bool in_flight  UNUSED,
struct HorizontalGuidance gh,
struct VerticalGuidance gv,
enum GuidanceIndiHybrid_HMode  h_mode,
enum GuidanceIndiHybrid_VMode  v_mode 
)

Definition at line 749 of file guidance_indi_hybrid.c.

◆ guidance_set_min_max_airspeed()

void guidance_set_min_max_airspeed ( float  min_airspeed,
float  max_airspeed 
)

Definition at line 414 of file guidance_indi_hybrid.c.

Referenced by rotwing_state_periodic().

+ Here is the caller graph for this function:

◆ send_eff_mat_guid_indi_hybrid()

static void send_eff_mat_guid_indi_hybrid ( struct transport_tx *  trans,
struct link_device *  dev 
)
static

Definition at line 303 of file guidance_indi_hybrid.c.

References dev, and Ga.

Referenced by guidance_indi_init().

+ Here is the caller graph for this function:

◆ send_guidance_indi_hybrid()

static void send_guidance_indi_hybrid ( struct transport_tx *  trans,
struct link_device *  dev 
)
static

Definition at line 310 of file guidance_indi_hybrid.c.

References dev, euler_cmd, filt_accel_ned, gi_speed_sp, SecondOrderLowPass::o, sp_accel, FloatVect3::x, FloatVect3::y, and FloatVect3::z.

Referenced by guidance_indi_init().

+ Here is the caller graph for this function:

◆ vel_sp_cb()

static void vel_sp_cb ( uint8_t  sender_id,
struct FloatVect3 vel_sp 
)
static

ABI callback that obtains the velocity setpoint from a module.

Definition at line 915 of file guidance_indi_hybrid.c.

References get_sys_time_float(), indi_vel_sp, time_of_vel_sp, FloatVect3::x, FloatVect3::y, and FloatVect3::z.

Referenced by guidance_indi_init().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Variable Documentation

◆ accely_filt

◆ coordinated_turn_use_accel

bool coordinated_turn_use_accel = false

Definition at line 229 of file guidance_indi_hybrid.c.

◆ desired_airspeed

struct FloatVect2 desired_airspeed

Definition at line 241 of file guidance_indi_hybrid.c.

◆ du_gih

float du_gih[GUIDANCE_INDI_HYBRID_U]

Definition at line 249 of file guidance_indi_hybrid.c.

◆ euler_cmd

struct FloatVect3 euler_cmd

Definition at line 246 of file guidance_indi_hybrid.c.

Referenced by send_guidance_indi_hybrid().

◆ eulers_zxy

◆ filt_accel_ned

◆ filter_cutoff

float filter_cutoff = GUIDANCE_INDI_FILTER_CUTOFF

Definition at line 281 of file guidance_indi_hybrid.c.

Referenced by guidance_indi_enter(), and guidance_indi_init().

◆ force_forward

bool force_forward = false

forward flight for hybrid nav

Definition at line 160 of file guidance_indi_hybrid.c.

Referenced by reshape_wind().

◆ Ga

float Ga[GUIDANCE_INDI_HYBRID_V][GUIDANCE_INDI_HYBRID_U]

Definition at line 246 of file guidance_indi_hybrid.c.

Referenced by guidance_indi_init(), and send_eff_mat_guid_indi_hybrid().

◆ gi_speed_sp

struct FloatVect3 gi_speed_sp = {0.0, 0.0, 0.0}

Definition at line 287 of file guidance_indi_hybrid.c.

Referenced by send_guidance_indi_hybrid().

◆ gi_unbounded_airspeed_sp

float gi_unbounded_airspeed_sp = 0.f

Definition at line 244 of file guidance_indi_hybrid.c.

Referenced by rotwing_state_periodic(), and send_rotating_wing_state().

◆ gih_coordinated_turn_max_airspeed

Definition at line 226 of file guidance_indi_hybrid.c.

◆ gih_coordinated_turn_min_airspeed

float gih_coordinated_turn_min_airspeed = GUIDANCE_INDI_COORDINATED_TURN_MIN_AIRSPEED

Definition at line 225 of file guidance_indi_hybrid.c.

◆ gih_params

struct guidance_indi_hybrid_params gih_params
Initial value:
= {
.speed_gain = GUIDANCE_INDI_SPEED_GAIN,
.speed_gainz = GUIDANCE_INDI_SPEED_GAINZ,
.heading_bank_gain = GUIDANCE_INDI_HEADING_BANK_GAIN,
.liftd_asq = GUIDANCE_INDI_LIFTD_ASQ,
.min_airspeed = GUIDANCE_INDI_MIN_AIRSPEED,
.max_airspeed = GUIDANCE_INDI_MAX_AIRSPEED,
.stall_protect_gain = 1.5,
.climb_vspeed_fwd = GUIDANCE_INDI_FWD_CLIMB_SPEED,
.descend_vspeed_fwd = GUIDANCE_INDI_FWD_DESCEND_SPEED,
.climb_vspeed_quad = GUIDANCE_INDI_QUAD_CLIMB_SPEED,
.descend_vspeed_quad = GUIDANCE_INDI_QUAD_DESCEND_SPEED,
}
#define GUIDANCE_INDI_QUAD_DESCEND_SPEED
Descend speed when navigation is doing direct lines.
#define GUIDANCE_INDI_SPEED_GAINZ
#define GUIDANCE_INDI_MIN_AIRSPEED
#define GUIDANCE_INDI_FWD_DESCEND_SPEED
Descend speed when navigation is making turns instead of direct lines.
#define GUIDANCE_INDI_LIFTD_ASQ
#define GUIDANCE_INDI_QUAD_CLIMB_SPEED
Climb speed when navigation is doing direct lines.
#define GUIDANCE_INDI_POS_GAIN
#define GUIDANCE_INDI_FWD_CLIMB_SPEED
Climb speed when navigation is making turns instead of direct lines.
#define GUIDANCE_INDI_LIFTD_P50
#define GUIDANCE_INDI_POS_GAINZ
#define GUIDANCE_INDI_LIFTD_P80
#define GUIDANCE_INDI_SPEED_GAIN

Definition at line 1 of file guidance_indi_hybrid.c.

Referenced by bound_vz_sp(), compute_accel_from_speed_sp(), and guidance_indi_get_liftd().

◆ guidance_euler_cmd

struct FloatEulers guidance_euler_cmd

Definition at line 284 of file guidance_indi_hybrid.c.

◆ guidance_indi_airspeed_filt

Butterworth2LowPass guidance_indi_airspeed_filt

◆ guidance_indi_airspeed_filt_cutoff

float guidance_indi_airspeed_filt_cutoff = GUIDANCE_INDI_AIRSPEED_FILT_CUTOFF

Definition at line 282 of file guidance_indi_hybrid.c.

Referenced by guidance_indi_enter(), and guidance_indi_init().

◆ guidance_indi_airspeed_filtering

bool guidance_indi_airspeed_filtering = false

Definition at line 162 of file guidance_indi_hybrid.c.

◆ guidance_indi_hybrid_heading_sp

float guidance_indi_hybrid_heading_sp = 0.f

Definition at line 284 of file guidance_indi_hybrid.c.

Referenced by guidance_indi_enter().

◆ guidance_indi_max_bank

float guidance_indi_max_bank = GUIDANCE_H_MAX_BANK

Definition at line 218 of file guidance_indi_hybrid.c.

◆ guidance_indi_min_pitch

float guidance_indi_min_pitch = GUIDANCE_INDI_MIN_PITCH

Definition at line 219 of file guidance_indi_hybrid.c.

◆ guidance_indi_pitch_pref_deg

float guidance_indi_pitch_pref_deg = 0

Definition at line 131 of file guidance_indi_hybrid.c.

Referenced by guidance_indi_hybrid_set_wls_settings().

◆ indi_vel_sp

struct FloatVect3 indi_vel_sp = {0.0, 0.0, 0.0}

Definition at line 295 of file guidance_indi_hybrid.c.

Referenced by vel_sp_cb().

◆ inv_eff

float inv_eff[4]

Definition at line 215 of file guidance_indi_hybrid.c.

◆ pitch_filt

◆ roll_filt

◆ sp_accel

struct FloatVect3 sp_accel = {0.0,0.0,0.0}

Definition at line 162 of file guidance_indi_hybrid.c.

Referenced by send_guidance_indi_hybrid().

◆ take_heading_control

bool take_heading_control = false

Definition at line 158 of file guidance_indi_hybrid.c.

◆ thrust_act

float thrust_act = 0.f

Definition at line 235 of file guidance_indi_hybrid.c.

Referenced by guidance_indi_enter().

◆ thrust_dyn

float thrust_dyn = 0.f

Definition at line 234 of file guidance_indi_hybrid.c.

Referenced by guidance_indi_init().

◆ thrust_filt

Butterworth2LowPass thrust_filt

Definition at line 239 of file guidance_indi_hybrid.c.

Referenced by guidance_indi_enter(), and guidance_indi_init().

◆ thrust_in

float thrust_in

Definition at line 287 of file guidance_indi_hybrid.c.

Referenced by guidance_indi_enter().

◆ thrust_sp

struct ThrustSetpoint thrust_sp

Definition at line 284 of file guidance_indi_hybrid.c.

◆ time_of_vel_sp

float time_of_vel_sp = 0.0

Definition at line 297 of file guidance_indi_hybrid.c.

Referenced by vel_sp_cb().

◆ v_gih

float v_gih[3]

Definition at line 278 of file guidance_indi_hybrid.c.

Referenced by guidance_indi_calcg_wing().

◆ vel_sp_ev

abi_event vel_sp_ev

Definition at line 294 of file guidance_indi_hybrid.c.

Referenced by guidance_indi_init().