mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-02-12 02:44:00 -04:00
Copter: log ERR when compass, baro unhealthy
This commit is contained in:
parent
2b4aaf2368
commit
764fa36716
@ -272,6 +272,11 @@ void Copter::fast_loop()
|
|||||||
|
|
||||||
// check if we've landed or crashed
|
// check if we've landed or crashed
|
||||||
update_land_and_crash_detectors();
|
update_land_and_crash_detectors();
|
||||||
|
|
||||||
|
// log sensor health
|
||||||
|
if (should_log(MASK_LOG_ANY)) {
|
||||||
|
Log_Sensor_Health();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// rc_loops - reads user input from transmitter/receiver
|
// rc_loops - reads user input from transmitter/receiver
|
||||||
|
@ -125,6 +125,10 @@ Copter::Copter(void) :
|
|||||||
param_loader(var_info)
|
param_loader(var_info)
|
||||||
{
|
{
|
||||||
memset(¤t_loc, 0, sizeof(current_loc));
|
memset(¤t_loc, 0, sizeof(current_loc));
|
||||||
|
|
||||||
|
// init sensor error logging flags
|
||||||
|
sensor_health.baro = true;
|
||||||
|
sensor_health.compass = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Copter copter;
|
Copter copter;
|
||||||
|
@ -271,6 +271,12 @@ private:
|
|||||||
uint32_t last_heartbeat_ms; // the time when the last HEARTBEAT message arrived from a GCS - used for triggering gcs failsafe
|
uint32_t last_heartbeat_ms; // the time when the last HEARTBEAT message arrived from a GCS - used for triggering gcs failsafe
|
||||||
} failsafe;
|
} failsafe;
|
||||||
|
|
||||||
|
// sensor health for logging
|
||||||
|
struct {
|
||||||
|
uint8_t baro : 1; // true if baro is healthy
|
||||||
|
uint8_t compass : 1; // true if compass is healthy
|
||||||
|
} sensor_health;
|
||||||
|
|
||||||
// Motor Output
|
// Motor Output
|
||||||
#if FRAME_CONFIG == QUAD_FRAME
|
#if FRAME_CONFIG == QUAD_FRAME
|
||||||
#define MOTOR_CLASS AP_MotorsQuad
|
#define MOTOR_CLASS AP_MotorsQuad
|
||||||
@ -598,6 +604,7 @@ private:
|
|||||||
void Log_Write_Baro(void);
|
void Log_Write_Baro(void);
|
||||||
void Log_Write_Parameter_Tuning(uint8_t param, float tuning_val, int16_t control_in, int16_t tune_low, int16_t tune_high);
|
void Log_Write_Parameter_Tuning(uint8_t param, float tuning_val, int16_t control_in, int16_t tune_low, int16_t tune_high);
|
||||||
void Log_Write_Home_And_Origin();
|
void Log_Write_Home_And_Origin();
|
||||||
|
void Log_Sensor_Health();
|
||||||
#if FRAME_CONFIG == HELI_FRAME
|
#if FRAME_CONFIG == HELI_FRAME
|
||||||
void Log_Write_Heli(void);
|
void Log_Write_Heli(void);
|
||||||
#endif
|
#endif
|
||||||
|
@ -646,6 +646,22 @@ void Copter::Log_Write_Home_And_Origin()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// logs when baro or compass becomes unhealthy
|
||||||
|
void Copter::Log_Sensor_Health()
|
||||||
|
{
|
||||||
|
// check baro
|
||||||
|
if (sensor_health.baro != barometer.healthy()) {
|
||||||
|
sensor_health.baro = barometer.healthy();
|
||||||
|
Log_Write_Error(ERROR_SUBSYSTEM_BARO, (sensor_health.baro ? ERROR_CODE_ERROR_RESOLVED : ERROR_CODE_UNHEALTHY));
|
||||||
|
}
|
||||||
|
|
||||||
|
// check compass
|
||||||
|
if (sensor_health.compass != compass.healthy()) {
|
||||||
|
sensor_health.compass = compass.healthy();
|
||||||
|
Log_Write_Error(ERROR_SUBSYSTEM_COMPASS, (sensor_health.compass ? ERROR_CODE_ERROR_RESOLVED : ERROR_CODE_UNHEALTHY));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
struct PACKED log_Heli {
|
struct PACKED log_Heli {
|
||||||
LOG_PACKET_HEADER;
|
LOG_PACKET_HEADER;
|
||||||
uint64_t time_us;
|
uint64_t time_us;
|
||||||
|
@ -353,6 +353,7 @@ enum FlipState {
|
|||||||
// general error codes
|
// general error codes
|
||||||
#define ERROR_CODE_ERROR_RESOLVED 0
|
#define ERROR_CODE_ERROR_RESOLVED 0
|
||||||
#define ERROR_CODE_FAILED_TO_INITIALISE 1
|
#define ERROR_CODE_FAILED_TO_INITIALISE 1
|
||||||
|
#define ERROR_CODE_UNHEALTHY 4
|
||||||
// subsystem specific error codes -- radio
|
// subsystem specific error codes -- radio
|
||||||
#define ERROR_CODE_RADIO_LATE_FRAME 2
|
#define ERROR_CODE_RADIO_LATE_FRAME 2
|
||||||
// subsystem specific error codes -- failsafe_thr, batt, gps
|
// subsystem specific error codes -- failsafe_thr, batt, gps
|
||||||
|
Loading…
Reference in New Issue
Block a user