mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-22 15:53:33 +08:00
LPE flow improvements.
This commit is contained in:
committed by
James Goppert
parent
db44129ec0
commit
cf658638f4
@@ -8,7 +8,7 @@ extern orb_advert_t mavlink_log_pub;
|
||||
// required number of samples for sensor
|
||||
// to initialize
|
||||
static const uint32_t REQ_FLOW_INIT_COUNT = 10;
|
||||
static const uint32_t FLOW_TIMEOUT = 1000000; // 1 s
|
||||
static const uint32_t FLOW_TIMEOUT = 1000000; // 1 s
|
||||
|
||||
// minimum flow altitude
|
||||
static const float flow_min_agl = 0.05;
|
||||
@@ -67,8 +67,9 @@ int BlockLocalPositionEstimator::flowMeasure(Vector<float, n_y_flow> &y)
|
||||
float d = agl() * cosf(_sub_att.get().roll) * cosf(_sub_att.get().pitch);
|
||||
|
||||
// optical flow in x, y axis
|
||||
float flow_x_rad = _sub_flow.get().pixel_flow_x_integral;
|
||||
float flow_y_rad = _sub_flow.get().pixel_flow_y_integral;
|
||||
// TODO consider making flow scale a states of the kalman filter
|
||||
float flow_x_rad = _sub_flow.get().pixel_flow_x_integral * _flow_scale.get();
|
||||
float flow_y_rad = _sub_flow.get().pixel_flow_y_integral * _flow_scale.get();
|
||||
float dt_flow = _sub_flow.get().integration_timespan / 1.0e6f;
|
||||
|
||||
if (dt_flow > 0.5f || dt_flow < 1.0e-6f) {
|
||||
@@ -127,13 +128,38 @@ void BlockLocalPositionEstimator::flowCorrect()
|
||||
|
||||
SquareMatrix<float, n_y_flow> R;
|
||||
R.setZero();
|
||||
float d = agl() * cosf(_sub_att.get().roll) * cosf(_sub_att.get().pitch);
|
||||
float rot_rate_norm = sqrtf(_sub_att.get().rollspeed * _sub_att.get().rollspeed
|
||||
+ _sub_att.get().pitchspeed * _sub_att.get().pitchspeed
|
||||
+ _sub_att.get().yawspeed * _sub_att.get().yawspeed);
|
||||
float flow_vxy_stddev = _flow_vxy_stddev.get()
|
||||
+ _flow_vxy_d_stddev.get() * d
|
||||
+ _flow_vxy_r_stddev.get() * rot_rate_norm;
|
||||
|
||||
// polynomial noise model, found using least squares fit
|
||||
// h, h**2, v, v*h, v*h**2
|
||||
const float p[5] = {0.04005232f, -0.00656446f, -0.26265873f, 0.13686658f, -0.00397357f};
|
||||
|
||||
// prevent extrapolation past end of polynomial fit by bounding independent variables
|
||||
float h = agl();
|
||||
float v = y.norm();
|
||||
const float h_min = 2.0f;
|
||||
const float h_max = 8.0f;
|
||||
const float v_min = 0.5f;
|
||||
const float v_max = 1.0f;
|
||||
|
||||
if (h > h_max) {
|
||||
h = h_max;
|
||||
}
|
||||
|
||||
if (h < h_min) {
|
||||
h = h_min;
|
||||
}
|
||||
|
||||
if (v > v_max) {
|
||||
v = v_max;
|
||||
}
|
||||
|
||||
if (v < v_min) {
|
||||
v = v_min;
|
||||
}
|
||||
|
||||
// compute polynomial value
|
||||
float flow_vxy_stddev = p[0] * h + p[1] * h * h + p[2] * v + p[3] * v * h + p[4] * v * h * h;
|
||||
|
||||
R(Y_flow_vx, Y_flow_vx) = flow_vxy_stddev * flow_vxy_stddev;
|
||||
R(Y_flow_vy, Y_flow_vy) = R(Y_flow_vx, Y_flow_vx);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user