34 #define THROTTLE_CURVE_SWITCH_VAL (MAX_PPRZ*2/THROTTLE_CURVES_NB)
37 #ifndef THROTTLE_CURVE_RPM_FB_P
38 #define THROTTLE_CURVE_RPM_FB_P 0.0
41 #ifndef THROTTLE_CURVE_RPM_FB_I
42 #define THROTTLE_CURVE_RPM_FB_I 0.0
45 #ifndef THROTTLE_CURVE_RPM_INC_LIMIT
46 #define THROTTLE_CURVE_RPM_INC_LIMIT 512
50 #ifndef THROTTLE_CURVE_RPM_ID
51 #define THROTTLE_CURVE_RPM_ID ABI_BROADCAST
53 #ifndef THROTTLE_CURVE_RPM_ACT
54 #define THROTTLE_CURVE_RPM_ACT 0
62 .curves = THROTTLE_CURVES
65 #if PERIODIC_TELEMETRY
70 pprz_msg_send_THROTTLE_CURVE(trans, dev, AC_ID, &throttle_curve.
mode, &throttle_curve.
throttle,
81 throttle_curve.
mode = THROTTLE_CURVE_MODE_INIT;
82 throttle_curve.
nav_mode = THROTTLE_CURVE_MODE_INIT;
94 #if PERIODIC_TELEMETRY
120 Bound(mode, 0, THROTTLE_CURVES_NB - 1);
128 throttle_curve.
mode = 0;
136 throttle_curve.
rpm = curve.
rpm[0];
140 int8_t curve_p = ((float)cmds[COMMAND_THRUST] / curve_range);
144 uint16_t x = cmds[COMMAND_THRUST] - curve_p * curve_range;
146 + ((curve.
throttle[curve_p + 1] - curve.
throttle[curve_p]) * x / curve_range);
149 if (curve.
rpm[0] != 0xFFFF) {
150 if (throttle_curve.
rpm == 0xFFFF) {
154 + ((curve.
rpm[curve_p + 1] - curve.
rpm[curve_p]) * x / curve_range);
155 int32_t rpm_diff = new_rpm - throttle_curve.
rpm;
157 throttle_curve.
rpm += rpm_diff;
159 throttle_curve.
rpm = 0xFFFF;
165 Bound(trimmed_throttle, 0,
MAX_PPRZ);
166 throttle_curve.
throttle = trimmed_throttle;
170 throttle_curve.
collective = trimmed_collective;
188 throttle_curve.
throttle = new_throttle;
190 }
else if (curve.
rpm[0] == 0xFFFF) {
195 cmds[COMMAND_THRUST] = throttle_curve.
throttle;
196 cmds[COMMAND_COLLECTIVE] = throttle_curve.
collective;
200 cmds[COMMAND_THRUST] = 0;
211 Bound(new_mode, 0, THROTTLE_CURVES_NB - 1);
Event structure to store callbacks in a linked list.
struct curve_t curves[THROTTLE_CURVES_NB]
Throttle/pitch curves.
#define THROTTLE_CURVE_RPM_FB_P
static void rpm_cb(uint8_t sender_id, uint16_t *rpm, uint8_t num_act)
RPM callback for RPM based control throttle curves.
float rpm_err_sum
Summed RPM error.
Periodic telemetry system header (includes downlink utility and generated code).
int32_t throttle_trim
RPM feedback i gain.
bool autopilot_get_motors_on(void)
get motors status
float rpm_fb_p
RPM feedback p gain.
Main include for ABI (AirBorneInterface).
void nav_throttle_curve_set(uint8_t mode)
Set a specific throttle curve based on the mode given with this function.
#define THROTTLE_CURVE_SWITCH_VAL
uint16_t rpm_meas
RPM measured.
uint8_t nb_points
The number of points in the curve.
pprz_t values[RADIO_CONTROL_NB_CHANNEL]
uint8_t nav_mode
Nav Flight mode.
#define THROTTLE_CURVE_RPM_ID
static void throttle_curve_send_telem(struct transport_tx *trans, struct link_device *dev)
#define THROTTLE_CURVE_RPM_FB_I
struct throttle_curve_t throttle_curve
#define THROTTLE_CURVE_RPM_INC_LIMIT
int32_t coll_trim
Collective trim.
uint16_t throttle
Output thrust(throttle) of the throttle curve.
#define THROTTLE_CURVE_RPM_ACT
#define DefaultPeriodic
Set default periodic telemetry.
Hardware independent code for commands handling.
struct RadioControl radio_control
int16_t collective[THROTTLE_POINTS_NB]
The collective points in the curve.
static const struct usb_device_descriptor dev
Core autopilot interface common to all firmwares.
void throttle_curve_init(void)
Initialize the default throttle curve values.
static uint8_t mode
mode holds the current sonar mode mode = 0 used at high altitude, uses 16 wave patterns mode = 1 used...
bool rpm_measured
Whenever the RPM is measured.
void throttle_curve_run(pprz_t cmds[], uint8_t ap_mode)
Run the throttle curve and generate the output throttle and pitch This depends on the FMODE(flight mo...
uint8_t nb_curves
The number of throttle/pitch curves.
uint16_t rpm[THROTTLE_POINTS_NB]
RPM points in the curve.
uint16_t throttle[THROTTLE_POINTS_NB]
Throttle points in the curve.
uint16_t rpm
Output RPM of the throttle curve.
int16_t collective
Output collective of the throttle curve.
int8_t register_periodic_telemetry(struct periodic_telemetry *_pt, uint8_t _id, telemetry_cb _cb)
Register a telemetry callback function.