From 0c32eeca2e6763a09d4aa473f2bc7a8fb33f4a47 Mon Sep 17 00:00:00 2001 From: Peter Barker Date: Fri, 4 Mar 2022 14:29:47 +1100 Subject: [PATCH] AP_Logger: stop libraries including AP_Logger.h in .h files AP_Logger.h is a nexus of includes; while this is being improved over time, there's no reason for the library headers to include AP_Logger.h as the logger itself is access by singleton and the structures are in LogStructure.h This necessitated moving The PID_Info structure out of AP_Logger's namespace. This cleans up a pretty nasty bit - that structure is definitely not simply used for logging, but also used to pass pid information around to controllers! There are a lot of patches in here because AP_Logger.h, acting as a nexus, was providing transitive header file inclusion in many (some unlikely!) places. --- libraries/AP_Logger/AP_Logger.h | 17 ++--------------- libraries/AP_Logger/LogFile.cpp | 2 +- 2 files changed, 3 insertions(+), 16 deletions(-) diff --git a/libraries/AP_Logger/AP_Logger.h b/libraries/AP_Logger/AP_Logger.h index 4a509347a7..1f826233d0 100644 --- a/libraries/AP_Logger/AP_Logger.h +++ b/libraries/AP_Logger/AP_Logger.h @@ -48,6 +48,7 @@ #define HAL_LOGGER_FILE_CONTENTS_ENABLED HAL_LOGGING_FILESYSTEM_ENABLED #endif +#include #include #include #include @@ -326,21 +327,7 @@ public: void WriteCritical(const char *name, const char *labels, const char *units, const char *mults, const char *fmt, ...); void WriteV(const char *name, const char *labels, const char *units, const char *mults, const char *fmt, va_list arg_list, bool is_critical=false, bool is_streaming=false); - // This structure provides information on the internal member data of a PID for logging purposes - struct PID_Info { - float target; - float actual; - float error; - float P; - float I; - float D; - float FF; - float Dmod; - float slew_rate; - bool limit; - }; - - void Write_PID(uint8_t msg_type, const PID_Info &info); + void Write_PID(uint8_t msg_type, const AP_PIDInfo &info); // returns true if logging of a message should be attempted bool should_log(uint32_t mask) const; diff --git a/libraries/AP_Logger/LogFile.cpp b/libraries/AP_Logger/LogFile.cpp index 7c0c5d78cb..c52410ca47 100644 --- a/libraries/AP_Logger/LogFile.cpp +++ b/libraries/AP_Logger/LogFile.cpp @@ -407,7 +407,7 @@ void AP_Logger::Write_ServoStatus(uint64_t time_us, uint8_t id, float position, // Write a Yaw PID packet -void AP_Logger::Write_PID(uint8_t msg_type, const PID_Info &info) +void AP_Logger::Write_PID(uint8_t msg_type, const AP_PIDInfo &info) { const struct log_PID pkt{ LOG_PACKET_HEADER_INIT(msg_type),