mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-01-03 06:28:27 -04:00
AC_PID: 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.
This commit is contained in:
parent
66f0a0f42b
commit
e5e4dee708
@ -7,7 +7,6 @@
|
||||
#include <AP_Param/AP_Param.h>
|
||||
#include <stdlib.h>
|
||||
#include <cmath>
|
||||
#include <AP_Logger/AP_Logger.h>
|
||||
#include <Filter/SlewLimiter.h>
|
||||
|
||||
#define AC_PID_TFILT_HZ_DEFAULT 0.0f // default input filter frequency
|
||||
@ -15,6 +14,8 @@
|
||||
#define AC_PID_DFILT_HZ_DEFAULT 20.0f // default input filter frequency
|
||||
#define AC_PID_RESET_TC 0.16f // Time constant for integrator reset decay to zero
|
||||
|
||||
#include "AP_PIDInfo.h"
|
||||
|
||||
/// @class AC_PID
|
||||
/// @brief Copter PID control class
|
||||
class AC_PID {
|
||||
@ -116,7 +117,7 @@ public:
|
||||
// return current slew rate of slew limiter. Will return 0 if SMAX is zero
|
||||
float get_slew_rate(void) const { return _slew_limiter.get_slew_rate(); }
|
||||
|
||||
const AP_Logger::PID_Info& get_pid_info(void) const { return _pid_info; }
|
||||
const AP_PIDInfo& get_pid_info(void) const { return _pid_info; }
|
||||
|
||||
// parameter var table
|
||||
static const struct AP_Param::GroupInfo var_info[];
|
||||
@ -155,5 +156,5 @@ protected:
|
||||
float _derivative; // derivative value to enable filtering
|
||||
int8_t _slew_limit_scale;
|
||||
|
||||
AP_Logger::PID_Info _pid_info;
|
||||
AP_PIDInfo _pid_info;
|
||||
};
|
||||
|
@ -7,7 +7,7 @@
|
||||
#include <AP_Param/AP_Param.h>
|
||||
#include <stdlib.h>
|
||||
#include <cmath>
|
||||
#include <AP_Logger/AP_Logger.h>
|
||||
#include <AC_PID/AP_PIDInfo.h>
|
||||
|
||||
/// @class AC_PID_2D
|
||||
/// @brief Copter PID control class
|
||||
@ -75,8 +75,8 @@ public:
|
||||
void set_integrator(const Vector3f& i) { set_integrator(Vector2f{i.x, i.y}); }
|
||||
void set_integrator(const Vector2f& i);
|
||||
|
||||
const AP_Logger::PID_Info& get_pid_info_x(void) const { return _pid_info_x; }
|
||||
const AP_Logger::PID_Info& get_pid_info_y(void) const { return _pid_info_y; }
|
||||
const AP_PIDInfo& get_pid_info_x(void) const { return _pid_info_x; }
|
||||
const AP_PIDInfo& get_pid_info_y(void) const { return _pid_info_y; }
|
||||
|
||||
// parameter var table
|
||||
static const struct AP_Param::GroupInfo var_info[];
|
||||
@ -100,6 +100,6 @@ protected:
|
||||
Vector2f _integrator; // integrator value
|
||||
bool _reset_filter; // true when input filter should be reset during next call to update_all
|
||||
|
||||
AP_Logger::PID_Info _pid_info_x;
|
||||
AP_Logger::PID_Info _pid_info_y;
|
||||
AP_PIDInfo _pid_info_x;
|
||||
AP_PIDInfo _pid_info_y;
|
||||
};
|
||||
|
@ -5,7 +5,7 @@
|
||||
|
||||
#include <AP_Common/AP_Common.h>
|
||||
#include <AP_Param/AP_Param.h>
|
||||
#include <AP_Logger/AP_Logger.h>
|
||||
#include "AP_PIDInfo.h"
|
||||
|
||||
/// @class AC_PID_Basic
|
||||
/// @brief Copter PID control class
|
||||
@ -70,7 +70,7 @@ public:
|
||||
void set_integrator(float error, float i);
|
||||
void set_integrator(float i);
|
||||
|
||||
const AP_Logger::PID_Info& get_pid_info(void) const WARN_IF_UNUSED { return _pid_info; }
|
||||
const AP_PIDInfo& get_pid_info(void) const WARN_IF_UNUSED { return _pid_info; }
|
||||
|
||||
// parameter var table
|
||||
static const struct AP_Param::GroupInfo var_info[];
|
||||
@ -94,5 +94,5 @@ protected:
|
||||
float _integrator; // integrator value
|
||||
bool _reset_filter; // true when input filter should be reset during next call to set_input
|
||||
|
||||
AP_Logger::PID_Info _pid_info;
|
||||
AP_PIDInfo _pid_info;
|
||||
};
|
||||
|
20
libraries/AC_PID/AP_PIDInfo.h
Normal file
20
libraries/AC_PID/AP_PIDInfo.h
Normal file
@ -0,0 +1,20 @@
|
||||
#pragma once
|
||||
|
||||
// This structure provides information on the internal member data of
|
||||
// a PID. It provides an abstract way to pass PID information around,
|
||||
// useful for logging and sending mavlink messages.
|
||||
|
||||
// It is also used to pass PID information into controllers...
|
||||
|
||||
struct AP_PIDInfo {
|
||||
float target;
|
||||
float actual;
|
||||
float error;
|
||||
float P;
|
||||
float I;
|
||||
float D;
|
||||
float FF;
|
||||
float Dmod;
|
||||
float slew_rate;
|
||||
bool limit;
|
||||
};
|
Loading…
Reference in New Issue
Block a user