47 #define MAX_AIRSPEED 15
51 #define INT32_ANGLE_HIGH_RES_FRAC 18
62 #define AIRSPEED_HOVER 4
63 #define AIRSPEED_FORWARD 12
64 #define CRUISE_THROTTLE 4000
65 #define FWD_SPEED_P_GAIN 30
66 #define FWD_ALT_THRUST_GAIN 0.35
68 #define FWD_NOMINAL_PITCH 78.0
69 #define FWD_PITCH_GAIN 2.1
70 #define HOVER_P_GAIN 12
99 #if PERIODIC_TELEMETRY
106 pprz_msg_send_HYBRID_GUIDANCE(trans,
dev, AC_ID,
107 &(pos->
x), &(pos->
y),
108 &(speed->
x), &(speed->
y),
144 #if PERIODIC_TELEMETRY
150 #define INT32_ANGLE_HIGH_RES_NORMALIZE(_a) { \
151 while ((_a) > (INT32_ANGLE_PI << (INT32_ANGLE_HIGH_RES_FRAC - INT32_ANGLE_FRAC))) (_a) -= (INT32_ANGLE_2_PI << (INT32_ANGLE_HIGH_RES_FRAC - INT32_ANGLE_FRAC)); \
152 while ((_a) < -(INT32_ANGLE_PI << (INT32_ANGLE_HIGH_RES_FRAC - INT32_ANGLE_FRAC))) (_a) += (INT32_ANGLE_2_PI << (INT32_ANGLE_HIGH_RES_FRAC - INT32_ANGLE_FRAC)); \
256 if (heading_diff > 0.0) {
258 }
else if (heading_diff < 0.0) {
332 if (norm_groundspeed_sp > 1 << 8) {
354 if (norm_airspeed_sp > (
max_airspeed << 8) && norm_groundspeed_sp > 0) {
363 float d_sqrt_f = sqrtf(dv);
366 int32_t result = ((-bv + d_sqrt) << 8) / (2 * av);
379 if ((norm_airspeed_sp > (
max_airspeed << 8)) && (norm_airspeed_sp != 0)) {
445 int32_t hover_thrust = delta_t;
452 hybrid_delta_t = hover_thrust;
462 hybrid_delta_t = fwd_thrust;
473 hybrid_delta_t = (fwd_thrust * airspeed_transition
474 + hover_thrust * (1 - airspeed_transition));
487 #if GUIDANCE_HYBRID_USE_AS_DEFAULT
#define FLOAT_ANGLE_NORMALIZE(_a)
void float_eulers_of_quat_zxy(struct FloatEulers *e, struct FloatQuat *q)
euler rotation 'ZXY' This rotation order is useful if you need 90 deg pitch
void float_quat_of_orientation_vect(struct FloatQuat *q, const struct FloatVect3 *ov)
Quaternion from orientation vector.
#define VECT2_ADD(_a, _b)
#define VECT2_DIFF(_c, _a, _b)
#define VECT2_COPY(_a, _b)
#define VECT2_SDIV(_vo, _vi, _s)
#define QUAT_BFP_OF_REAL(_qi, _qf)
int32_t phi
in rad with INT32_ANGLE_FRAC
int32_t psi
in rad with INT32_ANGLE_FRAC
int32_t theta
in rad with INT32_ANGLE_FRAC
void int32_quat_comp(struct Int32Quat *a2c, struct Int32Quat *a2b, struct Int32Quat *b2c)
Composition (multiplication) of two quaternions.
void int32_quat_of_axis_angle(struct Int32Quat *q, struct Int32Vect3 *uv, int32_t angle)
Quaternion from unit vector and angle.
#define INT_MULT_RSHIFT(_a, _b, _r)
#define ANGLE_BFP_OF_REAL(_af)
static uint32_t int32_vect2_norm(struct Int32Vect2 *v)
return norm of 2D vector
#define POS_FLOAT_OF_BFP(_ai)
#define FLOAT_OF_BFP(_vbfp, _frac)
#define INT_VECT2_ZERO(_v)
#define ANGLE_FLOAT_OF_BFP(_ai)
#define INT32_VECT2_RSHIFT(_o, _i, _r)
#define POS_BFP_OF_REAL(_af)
#define INT_EULERS_ZERO(_e)
vector in North East Down coordinates
static struct FloatQuat * stateGetNedToBodyQuat_f(void)
Get vehicle body attitude quaternion (float).
static struct NedCoor_i * stateGetPositionNed_i(void)
Get position in local NED coordinates (int).
static struct NedCoor_i * stateGetSpeedNed_i(void)
Get ground speed in local NED coordinates (int).
struct StabilizationSetpoint guidance_hybrid_h_run_pos(bool in_flight UNUSED, struct HorizontalGuidance *gh)
struct StabilizationSetpoint guidance_hybrid_h_run_speed(bool in_flight UNUSED, struct HorizontalGuidance *gh)
int32_t guidance_hybrid_norm_ref_airspeed
#define FWD_NOMINAL_PITCH
float guidance_hybrid_norm_ref_airspeed_f
float fwd_alt_thrust_gain
static int32_t omega_disp
static int32_t v_control_pitch
static struct Int32Vect2 guidance_h_pos_err
static struct Int32Eulers guidance_hybrid_ypr_sp
static int32_t airspeed_sp_heading_disp
struct StabilizationSetpoint guidance_hybrid_run(void)
Runs the Hybrid Guidance main functions.
static struct Int32Vect2 guidance_hybrid_groundspeed_sp
static void send_hybrid_guidance(struct transport_tx *trans, struct link_device *dev)
struct StabilizationSetpoint guidance_hybrid_h_run_accel(bool in_flight UNUSED, struct HorizontalGuidance *gh UNUSED)
#define FWD_ALT_THRUST_GAIN
static bool guidance_hovering
void guidance_hybrid_determine_wind_estimate(void)
Description.
static struct Int32Vect2 guidance_hybrid_airspeed_sp
#define INT32_ANGLE_HIGH_RES_NORMALIZE(_a)
static int32_t heading_diff_disp
struct ThrustSetpoint guidance_hybrid_vertical(struct ThrustSetpoint *th)
Take a thrust command as input and returns the modified value according to the current flight regime.
void guidance_hybrid_groundspeed_to_airspeed(void)
Description.
static struct Int32Vect2 wind_estimate_high_res
static struct Int32Vect2 guidance_hybrid_airspeed_ref
struct ThrustSetpoint guidance_hybrid_v_run_speed(bool in_flight, struct VerticalGuidance *gv)
void guidance_hybrid_airspeed_to_attitude(struct Int32Eulers *ypr_sp)
Convert a required airspeed to a certain attitude for the Quadshot.
int32_t horizontal_speed_gain
struct ThrustSetpoint guidance_hybrid_v_run_accel(bool in_flight, struct VerticalGuidance *gv)
struct StabilizationSetpoint guidance_hybrid_set_cmd_i(struct Int32Eulers *sp_cmd)
Creates the attitude set-points from an orientation vector.
static int32_t high_res_psi
static struct Int32Vect2 guidance_hybrid_ref_airspeed
static struct Int32Vect2 wind_estimate
void guidance_hybrid_init(void)
Hybrid Guidance Initialization function.
#define INT32_ANGLE_HIGH_RES_FRAC
bool force_forward_flight
static int32_t norm_sp_airspeed_disp
struct ThrustSetpoint guidance_hybrid_v_run_pos(bool in_flight, struct VerticalGuidance *gv)
Guidance controllers (horizontal and vertical) for Hybrid UAV configurations.
struct FloatEulers eulers_zxy
state eulers in zxy order
void guidance_v_run_enter(void)
struct ThrustSetpoint guidance_v_run_pos(bool in_flight UNUSED, struct VerticalGuidance *gv)
struct ThrustSetpoint guidance_v_run_speed(bool in_flight UNUSED, struct VerticalGuidance *gv)
struct ThrustSetpoint guidance_v_run_accel(bool in_flight UNUSED, struct VerticalGuidance *gv)
struct ThrustSetpoint guidance_pid_v_run_accel(bool in_flight UNUSED, struct VerticalGuidance *gv UNUSED)
struct ThrustSetpoint guidance_pid_v_run_pos(bool in_flight, struct VerticalGuidance *gv)
struct ThrustSetpoint guidance_pid_v_run_speed(bool in_flight, struct VerticalGuidance *gv)
struct GuidancePID guidance_pid
Guidance PID structyre.
Guidance controller with PID for rotorcrafts.
#define PPRZ_ITRIG_SIN(_s, _a)
#define PPRZ_ITRIG_COS(_c, _a)
Generic interface for radio control modules.
Horizontal guidance for rotorcrafts.
void guidance_h_run_enter(void)
struct StabilizationSetpoint guidance_h_run_pos(bool in_flight, struct HorizontalGuidance *gh)
struct StabilizationSetpoint guidance_h_run_speed(bool in_flight, struct HorizontalGuidance *gh)
struct StabilizationSetpoint guidance_h_run_accel(bool in_flight, struct HorizontalGuidance *gh)
struct VerticalGuidance guidance_v
Vertical guidance for rotorcrafts.
float nominal_throttle
nominal throttle for hover.
struct RotorcraftNavigation nav
float heading
heading setpoint (in radians)
General attitude stabilization interface for rotorcrafts.
struct StabilizationSetpoint stab_sp_from_quat_i(struct Int32Quat *quat)
struct ThrustSetpoint th_sp_from_thrust_i(int32_t thrust, uint8_t axis)
int32_t th_sp_to_thrust_i(struct ThrustSetpoint *th, int32_t thrust, uint8_t axis)
static const struct usb_device_descriptor dev
union StabilizationSetpoint::@278 sp
Thrust setpoint // TODO to a setpoint header Structure to store the desired thrust vector with differ...
int8_t register_periodic_telemetry(struct periodic_telemetry *_pt, uint8_t _id, telemetry_cb _cb)
Register a telemetry callback function.
Periodic telemetry system header (includes downlink utility and generated code).
#define DefaultPeriodic
Set default periodic telemetry.
int int32_t
Typedef defining 32 bit int type.