67 #include "generated/airframe.h"
80 #error "Energy Controller can not accept Loiter Trim"
129 #define V_CTL_AUTO_GROUNDSPEED_MAX_SUM_ERR 100
145 #ifndef V_CTL_ALTITUDE_MAX_CLIMB
146 #define V_CTL_ALTITUDE_MAX_CLIMB 2;
147 INFO(
"V_CTL_ALTITUDE_MAX_CLIMB not defined - default is 2 , indicating 2 m/s")
149 #ifndef STALL_AIRSPEED
150 INFO(
"No STALL_AIRSPEED defined. Using NOMINAL_AIRSPEED")
151 #define STALL_AIRSPEED NOMINAL_AIRSPEED
153 #ifndef V_CTL_GLIDE_RATIO
154 #define V_CTL_GLIDE_RATIO 8.
155 INFO(
"V_CTL_GLIDE_RATIO not defined - default is 8.")
157 #ifndef AIRSPEED_SETPOINT_SLEW
158 #define AIRSPEED_SETPOINT_SLEW 1
160 #ifndef V_CTL_MAX_ACCELERATION
161 #define V_CTL_MAX_ACCELERATION 0.5 //G
164 #ifndef V_CTL_ENERGY_IMU_ID
165 #define V_CTL_ENERGY_IMU_ID ABI_BROADCAST
182 *last_v = (((*last_v) * (((float)count) - 1.0f)) + new_v) / ((
float) count);
185 static void ac_char_update(
float throttle,
float pitch,
float climb,
float accelerate)
187 if ((accelerate > -0.02) && (accelerate < 0.02)) {
188 if (throttle >= 1.0f) {
189 ac_char_climb_count++;
190 ac_char_average(&ac_char_climb_pitch, pitch * 57.6f, ac_char_climb_count);
192 }
else if (throttle <= 0.0f) {
193 ac_char_descend_count++;
194 ac_char_average(&ac_char_descend_pitch, pitch * 57.6f , ac_char_descend_count);
196 }
else if ((climb > -0.125) && (climb < 0.125)) {
197 ac_char_cruise_count++;
198 ac_char_average(&ac_char_cruise_throttle , throttle , ac_char_cruise_count);
199 ac_char_average(&ac_char_cruise_pitch , pitch * 57.6f , ac_char_cruise_count);
205 uint32_t stamp __attribute__((unused)),
228 #ifdef V_CTL_AUTO_THROTTLE_NOMINAL_CRUISE_PITCH
255 #ifdef V_CTL_ENERGY_TOT_PGAIN
265 #warning "V_CTL_ENERGY_TOT GAINS are not defined and set to 0"
268 #ifdef V_CTL_ALTITUDE_MAX_CLIMB
272 #warning "V_CTL_ALTITUDE_MAX_CLIMB not defined - default is 2m/s"
275 #ifdef V_CTL_AUTO_GROUNDSPEED_SETPOINT
312 BoundAbs(incr, 2 * dt_navigation);
313 v_ctl_climb_setpoint += incr;
323 lp_vdot[4] += (v - lp_vdot[4]) / 3;
324 lp_vdot[3] += (lp_vdot[4] - lp_vdot[3]) / 3;
325 lp_vdot[2] += (lp_vdot[3] - lp_vdot[2]) / 3;
326 lp_vdot[1] += (lp_vdot[2] - lp_vdot[1]) / 3;
327 lp_vdot[0] += (lp_vdot[1] - lp_vdot[0]) / 3;
342 v_ctl_auto_airspeed_setpoint_slew += airspeed_incr;
344 #ifdef V_CTL_AUTO_GROUNDSPEED_SETPOINT
390 float en_tot_err = gamma_err + vdot_err;
393 float en_dis_err = gamma_err - vdot_err;
411 en_dis_err = -vdot_err;
425 float v_ctl_pitch_of_vz =
442 #ifdef V_CTL_THROTTLE_SLEW_LIMITER
443 #define V_CTL_THROTTLE_SLEW (1./CONTROL_FREQUENCY/(V_CTL_THROTTLE_SLEW_LIMITER))
446 #ifndef V_CTL_THROTTLE_SLEW
447 #define V_CTL_THROTTLE_SLEW 1.
456 v_ctl_throttle_slewed += diff_throttle;
float v_ctl_altitude_error
in meters, (setpoint - alt) -> positive = too low
#define V_CTL_ENERGY_IMU_ID
Event structure to store callbacks in a linked list.
bool launch
request launch
float v_ctl_airspeed_pgain
float v_ctl_auto_throttle_nominal_cruise_throttle
static void ac_char_average(float *last_v, float new_v, int count)
static float stateGetHorizontalSpeedNorm_f(void)
Get norm of horizontal ground speed (float).
float v_ctl_altitude_setpoint
in meters above MSL
static struct FloatEulers * stateGetNedToBodyEulers_f(void)
Get vehicle body attitude euler angles (float).
float alt
in meters (above WGS84 reference ellipsoid or above MSL)
pprz_t v_ctl_throttle_setpoint
float v_ctl_desired_acceleration
bool autopilot_throttle_killed(void)
get kill status
float v_ctl_energy_diff_pgain
float v_ctl_auto_groundspeed_setpoint
in meters per second
float v_ctl_auto_groundspeed_igain
#define V_CTL_MAX_ACCELERATION
static void float_quat_identity(struct FloatQuat *q)
initialises a quaternion to identity
float v_ctl_climb_setpoint
float v_ctl_auto_pitch_of_airspeed_pgain
#define V_CTL_ALTITUDE_MAX_CLIMB
float v_ctl_altitude_pre_climb
Path Angle.
Main include for ABI (AirBorneInterface).
float controlled_throttle
static float stateGetAirspeed_f(void)
Get airspeed (float).
float v_ctl_energy_total_igain
#define CONTROL_FREQUENCY
int ac_char_descend_count
void v_ctl_throttle_slew(void)
Computes slewed throttle from throttle setpoint called at 20Hz.
void v_ctl_climb_loop(void)
Auto-throttle inner loop.
float ac_char_descend_max
float v_ctl_auto_throttle_sum_err
Vertical control using total energy control for fixed wing vehicles.
#define V_CTL_THROTTLE_SLEW
float ac_char_cruise_throttle
float v_ctl_auto_pitch_of_airspeed_dgain
static float low_pass_vdot(float v)
struct pprz_autopilot autopilot
Global autopilot structure.
float v_ctl_pitch_setpoint
float v_ctl_auto_airspeed_setpoint
in meters per second
static abi_event accel_ev
#define V_CTL_AUTO_GROUNDSPEED_MAX_SUM_ERR
float v_ctl_auto_throttle_climb_throttle_increment
float v_ctl_auto_groundspeed_sum_err
#define V_CTL_SPEED_THROTTLE
#define V_CTL_CLIMB_MODE_AUTO_THROTTLE
float v_ctl_energy_diff_igain
static const float dt_navigation
#define NAVIGATION_FREQUENCY
float ac_char_climb_pitch
float v_ctl_auto_throttle_of_airspeed_igain
static void ac_char_update(float throttle, float pitch, float climb, float accelerate)
void float_quat_vmult(struct FloatVect3 *v_out, struct FloatQuat *q, const struct FloatVect3 *v_in)
rotate 3D vector by quaternion.
uint8_t v_ctl_auto_throttle_submode
static void float_quat_invert(struct FloatQuat *qo, struct FloatQuat *qi)
float v_ctl_energy_total_pgain
#define AIRSPEED_SETPOINT_SLEW
#define V_CTL_MODE_AUTO_CLIMB
#define ACCELS_FLOAT_OF_BFP(_ef, _ei)
float v_ctl_altitude_pgain
#define V_CTL_GLIDE_RATIO
Core autopilot interface common to all firmwares.
static void body_to_imu_cb(uint8_t sender_id, struct FloatQuat *q_b2i_f)
float v_ctl_auto_throttle_cruise_throttle
static struct UtmCoor_f * stateGetPositionUtm_f(void)
Get position in UTM coordinates (float).
API to get/set the generic vehicle states.
float ac_char_cruise_pitch
float nav_pitch
with INT32_ANGLE_FRAC
static struct EnuCoor_f * stateGetSpeedEnu_f(void)
Get ground speed in local ENU coordinates (float).
float v_ctl_auto_throttle_pitch_of_vz_pgain
static struct Int32Vect3 accel_imu_meas
float v_ctl_auto_throttle_nominal_cruise_pitch
float v_ctl_auto_airspeed_setpoint_slew
static struct FloatQuat imu_to_body_quat
#define V_CTL_MODE_MANUAL
float v_ctl_auto_throttle_of_airspeed_pgain
Fixedwing Navigation library.
float ac_char_descend_pitch
float v_ctl_auto_groundspeed_pgain
static void accel_cb(uint8_t sender_id, uint32_t stamp, struct Int32Vect3 *accel)
static abi_event body_to_imu_ev
pprz_t v_ctl_throttle_slewed
static const float dt_attidude
float v_ctl_auto_pitch_of_airspeed_igain
float v_ctl_max_acceleration
float v_ctl_auto_airspeed_controlled
void v_ctl_altitude_loop(void)
outer loop