dRonin
adbada4
dRonin firmware
|
Header for sensor functions. More...
Files | |
file | stabilization.h |
Attitude stabilization module. | |
file | virtualflybar.h |
Attitude stabilization module. | |
file | sensors.c |
Acquire sensor data from sensors registered with PIOS_Sensors. | |
file | stabilization.c |
Control the UAV attitude to StabilizationDesired. | |
file | virtualflybar.c |
Virtual flybar control mode. | |
Macros | |
#define | MAX_SENSOR_PERIOD 6 |
#define | REQUIRED_GOOD_CYCLES 50 |
#define | MAX_TIME_BETWEEN_VALID_BARO_DATAS_US (100*1000) |
#define | MAX_TIME_BETWEEN_VALID_MAG_DATAS_US (300*1000) |
#define | MAX_QUEUE_SIZE 1 |
#define | STACK_SIZE_BYTES 1200 |
#define | TASK_PRIORITY PIOS_THREAD_PRIO_HIGHEST |
#define | FAILSAFE_TIMEOUT_MS 30 |
#define | COORDINATED_FLIGHT_MIN_ROLL_THRESHOLD 3.0f |
#define | COORDINATED_FLIGHT_MAX_YAW_THRESHOLD 0.05f |
#define | HORIZON_MODE_MAX_BLEND 0.85f |
Set the stick position that maximally transitions to rate. More... | |
#define | THROTTLE_EPSILON 0.000001f |
Minimum sane positive value for throttle. More... | |
#define | get_deadband(axis) (deadbands ? (deadbands + axis) : NULL) |
Enumerations | |
enum | { ROLL, PITCH, YAW, MAX_AXES } |
enum | mag_calibration_algo { MAG_CALIBRATION_PRELEMARI, MAG_CALIBRATION_NORMALIZE_LENGTH } |
enum | { PID_GROUP_RATE, PID_RATE_ROLL = PID_GROUP_RATE, PID_RATE_PITCH, PID_RATE_YAW, PID_GROUP_ATT, PID_ATT_ROLL = PID_GROUP_ATT, PID_ATT_PITCH, PID_ATT_YAW, PID_GROUP_VBAR, PID_VBAR_ROLL = PID_GROUP_VBAR, PID_VBAR_PITCH, PID_VBAR_YAW, PID_COORDINATED_FLIGHT_YAW, PID_MAX } |
Functions | |
int32_t | StabilizationInitialize () |
int | stabilization_virtual_flybar (float gyro, float command, float *output, float dT, bool reinit, uint32_t axis, struct pid *pid, VbarSettingsData *settings) |
int | stabilization_virtual_flybar_pirocomp (float z_gyro, float dT) |
static void | update_accels (struct pios_sensor_accel_data *accels) |
Apply calibration and rotation to the raw accel data. More... | |
static void | update_gyros (struct pios_sensor_gyro_data *gyros) |
Apply calibration and rotation to the raw gyro data. More... | |
static void | update_mags (struct pios_sensor_mag_data *mag) |
Apply calibration and rotation to the raw mag data. More... | |
static void | update_baro (struct pios_sensor_baro_data *baro) |
static void | mag_calibration_prelemari (MagnetometerData *mag) |
static void | mag_calibration_fix_length (MagnetometerData *mag) |
static void | updateTemperatureComp (float temperature, float *temp_bias) |
static void | sensors_settings_update () |
int32_t | sensors_init (void) |
bool | sensors_step () |
DONT_BUILD_IF ((MAX_AXES+0!=3), stabAxisWrongCount) | |
DONT_BUILD_IF ((PID_RATE_ROLL+0!=ROLL)||(PID_ATT_ROLL!=PID_GROUP_ATT+ROLL), stabAxisPidEnumMapping1) | |
DONT_BUILD_IF ((PID_RATE_PITCH+0!=PITCH)||(PID_ATT_PITCH!=PID_GROUP_ATT+PITCH), stabAxisPidEnumMapping2) | |
DONT_BUILD_IF ((PID_RATE_YAW+0!=YAW)||(PID_ATT_YAW!=PID_GROUP_ATT+YAW), stabAxisPidEnumMapping3) | |
DONT_BUILD_IF (STABILIZATIONSETTINGS_MAXLEVELANGLE_ROLL!=ROLL+0, LevelAngleConstantRoll) | |
DONT_BUILD_IF (STABILIZATIONSETTINGS_MAXLEVELANGLE_PITCH!=PITCH+0, LevelAngleConstantPitch) | |
DONT_BUILD_IF (STABILIZATIONSETTINGS_MAXLEVELANGLE_YAW!=YAW+0, LevelAngleConstantYaw) | |
static void | stabilizationTask (void *parameters) |
static void | zero_pids (void) |
static void | calculate_pids (float dT) |
static void | update_settings (float dT) |
static float | get_throttle (ActuatorDesiredData *actuator_desired, SystemSettingsAirframeTypeOptions *airframe_type) |
int32_t | StabilizationStart () |
bool | stabilization_failsafe_checks (StabilizationDesiredData *stab_desired, ActuatorDesiredData *actuator_desired, SystemSettingsAirframeTypeOptions airframe_type, float *input, uint8_t *mode) |
static void | calculate_attitude_errors (uint8_t *axis_mode, float *raw_input, AttitudeActualData *attitudeActual, float *local_attitude_error, float *horizon_rate_fraction) |
MODULE_HIPRI_INITCALL (StabilizationInitialize, StabilizationStart) | |
static float | calculate_thrust (StabilizationDesiredThrustModeOptions mode, FlightStatusData *flightStatus, SystemSettingsAirframeTypeOptions airframe_type, float desired_thrust) |
static uint8_t | remap_smoothing_mode (uint8_t m) |
static void | calculate_vert_pids (float dT) |
static float | bound (float val, float range) |
Private methods. More... | |
Variables | |
static INSSettingsData | insSettings |
static AccelsData | accelsData |
static volatile bool | settings_updated = true |
static bool | bias_correct_gyro = true |
static float | mag_bias [3] = {0,0,0} |
static float | mag_scale [3] = {0,0,0} |
static float | accel_bias [3] = {0,0,0} |
static float | accel_scale [3] = {0,0,0} |
static float | gyro_scale [3] = {0,0,0} |
static float | gyro_coeff_x [4] = {0,0,0,0} |
static float | gyro_coeff_y [4] = {0,0,0,0} |
static float | gyro_coeff_z [4] = {0,0,0,0} |
static float | gyro_temp_bias [3] = {0,0,0} |
static float | z_accel_offset = 0 |
static float | Rsb [3][3] = {{0}} |
static int8_t | rotate = 0 |
Rotation matrix that transforms from the body frame to the sensor board frame. More... | |
static enum mag_calibration_algo | mag_calibration_algo = MAG_CALIBRATION_PRELEMARI |
Select the algorithm to try and null out the magnetometer bias error. More... | |
static lpfilter_state_t | gyro_filter |
static lpfilter_state_t | accel_filter |
static struct pios_thread * | taskHandle |
static StabilizationSettingsData | settings |
static VbarSettingsData | vbar_settings |
static SubTrimData | subTrim |
uint16_t | ident_wiggle_points |
static float | axis_lock_accum [MAX_AXES] = {0,0,0} |
static uint8_t | max_axis_lock = 0 |
static uint8_t | max_axislock_rate = 0 |
static float | weak_leveling_kp = 0 |
static uint8_t | weak_leveling_max = 0 |
static bool | lowThrottleZeroIntegral |
static float | max_rate_alpha = 0.8f |
float | vbar_decay = 0.991f |
static struct pid | pids [PID_MAX] |
static smoothcontrol_state | rc_smoothing |
struct pid_deadband * | deadbands = NULL |
static float | vbar_integral [MAX_AXES] |
Private variables. More... | |
float | vbar_decay |
Header for sensor functions.
#define COORDINATED_FLIGHT_MAX_YAW_THRESHOLD 0.05f |
Definition at line 101 of file stabilization.c.
#define COORDINATED_FLIGHT_MIN_ROLL_THRESHOLD 3.0f |
Definition at line 100 of file stabilization.c.
#define FAILSAFE_TIMEOUT_MS 30 |
Definition at line 99 of file stabilization.c.
Definition at line 188 of file stabilization.c.
#define HORIZON_MODE_MAX_BLEND 0.85f |
Set the stick position that maximally transitions to rate.
Definition at line 106 of file stabilization.c.
#define MAX_QUEUE_SIZE 1 |
Definition at line 90 of file stabilization.c.
#define STACK_SIZE_BYTES 1200 |
Definition at line 95 of file stabilization.c.
#define TASK_PRIORITY PIOS_THREAD_PRIO_HIGHEST |
Definition at line 98 of file stabilization.c.
#define THROTTLE_EPSILON 0.000001f |
Minimum sane positive value for throttle.
Definition at line 109 of file stabilization.c.
anonymous enum |
Enumerator | |
---|---|
ROLL | |
PITCH | |
YAW | |
MAX_AXES |
Definition at line 35 of file stabilization.h.
anonymous enum |
Definition at line 111 of file stabilization.c.
enum mag_calibration_algo |
|
static |
|
static |
Definition at line 331 of file stabilization.c.
|
static |
Definition at line 1579 of file stabilization.c.
|
static |
Definition at line 503 of file stabilization.c.
|
static |
Definition at line 1679 of file stabilization.c.
DONT_BUILD_IF | ( | (MAX_AXES+0!=3) | , |
stabAxisWrongCount | |||
) |
DONT_BUILD_IF | ( | (PID_RATE_ROLL+0!=ROLL)||(PID_ATT_ROLL!=PID_GROUP_ATT+ROLL) | , |
stabAxisPidEnumMapping1 | |||
) |
DONT_BUILD_IF | ( | (PID_RATE_PITCH+0!=PITCH)||(PID_ATT_PITCH!=PID_GROUP_ATT+PITCH) | , |
stabAxisPidEnumMapping2 | |||
) |
DONT_BUILD_IF | ( | (PID_RATE_YAW+0!=YAW)||(PID_ATT_YAW!=PID_GROUP_ATT+YAW) | , |
stabAxisPidEnumMapping3 | |||
) |
DONT_BUILD_IF | ( | STABILIZATIONSETTINGS_MAXLEVELANGLE_ROLL! | = ROLL+0 , |
LevelAngleConstantRoll | |||
) |
DONT_BUILD_IF | ( | STABILIZATIONSETTINGS_MAXLEVELANGLE_PITCH! | = PITCH+0 , |
LevelAngleConstantPitch | |||
) |
DONT_BUILD_IF | ( | STABILIZATIONSETTINGS_MAXLEVELANGLE_YAW! | = YAW+0 , |
LevelAngleConstantYaw | |||
) |
|
static |
Definition at line 193 of file stabilization.c.
|
static |
|
static |
MODULE_HIPRI_INITCALL | ( | StabilizationInitialize | , |
StabilizationStart | |||
) |
|
static |
Definition at line 1563 of file stabilization.c.
int32_t sensors_init | ( | void | ) |
API for sensor fusion algorithms: Configure(struct pios_queue *gyro, struct pios_queue *accel, struct pios_queue *mag, struct pios_queue *baro) Stores all the queues the algorithm will pull data from FinalizeSensors() – before saving the sensors modifies them based on internal state (gyro bias) Update() – queries queues and updates the attitude estiamte Initialise the module. Called before the start function
|
static |
bool sensors_step | ( | ) |
bool stabilization_failsafe_checks | ( | StabilizationDesiredData * | stab_desired, |
ActuatorDesiredData * | actuator_desired, | ||
SystemSettingsAirframeTypeOptions | airframe_type, | ||
float * | input, | ||
uint8_t * | mode | ||
) |
Definition at line 271 of file stabilization.c.
int stabilization_virtual_flybar | ( | float | gyro, |
float | command, | ||
float * | output, | ||
float | dT, | ||
bool | reinit, | ||
uint32_t | axis, | ||
struct pid * | pid, | ||
VbarSettingsData * | settings | ||
) |
Definition at line 44 of file virtualflybar.c.
int stabilization_virtual_flybar_pirocomp | ( | float | z_gyro, |
float | dT | ||
) |
Want to keep the virtual flybar fixed in world coordinates as we pirouette
[in] | z_gyro | The deg/s of rotation along the z axis |
[in] | dT | The time since last sample |
Definition at line 79 of file virtualflybar.c.
int32_t StabilizationInitialize | ( | ) |
Module initialization
Definition at line 230 of file stabilization.c.
int32_t StabilizationStart | ( | ) |
Module initialization
Definition at line 215 of file stabilization.c.
|
static |
Module task
Definition at line 714 of file stabilization.c.
|
static |
|
static |
|
static |
|
static |
|
static |
Definition at line 1690 of file stabilization.c.
|
static |
|
static |
Clear the accumulators and derivatives for all the axes
Definition at line 1553 of file stabilization.c.
|
static |
|
static |
Definition at line 154 of file stabilization.c.
struct pid_deadband* deadbands = NULL |
Definition at line 178 of file stabilization.c.
|
static |
uint16_t ident_wiggle_points |
Definition at line 152 of file stabilization.c.
|
static |
Definition at line 159 of file stabilization.c.
|
static |
Definition at line 155 of file stabilization.c.
|
static |
Definition at line 156 of file stabilization.c.
|
static |
Definition at line 160 of file stabilization.c.
Definition at line 171 of file stabilization.c.
|
static |
Definition at line 172 of file stabilization.c.
|
static |
|
static |
Definition at line 147 of file stabilization.c.
|
static |
Definition at line 150 of file stabilization.c.
|
static |
Definition at line 141 of file stabilization.c.
float vbar_decay |
Definition at line 161 of file stabilization.c.
float vbar_decay = 0.991f |
Definition at line 161 of file stabilization.c.
|
static |
Private variables.
Definition at line 38 of file virtualflybar.c.
|
static |
Definition at line 148 of file stabilization.c.
|
static |
Definition at line 157 of file stabilization.c.
|
static |
Definition at line 158 of file stabilization.c.