27 #include "generated/airframe.h"
47 #ifndef GUIDANCE_H_AGAIN
48 #define GUIDANCE_H_AGAIN 0
51 #ifndef GUIDANCE_H_VGAIN
52 #define GUIDANCE_H_VGAIN 0
56 #if (GUIDANCE_H_PGAIN < 0) || \
57 (GUIDANCE_H_DGAIN < 0) || \
58 (GUIDANCE_H_IGAIN < 0) || \
59 (GUIDANCE_H_AGAIN < 0) || \
60 (GUIDANCE_H_VGAIN < 0)
61 #error "ALL control gains have to be positive!!!"
64 #ifndef GUIDANCE_H_MAX_BANK
65 #define GUIDANCE_H_MAX_BANK RadOfDeg(20)
71 #ifndef GUIDANCE_H_APPROX_FORCE_BY_THRUST
72 #define GUIDANCE_H_APPROX_FORCE_BY_THRUST FALSE
76 #define GUIDANCE_INDI FALSE
106 #if PERIODIC_TELEMETRY
112 pprz_msg_send_GUIDANCE_H_INT(trans, dev, AC_ID,
115 &(pos->
x), &(pos->
y));
123 pprz_msg_send_HOVER_LOOP(trans, dev, AC_ID,
126 &(pos->
x), &(pos->
y),
127 &(speed->
x), &(speed->
y),
128 &(accel->
x), &(accel->
y),
142 pprz_msg_send_GUIDANCE_H_REF_INT(trans, dev, AC_ID,
153 pprz_msg_send_ROTORCRAFT_TUNE_HOVER(trans, dev, AC_ID,
184 transition_percentage = 0;
185 transition_theta_offset = 0;
189 #if GUIDANCE_H_MODE_MODULE_SETTING == GUIDANCE_H_MODE_MODULE
193 #if PERIODIC_TELEMETRY
223 transition_percentage = 0;
224 transition_theta_offset = 0;
240 #if NO_ATTITUDE_RESET_ON_MODE_CHANGE
254 #if NO_ATTITUDE_RESET_ON_MODE_CHANGE
263 #if GUIDANCE_H_MODE_MODULE_SETTING == GUIDANCE_H_MODE_MODULE
271 #if NO_ATTITUDE_RESET_ON_MODE_CHANGE
303 #if SWITCH_STICKS_FOR_RATE_CONTROL
320 #if GUIDANCE_H_USE_SPEED_REF
325 #if GUIDANCE_H_MODE_MODULE_SETTING == GUIDANCE_H_MODE_MODULE
424 #if GUIDANCE_H_MODE_MODULE_SETTING == GUIDANCE_H_MODE_MODULE
443 #if GUIDANCE_H_USE_REF
444 #if GUIDANCE_H_USE_SPEED_REF
464 #if GUIDANCE_H_USE_SPEED_REF
472 #define MAX_POS_ERR POS_BFP_OF_REAL(16.)
473 #define MAX_SPEED_ERR SPEED_BFP_OF_REAL(16.)
475 #ifndef GUIDANCE_H_THRUST_CMD_FILTER
476 #define GUIDANCE_H_THRUST_CMD_FILTER 10
481 #define GH_GAIN_SCALE 2
537 static int32_t thrust_cmd_filt;
577 #ifdef TRANSITION_MAX_OFFSET
void guidance_flip_enter(void)
void gh_update_ref_from_pos_sp(struct Int32Vect2 pos_sp)
int32_t psi
in rad with INT32_ANGLE_FRAC
void guidance_indi_enter(void)
void gh_set_ref(struct Int32Vect2 pos, struct Int32Vect2 speed, struct Int32Vect2 accel)
struct Int32Vect2 guidance_h_cmd_earth
horizontal guidance command.
void gh_update_ref_from_speed_sp(struct Int32Vect2 speed_sp)
#define GUIDANCE_H_MODE_RC_DIRECT
void guidance_h_module_run(bool_t in_flight)
void stabilization_rate_run(bool_t in_flight)
struct Int32Eulers rc_sp
with INT32_ANGLE_FRAC
Generic transmission transport header.
Rotorcraft navigation functions.
#define GUIDANCE_H_MODE_MODULE
#define GUIDANCE_H_MODE_CARE_FREE
void guidance_h_set_igain(uint32_t igain)
#define INT32_PERCENTAGE_FRAC
Dummy stabilization for rotorcrafts.
Periodic telemetry system header (includes downlink utility and generated code).
General attitude stabilization interface for rotorcrafts.
struct GuidanceHRef gh_ref
void stabilization_rate_enter(void)
int32_t theta
in rad with INT32_ANGLE_FRAC
#define VECT2_STRIM(_v, _min, _max)
#define POS_BFP_OF_REAL(_af)
bool_t approx_force_by_thrust
Open Loop guidance for making a flip.
void guidance_indi_run(bool_t in_flight, int32_t heading)
Read an attitude setpoint from the RC.
#define GUIDANCE_H_MODE_ATTITUDE
#define VECT2_COPY(_a, _b)
Vertical guidance for rotorcrafts.
#define VECT2_DIFF(_c, _a, _b)
static void transition_run(void)
struct HorizontalGuidanceReference ref
reference calculated from setpoints
void stabilization_attitude_enter(void)
static void reset_guidance_reference_from_current_position(void)
int32_t transition_percentage
void stabilization_attitude_read_rc_setpoint_eulers(struct Int32Eulers *sp, bool_t in_flight, bool_t in_carefree, bool_t coordinated_turn)
Read attitude setpoint from RC as euler angles.
void stabilization_attitude_reset_care_free_heading(void)
reset the heading for care-free mode to current heading
struct HorizontalGuidance guidance_h
pprz_t values[RADIO_CONTROL_NB_CHANNEL]
#define GUIDANCE_H_REF_MAX_SPEED
Default speed saturation.
struct HorizontalGuidanceSetpoint sp
setpoints
struct EnuCoor_i navigation_carrot
struct Int32Vect2 accel
with INT32_ACCEL_FRAC
struct Int64Vect2 pos
Reference model position.
static void guidance_h_traj_run(bool_t in_flight)
#define GUIDANCE_H_USE_SPEED_REF
Use horizontal guidance speed reference.
Rate stabilization for rotorcrafts.
static void guidance_h_nav_enter(void)
bool_t guidance_h_set_guided_heading(float heading)
Set heading setpoint in GUIDED mode.
#define BFP_OF_REAL(_vr, _frac)
void stabilization_none_enter(void)
#define PPRZ_ITRIG_SIN(_s, _a)
void guidance_h_module_enter(void)
static struct NedCoor_i * stateGetSpeedNed_i(void)
Get ground speed in local NED coordinates (int).
#define GUIDANCE_H_MODE_HOVER
struct Int32Vect2 guidance_h_speed_err
void guidance_h_read_rc(bool_t in_flight)
void stabilization_attitude_run(bool_t in_flight)
void stabilization_rate_read_rc(void)
static void read_rc_setpoint_speed_i(struct Int32Vect2 *speed_sp, bool_t in_flight)
read speed setpoint from RC
void guidance_h_module_read_rc(void)
struct Int32Vect2 speed
with INT32_SPEED_FRAC
#define GUIDANCE_H_APPROX_FORCE_BY_THRUST
void stabilization_rate_read_rc_switched_sticks(void)
void stabilization_attitude_read_rc(bool_t in_flight, bool_t in_carefree, bool_t coordinated_turn)
void stabilization_attitude_set_rpy_setpoint_i(struct Int32Eulers *rpy)
#define INT32_VECT2_NED_OF_ENU(_o, _i)
#define INT32_ANGLE_NORMALIZE(_a)
void stabilization_attitude_set_earth_cmd_i(struct Int32Vect2 *cmd, int32_t heading)
#define DefaultPeriodic
Set default periodic telemetry.
void guidance_h_run(bool_t in_flight)
void stabilization_none_read_rc(void)
struct RadioControl radio_control
#define GH_SPEED_REF_FRAC
#define GUIDANCE_H_MODE_NAV
#define GUIDANCE_H_MAX_BANK
#define GUIDANCE_H_MODE_KILL
bool_t guidance_h_set_guided_pos(float x, float y)
Set horizontal position setpoint in GUIDED mode.
void guidance_h_module_init(void)
#define ANGLE_BFP_OF_REAL(_af)
static const struct usb_device_descriptor dev
#define GH_ACCEL_REF_FRAC
int32_t heading
with INT32_ANGLE_FRAC
int32_t phi
in rad with INT32_ANGLE_FRAC
#define INT_EULERS_ZERO(_e)
API to get/set the generic vehicle states.
struct HorizontalGuidanceGains gains
vector in North East Down coordinates
struct Int32Vect2 speed
Reference model speed.
#define INT_MULT_RSHIFT(_a, _b, _r)
float nav_pitch
with INT32_ANGLE_FRAC
int32_t guidance_v_thrust_coeff
static void guidance_h_update_reference(void)
void guidance_h_mode_changed(uint8_t new_mode)
int32_t transition_theta_offset
General stabilization interface for rotorcrafts.
Horizontal guidance for rotorcrafts.
void guidance_flip_run(void)
#define GUIDANCE_H_THRUST_CMD_FILTER
struct Int32Vect2 pos
with INT32_POS_FRAC
int32_t stabilization_cmd[COMMANDS_NB]
Stabilization commands.
void stabilization_none_run(bool_t in_flight)
#define HORIZONTAL_MODE_ATTITUDE
#define INT_VECT2_ZERO(_v)
Guidance in a module file.
struct Int32Vect2 accel
Reference model acceleration.
#define SPEED_BFP_OF_REAL(_af)
struct Int32Vect2 guidance_h_pos_err
static struct NedCoor_i * stateGetPositionNed_i(void)
Get position in local NED coordinates (int).
#define INT32_VECT2_RSHIFT(_o, _i, _r)
#define INT32_VECT2_LSHIFT(_o, _i, _l)
#define GUIDANCE_H_MODE_FORWARD
static struct Int32Eulers * stateGetNedToBodyEulers_i(void)
Get vehicle body attitude euler angles (int).
int32_t nav_heading
with INT32_ANGLE_FRAC
#define GUIDANCE_H_USE_REF
Use horizontal guidance reference trajectory.
#define GUIDANCE_H_MODE_RATE
#define GUIDANCE_H_MODE_FLIP
struct Int32Vect2 speed
only used if GUIDANCE_H_USE_SPEED_REF
static void guidance_h_hover_enter(void)
void guidance_h_init(void)
A guidance mode based on Incremental Nonlinear Dynamic Inversion Come to ICRA2016 to learn more! ...
int8_t register_periodic_telemetry(struct periodic_telemetry *_pt, uint8_t _id, telemetry_cb _cb)
Register a telemetry callback function.
struct Int32Vect2 guidance_h_trim_att_integrator
static struct NedCoor_i * stateGetAccelNed_i(void)
Get acceleration in NED coordinates (int).
struct Int32Vect2 pos
horizontal position setpoint in NED.
#define PPRZ_ITRIG_COS(_c, _a)
#define GUIDANCE_H_MODE_GUIDED