Skip to content

Commit

Permalink
Plane: fix attitude/AOA logging and rates
Browse files Browse the repository at this point in the history
  • Loading branch information
Hwurzburg authored and tridge committed Aug 2, 2022
1 parent 223b005 commit fcf2953
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 26 deletions.
31 changes: 18 additions & 13 deletions ArduPlane/ArduPlane.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,9 @@ const AP_Scheduler::Task Plane::scheduler_tasks[] = {
#endif // CAMERA == ENABLED
SCHED_TASK_CLASS(AP_Scheduler, &plane.scheduler, update_logging, 0.2, 100, 111),
SCHED_TASK(compass_save, 0.1, 200, 114),
SCHED_TASK(Log_Write_Fast, 400, 300, 117),
SCHED_TASK(update_logging1, 25, 300, 120),
SCHED_TASK(update_logging2, 25, 300, 123),
SCHED_TASK(Log_Write_FullRate, 400, 300, 117),
SCHED_TASK(update_logging10, 10, 300, 120),
SCHED_TASK(update_logging25, 25, 300, 123),
#if HAL_SOARING_ENABLED
SCHED_TASK(update_soaring, 50, 400, 126),
#endif
Expand Down Expand Up @@ -226,24 +226,29 @@ void Plane::update_compass(void)
/*
do 10Hz logging
*/
void Plane::update_logging1(void)
void Plane::update_logging10(void)
{
if (should_log(MASK_LOG_ATTITUDE_MED) && !should_log(MASK_LOG_ATTITUDE_FAST)) {
bool log_faster = (should_log(MASK_LOG_ATTITUDE_FULLRATE) || should_log(MASK_LOG_ATTITUDE_FAST));
if (should_log(MASK_LOG_ATTITUDE_MED) && !log_faster) {
Log_Write_Attitude();
}

if (should_log(MASK_LOG_ATTITUDE_MED) && !should_log(MASK_LOG_IMU))
AP::ins().Write_IMU();

if (should_log(MASK_LOG_ATTITUDE_MED))
ahrs.Write_AOA_SSA();
} else if (log_faster) {
ahrs.Write_AOA_SSA();
}
}

/*
do 10Hz logging - part2
do 25Hz logging
*/
void Plane::update_logging2(void)
void Plane::update_logging25(void)
{
// MASK_LOG_ATTITUDE_FULLRATE logs at 400Hz, MASK_LOG_ATTITUDE_FAST at 25Hz, MASK_LOG_ATTIUDE_MED logs at 10Hz
// highest rate selected wins
bool log_faster = should_log(MASK_LOG_ATTITUDE_FULLRATE);
if (should_log(MASK_LOG_ATTITUDE_FAST) && !log_faster) {
Log_Write_Attitude();
}

if (should_log(MASK_LOG_CTUN)) {
Log_Write_Control_Tuning();
AP::ins().write_notch_log_messages();
Expand Down
14 changes: 4 additions & 10 deletions ArduPlane/Log.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,17 +49,11 @@ void Plane::Log_Write_Attitude(void)
}

// do fast logging for plane
void Plane::Log_Write_Fast(void)
void Plane::Log_Write_FullRate(void)
{
if (!should_log(MASK_LOG_ATTITUDE_FULLRATE)) {
uint32_t now = AP_HAL::millis();
if (now - last_log_fast_ms < 40) {
// default to 25Hz
return;
}
last_log_fast_ms = now;
}
if (should_log(MASK_LOG_ATTITUDE_FAST | MASK_LOG_ATTITUDE_FULLRATE)) {
// MASK_LOG_ATTITUDE_FULLRATE logs at 400Hz, MASK_LOG_ATTITUDE_FAST at 25Hz, MASK_LOG_ATTIUDE_MED logs at 10Hz
// highest rate selected wins
if (should_log(MASK_LOG_ATTITUDE_FULLRATE)) {
Log_Write_Attitude();
}
}
Expand Down
6 changes: 3 additions & 3 deletions ArduPlane/Plane.h
Original file line number Diff line number Diff line change
Expand Up @@ -868,7 +868,7 @@ class Plane : public AP_Vehicle {
// Log.cpp
uint32_t last_log_fast_ms;

void Log_Write_Fast(void);
void Log_Write_FullRate(void);
void Log_Write_Attitude(void);
void Log_Write_Control_Tuning();
void Log_Write_OFG_Guided();
Expand Down Expand Up @@ -1006,8 +1006,8 @@ class Plane : public AP_Vehicle {
void airspeed_ratio_update(void);
#endif
void compass_save(void);
void update_logging1(void);
void update_logging2(void);
void update_logging10(void);
void update_logging25(void);
void update_control_mode(void);
void update_fly_forward(void);
void update_flight_stage();
Expand Down

0 comments on commit fcf2953

Please sign in to comment.