67 #include "generated/airframe.h"
80 #error "Energy Controller can not accept Loiter Trim"
129 #define V_CTL_AUTO_GROUNDSPEED_MAX_SUM_ERR 100
144 #ifndef V_CTL_ALTITUDE_MAX_CLIMB
145 #define V_CTL_ALTITUDE_MAX_CLIMB 2;
146 INFO(
"V_CTL_ALTITUDE_MAX_CLIMB not defined - default is 2m/s")
148 #ifndef STALL_AIRSPEED
149 INFO(
"No STALL_AIRSPEED defined. Using NOMINAL_AIRSPEED")
150 #define STALL_AIRSPEED NOMINAL_AIRSPEED
152 #ifndef V_CTL_GLIDE_RATIO
153 #define V_CTL_GLIDE_RATIO 8.
154 INFO(
"V_CTL_GLIDE_RATIO not defined - default is 8.")
156 #ifndef AIRSPEED_SETPOINT_SLEW
157 #define AIRSPEED_SETPOINT_SLEW 1
159 #ifndef V_CTL_MAX_ACCELERATION
160 #define V_CTL_MAX_ACCELERATION 0.5
163 #ifndef V_CTL_ENERGY_IMU_ID
164 #define V_CTL_ENERGY_IMU_ID ABI_BROADCAST
181 *last_v = (((*last_v) * (((float)count) - 1.0f)) + new_v) / ((
float) count);
184 static void ac_char_update(
float throttle,
float pitch,
float climb,
float accelerate)
186 if ((accelerate > -0.02) && (accelerate < 0.02)) {
187 if (throttle >= 1.0f) {
188 ac_char_climb_count++;
189 ac_char_average(&ac_char_climb_pitch, pitch * 57.6f, ac_char_climb_count);
191 }
else if (throttle <= 0.0f) {
192 ac_char_descend_count++;
193 ac_char_average(&ac_char_descend_pitch, pitch * 57.6f , ac_char_descend_count);
195 }
else if ((climb > -0.125) && (climb < 0.125)) {
196 ac_char_cruise_count++;
197 ac_char_average(&ac_char_cruise_throttle , throttle , ac_char_cruise_count);
198 ac_char_average(&ac_char_cruise_pitch , pitch * 57.6f , ac_char_cruise_count);
204 uint32_t stamp __attribute__((unused)),
226 #ifdef V_CTL_AUTO_THROTTLE_NOMINAL_CRUISE_PITCH
253 #ifdef V_CTL_ENERGY_TOT_PGAIN
263 #warning "V_CTL_ENERGY_TOT GAINS are not defined and set to 0"
266 #ifdef V_CTL_ALTITUDE_MAX_CLIMB
270 #warning "V_CTL_ALTITUDE_MAX_CLIMB not defined - default is 2m/s"
273 #ifdef V_CTL_AUTO_GROUNDSPEED_SETPOINT
310 BoundAbs(incr, 2 * dt_navigation);
311 v_ctl_climb_setpoint += incr;
321 lp_vdot[4] += (v - lp_vdot[4]) / 3;
322 lp_vdot[3] += (lp_vdot[4] - lp_vdot[3]) / 3;
323 lp_vdot[2] += (lp_vdot[3] - lp_vdot[2]) / 3;
324 lp_vdot[1] += (lp_vdot[2] - lp_vdot[1]) / 3;
325 lp_vdot[0] += (lp_vdot[1] - lp_vdot[0]) / 3;
340 v_ctl_auto_airspeed_setpoint_slew += airspeed_incr;
342 #ifdef V_CTL_AUTO_GROUNDSPEED_SETPOINT
388 float en_tot_err = gamma_err + vdot_err;
391 float en_dis_err = gamma_err - vdot_err;
407 if ((controlled_throttle >= 1.0f) || (controlled_throttle <= 0.0f) || (
kill_throttle == 1)) {
409 en_dis_err = -vdot_err;
423 float v_ctl_pitch_of_vz =
440 #ifdef V_CTL_THROTTLE_SLEW_LIMITER
441 #define V_CTL_THROTTLE_SLEW (1./CONTROL_FREQUENCY/(V_CTL_THROTTLE_SLEW_LIMITER))
444 #ifndef V_CTL_THROTTLE_SLEW
445 #define V_CTL_THROTTLE_SLEW 1.
454 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.
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
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
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)
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_CLIMB_MODE_AUTO_THROTTLE
float v_ctl_energy_diff_igain
const float dt_navigation
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
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
#define NAVIGATION_FREQUENCY
#define CONTROL_FREQUENCY
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
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
Fixedwing autopilot modes.