mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-07-01 12:30:35 +08:00
added px4flow integral frame, adjusted px4flow i2c driver, adjusted postition_estimator_inav
This commit is contained in:
@@ -298,7 +298,7 @@ int position_estimator_inav_thread_main(int argc, char *argv[])
|
||||
float w_flow = 0.0f;
|
||||
|
||||
float sonar_prev = 0.0f;
|
||||
hrt_abstime flow_prev = 0; // time of last flow measurement
|
||||
//hrt_abstime flow_prev = 0; // time of last flow measurement
|
||||
hrt_abstime sonar_time = 0; // time of last sonar measurement (not filtered)
|
||||
hrt_abstime sonar_valid_time = 0; // time of last sonar measurement used for correction (filtered)
|
||||
|
||||
@@ -491,8 +491,8 @@ int position_estimator_inav_thread_main(int argc, char *argv[])
|
||||
orb_copy(ORB_ID(optical_flow), optical_flow_sub, &flow);
|
||||
|
||||
/* calculate time from previous update */
|
||||
float flow_dt = flow_prev > 0 ? (flow.flow_timestamp - flow_prev) * 1e-6f : 0.1f;
|
||||
flow_prev = flow.flow_timestamp;
|
||||
// float flow_dt = flow_prev > 0 ? (flow.flow_timestamp - flow_prev) * 1e-6f : 0.1f;
|
||||
// flow_prev = flow.flow_timestamp;
|
||||
|
||||
if ((flow.ground_distance_m > 0.31f) &&
|
||||
(flow.ground_distance_m < 4.0f) &&
|
||||
@@ -550,8 +550,9 @@ int position_estimator_inav_thread_main(int argc, char *argv[])
|
||||
|
||||
/* convert raw flow to angular flow (rad/s) */
|
||||
float flow_ang[2];
|
||||
flow_ang[0] = flow.flow_raw_x * params.flow_k / 1000.0f / flow_dt;
|
||||
flow_ang[1] = flow.flow_raw_y * params.flow_k / 1000.0f / flow_dt;
|
||||
//todo check direction of x und y axis
|
||||
flow_ang[0] = flow.pixel_flow_x_integral/(float)flow.integration_timespan*1000000.0f;//flow.flow_raw_x * params.flow_k / 1000.0f / flow_dt;
|
||||
flow_ang[1] = flow.pixel_flow_y_integral/(float)flow.integration_timespan*1000000.0f;//flow.flow_raw_y * params.flow_k / 1000.0f / flow_dt;
|
||||
/* flow measurements vector */
|
||||
float flow_m[3];
|
||||
flow_m[0] = -flow_ang[0] * flow_dist;
|
||||
|
||||
@@ -55,16 +55,21 @@
|
||||
*/
|
||||
struct optical_flow_s {
|
||||
|
||||
uint64_t timestamp; /**< in microseconds since system start */
|
||||
|
||||
uint64_t flow_timestamp; /**< timestamp from flow sensor */
|
||||
int16_t flow_raw_x; /**< flow in pixels in X direction, not rotation-compensated */
|
||||
int16_t flow_raw_y; /**< flow in pixels in Y direction, not rotation-compensated */
|
||||
float flow_comp_x_m; /**< speed over ground in meters, rotation-compensated */
|
||||
float flow_comp_y_m; /**< speed over ground in meters, rotation-compensated */
|
||||
float ground_distance_m; /**< Altitude / distance to ground in meters */
|
||||
uint8_t quality; /**< Quality of the measurement, 0: bad quality, 255: maximum quality */
|
||||
uint64_t timestamp; /**< in microseconds since system start */
|
||||
uint8_t sensor_id; /**< id of the sensor emitting the flow value */
|
||||
float pixel_flow_x_integral; /**< accumulated optical flow in radians around x axis */
|
||||
float pixel_flow_y_integral; /**< accumulated optical flow in radians around y axis */
|
||||
float gyro_x_rate_integral; /**< accumulated gyro value in radians around x axis */
|
||||
float gyro_y_rate_integral; /**< accumulated gyro value in radians around y axis */
|
||||
float gyro_z_rate_integral; /**< accumulated gyro value in radians around z axis */
|
||||
float ground_distance_m; /**< Altitude / distance to ground in meters */
|
||||
uint32_t integration_timespan; /**<accumulation timespan in microseconds */
|
||||
uint32_t time_since_last_sonar_update;/**< time since last sonar update in microseconds */
|
||||
uint16_t frame_count_since_last_readout;/**< number of accumulated frames in timespan */
|
||||
uint8_t quality; /**< Average of quality of accumulated frames, 0: bad quality, 255: maximum quality */
|
||||
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user