mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-30 20:23:33 +08:00
EKF: use namespace for structure definitions
will be moved to a separate file in the future
This commit is contained in:
+94
-91
@@ -43,7 +43,7 @@
|
|||||||
#include <matrix/matrix/math.hpp>
|
#include <matrix/matrix/math.hpp>
|
||||||
#include <lib/geo/geo.h>
|
#include <lib/geo/geo.h>
|
||||||
#include "RingBuffer.h"
|
#include "RingBuffer.h"
|
||||||
|
namespace estimator {
|
||||||
struct gps_message {
|
struct gps_message {
|
||||||
uint64_t time_usec;
|
uint64_t time_usec;
|
||||||
int32_t lat; // Latitude in 1E-7 degrees
|
int32_t lat; // Latitude in 1E-7 degrees
|
||||||
@@ -61,6 +61,59 @@ struct gps_message {
|
|||||||
float gdop; // geometric dilution of precision
|
float gdop; // geometric dilution of precision
|
||||||
};
|
};
|
||||||
|
|
||||||
|
typedef matrix::Vector<float, 2> Vector2f;
|
||||||
|
typedef matrix::Vector<float, 3> Vector3f;
|
||||||
|
typedef matrix::Quaternion<float> Quaternion;
|
||||||
|
typedef matrix::Matrix<float, 3, 3> Matrix3f;
|
||||||
|
|
||||||
|
struct outputSample {
|
||||||
|
Quaternion quat_nominal;
|
||||||
|
Vector3f vel;
|
||||||
|
Vector3f pos;
|
||||||
|
uint64_t time_us;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct imuSample {
|
||||||
|
Vector3f delta_ang;
|
||||||
|
Vector3f delta_vel;
|
||||||
|
float delta_ang_dt;
|
||||||
|
float delta_vel_dt;
|
||||||
|
uint64_t time_us;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct gpsSample {
|
||||||
|
Vector2f pos;
|
||||||
|
float hgt;
|
||||||
|
Vector3f vel;
|
||||||
|
uint64_t time_us;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct magSample {
|
||||||
|
Vector3f mag;
|
||||||
|
uint64_t time_us;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct baroSample {
|
||||||
|
float hgt;
|
||||||
|
uint64_t time_us;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct rangeSample {
|
||||||
|
float rng;
|
||||||
|
uint64_t time_us;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct airspeedSample {
|
||||||
|
float airspeed;
|
||||||
|
uint64_t time_us;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct flowSample {
|
||||||
|
Vector2f flowRadXY;
|
||||||
|
Vector2f flowRadXYcomp;
|
||||||
|
uint64_t time_us;
|
||||||
|
};
|
||||||
|
|
||||||
struct parameters {
|
struct parameters {
|
||||||
float mag_delay_ms = 0.0f;
|
float mag_delay_ms = 0.0f;
|
||||||
float baro_delay_ms = 0.0f;
|
float baro_delay_ms = 0.0f;
|
||||||
@@ -102,9 +155,12 @@ struct parameters {
|
|||||||
float req_hdrift = 0.3f; // maximum acceptable horizontal drift speed
|
float req_hdrift = 0.3f; // maximum acceptable horizontal drift speed
|
||||||
float req_vdrift = 0.5f; // maximum acceptable vertical drift speed
|
float req_vdrift = 0.5f; // maximum acceptable vertical drift speed
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
using namespace estimator;
|
||||||
class EstimatorBase
|
class EstimatorBase
|
||||||
{
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
EstimatorBase();
|
EstimatorBase();
|
||||||
~EstimatorBase();
|
~EstimatorBase();
|
||||||
@@ -181,14 +237,45 @@ public:
|
|||||||
// set vehicle arm status data
|
// set vehicle arm status data
|
||||||
void set_arm_status(bool data){ _vehicle_armed = data; }
|
void set_arm_status(bool data){ _vehicle_armed = data; }
|
||||||
|
|
||||||
|
void printIMU(struct imuSample *data);
|
||||||
|
void printStoredIMU();
|
||||||
|
void printQuaternion(Quaternion &q);
|
||||||
|
void print_imu_avg_time();
|
||||||
|
void printMag(struct magSample *data);
|
||||||
|
void printStoredMag();
|
||||||
|
void printBaro(struct baroSample *data);
|
||||||
|
void printStoredBaro();
|
||||||
|
void printGps(struct gpsSample *data);
|
||||||
|
void printStoredGps();
|
||||||
|
|
||||||
|
bool position_is_valid();
|
||||||
|
|
||||||
|
|
||||||
|
void copy_quaternion(float *quat)
|
||||||
|
{
|
||||||
|
for (unsigned i = 0; i < 4; i++) {
|
||||||
|
quat[i] = _output_new.quat_nominal(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
void copy_velocity(float *vel)
|
||||||
|
{
|
||||||
|
for (unsigned i = 0; i < 3; i++) {
|
||||||
|
vel[i] = _output_new.vel(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
void copy_position(float *pos)
|
||||||
|
{
|
||||||
|
for (unsigned i = 0; i < 3; i++) {
|
||||||
|
pos[i] = _output_new.pos(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
void copy_timestamp(uint64_t *time_us)
|
||||||
|
{
|
||||||
|
*time_us = _imu_time_last;
|
||||||
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
typedef matrix::Vector<float, 2> Vector2f;
|
|
||||||
typedef matrix::Vector<float, 3> Vector3f;
|
|
||||||
typedef matrix::Quaternion<float> Quaternion;
|
|
||||||
typedef matrix::Matrix<float, 3, 3> Matrix3f;
|
|
||||||
|
|
||||||
struct stateSample {
|
struct stateSample {
|
||||||
Vector3f ang_error;
|
Vector3f ang_error;
|
||||||
Vector3f vel;
|
Vector3f vel;
|
||||||
@@ -202,54 +289,6 @@ protected:
|
|||||||
Quaternion quat_nominal;
|
Quaternion quat_nominal;
|
||||||
} _state;
|
} _state;
|
||||||
|
|
||||||
struct outputSample {
|
|
||||||
Quaternion quat_nominal;
|
|
||||||
Vector3f vel;
|
|
||||||
Vector3f pos;
|
|
||||||
uint64_t time_us;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct imuSample {
|
|
||||||
Vector3f delta_ang;
|
|
||||||
Vector3f delta_vel;
|
|
||||||
float delta_ang_dt;
|
|
||||||
float delta_vel_dt;
|
|
||||||
uint64_t time_us;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct gpsSample {
|
|
||||||
Vector2f pos;
|
|
||||||
float hgt;
|
|
||||||
Vector3f vel;
|
|
||||||
uint64_t time_us;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct magSample {
|
|
||||||
Vector3f mag;
|
|
||||||
uint64_t time_us;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct baroSample {
|
|
||||||
float hgt;
|
|
||||||
uint64_t time_us;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct rangeSample {
|
|
||||||
float rng;
|
|
||||||
uint64_t time_us;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct airspeedSample {
|
|
||||||
float airspeed;
|
|
||||||
uint64_t time_us;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct flowSample {
|
|
||||||
Vector2f flowRadXY;
|
|
||||||
Vector2f flowRadXYcomp;
|
|
||||||
uint64_t time_us;
|
|
||||||
};
|
|
||||||
|
|
||||||
parameters _params; // filter parameters
|
parameters _params; // filter parameters
|
||||||
|
|
||||||
static const uint8_t OBS_BUFFER_LENGTH = 10;
|
static const uint8_t OBS_BUFFER_LENGTH = 10;
|
||||||
@@ -317,43 +356,7 @@ protected:
|
|||||||
} _fault_status;
|
} _fault_status;
|
||||||
|
|
||||||
void initialiseVariables(uint64_t timestamp);
|
void initialiseVariables(uint64_t timestamp);
|
||||||
|
|
||||||
public:
|
|
||||||
void printIMU(struct imuSample *data);
|
|
||||||
void printStoredIMU();
|
|
||||||
void printQuaternion(Quaternion &q);
|
|
||||||
void print_imu_avg_time();
|
|
||||||
void printMag(struct magSample *data);
|
|
||||||
void printStoredMag();
|
|
||||||
void printBaro(struct baroSample *data);
|
|
||||||
void printStoredBaro();
|
|
||||||
void printGps(struct gpsSample *data);
|
|
||||||
void printStoredGps();
|
|
||||||
|
|
||||||
bool position_is_valid();
|
|
||||||
|
|
||||||
void copy_quaternion(float *quat)
|
|
||||||
{
|
|
||||||
for (unsigned i = 0; i < 4; i++) {
|
|
||||||
quat[i] = _output_new.quat_nominal(i);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
void copy_velocity(float *vel)
|
|
||||||
{
|
|
||||||
for (unsigned i = 0; i < 3; i++) {
|
|
||||||
vel[i] = _output_new.vel(i);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
void copy_position(float *pos)
|
|
||||||
{
|
|
||||||
for (unsigned i = 0; i < 3; i++) {
|
|
||||||
pos[i] = _output_new.pos(i);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
void copy_timestamp(uint64_t *time_us)
|
|
||||||
{
|
|
||||||
*time_us = _imu_time_last;
|
|
||||||
}
|
|
||||||
bool _vehicle_armed = false; // vehicle arm status used to turn off funtionality used on the ground
|
bool _vehicle_armed = false; // vehicle arm status used to turn off funtionality used on the ground
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user