 |
Paparazzi UAS
v5.18.0_stable
Paparazzi is a free software Unmanned Aircraft System.
|
Go to the documentation of this file.
27 #include "generated/airframe.h"
37 #if GUIDANCE_INDI_HYBRID
52 #ifndef GUIDANCE_H_AGAIN
53 #define GUIDANCE_H_AGAIN 0
56 #ifndef GUIDANCE_H_VGAIN
57 #define GUIDANCE_H_VGAIN 0
61 #if (GUIDANCE_H_PGAIN < 0) || \
62 (GUIDANCE_H_DGAIN < 0) || \
63 (GUIDANCE_H_IGAIN < 0) || \
64 (GUIDANCE_H_AGAIN < 0) || \
65 (GUIDANCE_H_VGAIN < 0)
66 #error "ALL control gains have to be positive!!!"
69 #ifndef GUIDANCE_H_MAX_BANK
70 #define GUIDANCE_H_MAX_BANK RadOfDeg(20)
76 #ifndef GUIDANCE_H_APPROX_FORCE_BY_THRUST
77 #define GUIDANCE_H_APPROX_FORCE_BY_THRUST FALSE
81 #define GUIDANCE_INDI FALSE
86 #ifndef GUIDANCE_HEADING_IS_FREE
87 #define GUIDANCE_HEADING_IS_FREE TRUE
114 #if PERIODIC_TELEMETRY
117 static void send_gh(
struct transport_tx *trans,
struct link_device *
dev)
120 pprz_msg_send_GUIDANCE_H_INT(trans,
dev, AC_ID,
123 &(pos->
x), &(pos->
y));
131 pprz_msg_send_HOVER_LOOP(trans,
dev, AC_ID,
134 &(pos->
x), &(pos->
y),
135 &(speed->
x), &(speed->
y),
136 &(accel->
x), &(accel->
y),
148 static void send_href(
struct transport_tx *trans,
struct link_device *
dev)
150 pprz_msg_send_GUIDANCE_H_REF_INT(trans,
dev, AC_ID,
161 pprz_msg_send_ROTORCRAFT_TUNE_HOVER(trans,
dev, AC_ID,
198 #if GUIDANCE_H_MODE_MODULE_SETTING == GUIDANCE_H_MODE_MODULE
202 #if PERIODIC_TELEMETRY
228 #if HYBRID_NAVIGATION
237 #if USE_STABILIZATION_RATE
248 #if NO_ATTITUDE_RESET_ON_MODE_CHANGE
263 #if NO_ATTITUDE_RESET_ON_MODE_CHANGE
272 #if GUIDANCE_H_MODE_MODULE_SETTING == GUIDANCE_H_MODE_MODULE
280 #if NO_ATTITUDE_RESET_ON_MODE_CHANGE
311 #if USE_STABILIZATION_RATE
313 #if SWITCH_STICKS_FOR_RATE_CONTROL
332 #if GUIDANCE_H_USE_SPEED_REF
339 #if GUIDANCE_H_MODE_MODULE_SETTING == GUIDANCE_H_MODE_MODULE
369 #if USE_STABILIZATION_RATE
386 #if (STABILIZATION_FILTER_CMD_ROLL_PITCH || STABILIZATION_FILTER_CMD_YAW)
408 #if GUIDANCE_H_MODE_MODULE_SETTING == GUIDANCE_H_MODE_MODULE
427 #if GUIDANCE_H_USE_REF
447 #if GUIDANCE_H_USE_SPEED_REF
460 #define MAX_POS_ERR POS_BFP_OF_REAL(16.)
461 #define MAX_SPEED_ERR SPEED_BFP_OF_REAL(16.)
463 #ifndef GUIDANCE_H_THRUST_CMD_FILTER
464 #define GUIDANCE_H_THRUST_CMD_FILTER 10
469 #define GH_GAIN_SCALE 2
528 static int32_t thrust_cmd_filt;
597 #if HYBRID_NAVIGATION
603 #if HYBRID_NAVIGATION
611 #if GUIDANCE_HEADING_IS_FREE
643 #ifdef TRANSITION_MAX_OFFSET
734 float newvx = cosf(-
psi) * vx + sinf(-
psi) * vy;
735 float newvy = -sinf(-
psi) * vx + cosf(-
psi) * vy;
struct FloatVect3 speed_sp
int32_t theta
in rad with INT32_ANGLE_FRAC
int32_t guidance_hybrid_norm_ref_airspeed
struct HorizontalGuidanceReference ref
reference calculated from setpoints
#define INT32_VECT2_NED_OF_ENU(_o, _i)
#define GUIDANCE_H_USE_SPEED_REF
Use horizontal guidance speed reference.
#define ANGLE_FLOAT_OF_BFP(_ai)
int32_t transition_theta_offset
void stabilization_attitude_read_rc(bool in_flight, bool in_carefree, bool coordinated_turn)
#define FLOAT_ANGLE_NORMALIZE(_a)
uint8_t mask
bit 5: vx & vy, bit 6: vz, bit 7: vyaw
void guidance_hybrid_reset_heading(struct Int32Eulers *sp_cmd)
Description.
struct GuidanceHRef gh_ref
void stabilization_rate_read_rc(void)
#define GUIDANCE_H_MAX_BANK
void guidance_h_module_run(bool in_flight)
struct Int32Vect2 guidance_h_cmd_earth
horizontal guidance command.
#define GUIDANCE_H_MODE_ATTITUDE
void guidance_h_mode_changed(uint8_t new_mode)
void guidance_h_module_read_rc(void)
void stabilization_filter_commands(void)
static void guidance_h_update_reference(void)
#define GUIDANCE_H_MODE_GUIDED
#define SPEED_BFP_OF_REAL(_af)
static struct FloatEulers * stateGetNedToBodyEulers_f(void)
Get vehicle body attitude euler angles (float).
#define GH_ACCEL_REF_FRAC
struct Int32Vect2 pos
horizontal position setpoint in NED.
#define GUIDANCE_H_MODE_MODULE
#define GUIDANCE_H_MODE_RC_DIRECT
struct Int32Vect2 accel
with INT32_ACCEL_FRAC
#define PPRZ_ITRIG_COS(_c, _a)
#define FLOAT_EULERS_ZERO(_e)
struct EnuCoor_i navigation_target
struct EnuCoor_i navigation_carrot
void guidance_h_set_igain(uint32_t igain)
static struct NedCoor_i * stateGetPositionNed_i(void)
Get position in local NED coordinates (int).
struct Int32Vect2 speed
Reference model speed.
bool guidance_h_set_guided_pos(float x, float y)
Set horizontal position setpoint in GUIDED mode.
int32_t nav_heading
with INT32_ANGLE_FRAC
struct Int32Vect2 speed
with INT32_SPEED_FRAC
#define GUIDANCE_H_MODE_FLIP
#define INT_VECT2_ZERO(_v)
#define HORIZONTAL_MODE_MANUAL
struct Int32Vect2 guidance_h_pos_err
void stabilization_attitude_read_rc_setpoint_eulers_f(struct FloatEulers *sp, bool in_flight, bool in_carefree, bool coordinated_turn)
#define VECT2_DIFF(_c, _a, _b)
void gh_update_ref_from_speed_sp(struct Int32Vect2 speed_sp)
#define VECT2_COPY(_a, _b)
#define VECT2_STRIM(_v, _min, _max)
static void guidance_h_traj_run(bool in_flight)
static void reset_guidance_reference_from_current_position(void)
#define GUIDANCE_H_APPROX_FORCE_BY_THRUST
int32_t psi
in rad with INT32_ANGLE_FRAC
int32_t phi
in rad with INT32_ANGLE_FRAC
struct Int32Vect2 speed
only used in HOVER mode if GUIDANCE_H_USE_SPEED_REF or in GUIDED mode
#define GUIDANCE_H_MODE_HOVER
#define GH_SPEED_REF_FRAC
void gh_update_ref_from_pos_sp(struct Int32Vect2 pos_sp)
static struct NedCoor_i * stateGetSpeedNed_i(void)
Get ground speed in local NED coordinates (int).
void guidance_h_run(bool in_flight)
bool guidance_h_set_guided_body_vel(float vx, float vy)
Set body relative horizontal velocity setpoint in GUIDED mode.
#define GUIDANCE_H_MODE_FORWARD
#define ANGLE_BFP_OF_REAL(_af)
vector in North East Down coordinates
static const struct usb_device_descriptor dev
static void send_hover_loop(struct transport_tx *trans, struct link_device *dev)
struct Int32Vect2 guidance_h_trim_att_integrator
void guidance_indi_enter(void)
Call upon entering indi guidance.
void guidance_flip_run(void)
#define INT_MULT_RSHIFT(_a, _b, _r)
#define GUIDANCE_H_USE_REF
Use horizontal guidance reference trajectory.
bool approx_force_by_thrust
int8_t register_periodic_telemetry(struct periodic_telemetry *_pt, uint8_t _id, telemetry_cb _cb)
Register a telemetry callback function.
void stabilization_attitude_run(bool in_flight)
void guidance_flip_enter(void)
bool guidance_h_set_guided_heading(float heading)
Set heading setpoint in GUIDED mode.
#define BFP_OF_REAL(_vr, _frac)
void guidance_hybrid_run(void)
Runs the Hybrid Guidance main functions.
struct HorizontalGuidanceSetpoint sp
setpoints
void stabilization_rate_enter(void)
struct HorizontalGuidanceGains gains
#define GUIDANCE_H_MODE_KILL
void stabilization_attitude_reset_care_free_heading(void)
reset the heading for care-free mode to current heading
#define GUIDANCE_H_MODE_RATE
#define INT32_VECT2_RSHIFT(_o, _i, _r)
void gh_set_ref(struct Int32Vect2 pos, struct Int32Vect2 speed, struct Int32Vect2 accel)
#define INT32_VECT2_LSHIFT(_o, _i, _l)
void stabilization_attitude_enter(void)
struct Int32Vect2 guidance_h_speed_err
static void send_href(struct transport_tx *trans, struct link_device *dev)
static void read_rc_setpoint_speed_i(struct Int32Vect2 *speed_sp, bool in_flight)
read speed setpoint from RC
void guidance_h_read_rc(bool in_flight)
void stabilization_none_enter(void)
void guidance_h_hover_enter(void)
void guidance_h_nav_enter(void)
static void transition_run(bool to_forward)
static void send_tune_hover(struct transport_tx *trans, struct link_device *dev)
int32_t guidance_v_thrust_coeff
int32_t transition_percentage
void guidance_h_guided_run(bool in_flight)
Run GUIDED mode control.
int32_t stabilization_cmd[COMMANDS_NB]
Stabilization commands.
struct Int32Vect2 pos
with INT32_POS_FRAC
struct HorizontalGuidance guidance_h
static struct NedCoor_i * stateGetAccelNed_i(void)
Get acceleration in NED coordinates (int).
static void send_gh(struct transport_tx *trans, struct link_device *dev)
void guidance_h_from_nav(bool in_flight)
Set horizontal guidance from NAV and run control loop.
struct Int32Vect2 accel
Reference model acceleration.
void stabilization_rate_run(bool in_flight)
void stabilization_rate_read_rc_switched_sticks(void)
#define POS_BFP_OF_REAL(_af)
void stabilization_attitude_set_earth_cmd_i(struct Int32Vect2 *cmd, int32_t heading)
void stabilization_attitude_set_rpy_setpoint_i(struct Int32Eulers *rpy)
void guidance_h_module_enter(void)
static struct Int32Eulers * stateGetNedToBodyEulers_i(void)
Get vehicle body attitude euler angles (int).
void guidance_h_module_init(void)
#define GUIDANCE_H_MODE_NAV
#define INT32_PERCENTAGE_FRAC
bool guidance_h_set_guided_vel(float vx, float vy)
Set horizontal velocity setpoint in GUIDED mode.
#define HORIZONTAL_MODE_ATTITUDE
struct Int64Vect2 pos
Reference model position.
#define DefaultPeriodic
Set default periodic telemetry.
bool guidance_h_set_guided_heading_rate(float rate)
Set heading rate setpoint in GUIDED mode.
#define GUIDANCE_H_MODE_CARE_FREE
void stabilization_none_run(bool in_flight)
void guidance_indi_run(float *heading_sp)
struct RadioControl radio_control
const struct Int32Vect2 * guidance_h_get_pos_err(void)
Gets the position error.
void stabilization_none_read_rc(void)
void guidance_h_init(void)
pprz_t values[RADIO_CONTROL_NB_CHANNEL]
#define GUIDANCE_H_THRUST_CMD_FILTER
#define GUIDANCE_H_REF_MAX_SPEED
Default speed saturation.
#define PPRZ_ITRIG_SIN(_s, _a)