|
|
@ -34,7 +34,7 @@ using namespace Eigen; |
|
|
|
#include <uORB/Publication.hpp> |
|
|
|
#include <uORB/Publication.hpp> |
|
|
|
#include <uORB/topics/vehicle_local_position.h> |
|
|
|
#include <uORB/topics/vehicle_local_position.h> |
|
|
|
#include <uORB/topics/vehicle_global_position.h> |
|
|
|
#include <uORB/topics/vehicle_global_position.h> |
|
|
|
#include <uORB/topics/filtered_bottom_flow.h> |
|
|
|
//#include <uORB/topics/filtered_bottom_flow.h>
|
|
|
|
#include <uORB/topics/estimator_status.h> |
|
|
|
#include <uORB/topics/estimator_status.h> |
|
|
|
|
|
|
|
|
|
|
|
#define CBRK_NO_VISION_KEY 328754 |
|
|
|
#define CBRK_NO_VISION_KEY 328754 |
|
|
@ -108,6 +108,19 @@ class BlockLocalPositionEstimator : public control::SuperBlock |
|
|
|
// mocap: px, py, pz
|
|
|
|
// mocap: px, py, pz
|
|
|
|
//
|
|
|
|
//
|
|
|
|
public: |
|
|
|
public: |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// constants
|
|
|
|
|
|
|
|
enum {X_x = 0, X_y, X_z, X_vx, X_vy, X_vz, X_bx, X_by, X_bz, X_tz, n_x}; |
|
|
|
|
|
|
|
enum {U_ax = 0, U_ay, U_az, n_u}; |
|
|
|
|
|
|
|
enum {Y_baro_z = 0, n_y_baro}; |
|
|
|
|
|
|
|
enum {Y_lidar_z = 0, n_y_lidar}; |
|
|
|
|
|
|
|
enum {Y_flow_x = 0, Y_flow_y, n_y_flow}; |
|
|
|
|
|
|
|
enum {Y_sonar_z = 0, n_y_sonar}; |
|
|
|
|
|
|
|
enum {Y_gps_x = 0, Y_gps_y, Y_gps_z, Y_gps_vx, Y_gps_vy, Y_gps_vz, n_y_gps}; |
|
|
|
|
|
|
|
enum {Y_vision_x = 0, Y_vision_y, Y_vision_z, n_y_vision}; |
|
|
|
|
|
|
|
enum {Y_mocap_x = 0, Y_mocap_y, Y_mocap_z, n_y_mocap}; |
|
|
|
|
|
|
|
enum {POLL_FLOW, POLL_SENSORS, POLL_PARAM, n_poll}; |
|
|
|
|
|
|
|
|
|
|
|
BlockLocalPositionEstimator(); |
|
|
|
BlockLocalPositionEstimator(); |
|
|
|
void update(); |
|
|
|
void update(); |
|
|
|
virtual ~BlockLocalPositionEstimator(); |
|
|
|
virtual ~BlockLocalPositionEstimator(); |
|
|
@ -117,27 +130,6 @@ private: |
|
|
|
BlockLocalPositionEstimator(const BlockLocalPositionEstimator &); |
|
|
|
BlockLocalPositionEstimator(const BlockLocalPositionEstimator &); |
|
|
|
BlockLocalPositionEstimator operator=(const BlockLocalPositionEstimator &); |
|
|
|
BlockLocalPositionEstimator operator=(const BlockLocalPositionEstimator &); |
|
|
|
|
|
|
|
|
|
|
|
// constants
|
|
|
|
|
|
|
|
static const uint8_t n_x = 9; |
|
|
|
|
|
|
|
static const uint8_t n_u = 3; // 3 accelerations
|
|
|
|
|
|
|
|
static const uint8_t n_y_flow = 2; |
|
|
|
|
|
|
|
static const uint8_t n_y_sonar = 1; |
|
|
|
|
|
|
|
static const uint8_t n_y_baro = 1; |
|
|
|
|
|
|
|
static const uint8_t n_y_lidar = 1; |
|
|
|
|
|
|
|
static const uint8_t n_y_gps = 6; |
|
|
|
|
|
|
|
static const uint8_t n_y_vision = 3; |
|
|
|
|
|
|
|
static const uint8_t n_y_mocap = 3; |
|
|
|
|
|
|
|
enum {X_x = 0, X_y, X_z, X_vx, X_vy, X_vz, X_bx, X_by, X_bz}; |
|
|
|
|
|
|
|
enum {U_ax = 0, U_ay, U_az}; |
|
|
|
|
|
|
|
enum {Y_baro_z = 0}; |
|
|
|
|
|
|
|
enum {Y_lidar_z = 0}; |
|
|
|
|
|
|
|
enum {Y_flow_x = 0, Y_flow_y}; |
|
|
|
|
|
|
|
enum {Y_sonar_z = 0}; |
|
|
|
|
|
|
|
enum {Y_gps_x = 0, Y_gps_y, Y_gps_z, Y_gps_vx, Y_gps_vy, Y_gps_vz}; |
|
|
|
|
|
|
|
enum {Y_vision_x = 0, Y_vision_y, Y_vision_z, Y_vision_vx, Y_vision_vy, Y_vision_vz}; |
|
|
|
|
|
|
|
enum {Y_mocap_x = 0, Y_mocap_y, Y_mocap_z}; |
|
|
|
|
|
|
|
enum {POLL_FLOW, POLL_SENSORS, POLL_PARAM}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// methods
|
|
|
|
// methods
|
|
|
|
// ----------------------------
|
|
|
|
// ----------------------------
|
|
|
|
void initP(); |
|
|
|
void initP(); |
|
|
@ -152,7 +144,10 @@ private: |
|
|
|
void correctFlow(); |
|
|
|
void correctFlow(); |
|
|
|
void correctSonar(); |
|
|
|
void correctSonar(); |
|
|
|
void correctVision(); |
|
|
|
void correctVision(); |
|
|
|
void correctmocap(); |
|
|
|
void correctMocap(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// sensor timeout checks
|
|
|
|
|
|
|
|
void checkTimeouts(); |
|
|
|
|
|
|
|
|
|
|
|
// sensor initialization
|
|
|
|
// sensor initialization
|
|
|
|
void updateHome(); |
|
|
|
void updateHome(); |
|
|
@ -162,12 +157,12 @@ private: |
|
|
|
void initSonar(); |
|
|
|
void initSonar(); |
|
|
|
void initFlow(); |
|
|
|
void initFlow(); |
|
|
|
void initVision(); |
|
|
|
void initVision(); |
|
|
|
void initmocap(); |
|
|
|
void initMocap(); |
|
|
|
|
|
|
|
|
|
|
|
// publications
|
|
|
|
// publications
|
|
|
|
void publishLocalPos(); |
|
|
|
void publishLocalPos(); |
|
|
|
void publishGlobalPos(); |
|
|
|
void publishGlobalPos(); |
|
|
|
void publishFilteredFlow(); |
|
|
|
//void publishFilteredFlow();
|
|
|
|
void publishEstimatorStatus(); |
|
|
|
void publishEstimatorStatus(); |
|
|
|
|
|
|
|
|
|
|
|
// attributes
|
|
|
|
// attributes
|
|
|
@ -181,60 +176,90 @@ private: |
|
|
|
uORB::Subscription<vehicle_attitude_setpoint_s> _sub_att_sp; |
|
|
|
uORB::Subscription<vehicle_attitude_setpoint_s> _sub_att_sp; |
|
|
|
uORB::Subscription<optical_flow_s> _sub_flow; |
|
|
|
uORB::Subscription<optical_flow_s> _sub_flow; |
|
|
|
uORB::Subscription<sensor_combined_s> _sub_sensor; |
|
|
|
uORB::Subscription<sensor_combined_s> _sub_sensor; |
|
|
|
uORB::Subscription<distance_sensor_s> _sub_distance; |
|
|
|
|
|
|
|
uORB::Subscription<parameter_update_s> _sub_param_update; |
|
|
|
uORB::Subscription<parameter_update_s> _sub_param_update; |
|
|
|
uORB::Subscription<manual_control_setpoint_s> _sub_manual; |
|
|
|
uORB::Subscription<manual_control_setpoint_s> _sub_manual; |
|
|
|
uORB::Subscription<home_position_s> _sub_home; |
|
|
|
uORB::Subscription<home_position_s> _sub_home; |
|
|
|
uORB::Subscription<vehicle_gps_position_s> _sub_gps; |
|
|
|
uORB::Subscription<vehicle_gps_position_s> _sub_gps; |
|
|
|
uORB::Subscription<vision_position_estimate_s> _sub_vision_pos; |
|
|
|
uORB::Subscription<vision_position_estimate_s> _sub_vision_pos; |
|
|
|
uORB::Subscription<att_pos_mocap_s> _sub_mocap; |
|
|
|
uORB::Subscription<att_pos_mocap_s> _sub_mocap; |
|
|
|
|
|
|
|
uORB::Subscription<distance_sensor_s> *_distance_subs[ORB_MULTI_MAX_INSTANCES]; |
|
|
|
|
|
|
|
uORB::Subscription<distance_sensor_s> *_sub_lidar; |
|
|
|
|
|
|
|
uORB::Subscription<distance_sensor_s> *_sub_sonar; |
|
|
|
|
|
|
|
|
|
|
|
// publications
|
|
|
|
// publications
|
|
|
|
uORB::Publication<vehicle_local_position_s> _pub_lpos; |
|
|
|
uORB::Publication<vehicle_local_position_s> _pub_lpos; |
|
|
|
uORB::Publication<vehicle_global_position_s> _pub_gpos; |
|
|
|
uORB::Publication<vehicle_global_position_s> _pub_gpos; |
|
|
|
uORB::Publication<filtered_bottom_flow_s> _pub_filtered_flow; |
|
|
|
//uORB::Publication<filtered_bottom_flow_s> _pub_filtered_flow;
|
|
|
|
uORB::Publication<estimator_status_s> _pub_est_status; |
|
|
|
uORB::Publication<estimator_status_s> _pub_est_status; |
|
|
|
|
|
|
|
|
|
|
|
// map projection
|
|
|
|
// map projection
|
|
|
|
struct map_projection_reference_s _map_ref; |
|
|
|
struct map_projection_reference_s _map_ref; |
|
|
|
|
|
|
|
|
|
|
|
// parameters
|
|
|
|
// general parameters
|
|
|
|
BlockParamInt _integrate; |
|
|
|
BlockParamInt _integrate; |
|
|
|
|
|
|
|
|
|
|
|
BlockParamFloat _flow_xy_stddev; |
|
|
|
// sonar parameters
|
|
|
|
BlockParamFloat _sonar_z_stddev; |
|
|
|
BlockParamFloat _sonar_z_stddev; |
|
|
|
|
|
|
|
BlockParamFloat _sonar_z_offset; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// lidar parameters
|
|
|
|
BlockParamFloat _lidar_z_stddev; |
|
|
|
BlockParamFloat _lidar_z_stddev; |
|
|
|
|
|
|
|
BlockParamFloat _lidar_z_offset; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// accel parameters
|
|
|
|
BlockParamFloat _accel_xy_stddev; |
|
|
|
BlockParamFloat _accel_xy_stddev; |
|
|
|
BlockParamFloat _accel_z_stddev; |
|
|
|
BlockParamFloat _accel_z_stddev; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// baro parameters
|
|
|
|
BlockParamFloat _baro_stddev; |
|
|
|
BlockParamFloat _baro_stddev; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// gps parameters
|
|
|
|
BlockParamFloat _gps_xy_stddev; |
|
|
|
BlockParamFloat _gps_xy_stddev; |
|
|
|
BlockParamFloat _gps_z_stddev; |
|
|
|
BlockParamFloat _gps_z_stddev; |
|
|
|
|
|
|
|
|
|
|
|
BlockParamFloat _gps_vxy_stddev; |
|
|
|
BlockParamFloat _gps_vxy_stddev; |
|
|
|
BlockParamFloat _gps_vz_stddev; |
|
|
|
BlockParamFloat _gps_vz_stddev; |
|
|
|
|
|
|
|
|
|
|
|
BlockParamFloat _gps_eph_max; |
|
|
|
BlockParamFloat _gps_eph_max; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// vision parameters
|
|
|
|
BlockParamFloat _vision_xy_stddev; |
|
|
|
BlockParamFloat _vision_xy_stddev; |
|
|
|
BlockParamFloat _vision_z_stddev; |
|
|
|
BlockParamFloat _vision_z_stddev; |
|
|
|
BlockParamInt _no_vision; |
|
|
|
BlockParamInt _no_vision; |
|
|
|
BlockParamFloat _beta_max; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// mocap parameters
|
|
|
|
BlockParamFloat _mocap_p_stddev; |
|
|
|
BlockParamFloat _mocap_p_stddev; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// flow parameters
|
|
|
|
|
|
|
|
BlockParamFloat _flow_z_offset; |
|
|
|
|
|
|
|
BlockParamFloat _flow_xy_stddev; |
|
|
|
|
|
|
|
//BlockParamFloat _flow_board_x_offs;
|
|
|
|
|
|
|
|
//BlockParamFloat _flow_board_y_offs;
|
|
|
|
|
|
|
|
BlockParamInt _flow_min_q; |
|
|
|
|
|
|
|
|
|
|
|
// process noise
|
|
|
|
// process noise
|
|
|
|
BlockParamFloat _pn_p_noise_power; |
|
|
|
BlockParamFloat _pn_p_noise_power; |
|
|
|
BlockParamFloat _pn_v_noise_power; |
|
|
|
BlockParamFloat _pn_v_noise_power; |
|
|
|
BlockParamFloat _pn_b_noise_power; |
|
|
|
BlockParamFloat _pn_b_noise_power; |
|
|
|
|
|
|
|
BlockParamFloat _pn_t_noise_power; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// flow gyro filter
|
|
|
|
|
|
|
|
BlockHighPass _flow_gyro_x_high_pass; |
|
|
|
|
|
|
|
BlockHighPass _flow_gyro_y_high_pass; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// stats
|
|
|
|
|
|
|
|
BlockStats<float, 1> _baroStats; |
|
|
|
|
|
|
|
BlockStats<float, 1> _sonarStats; |
|
|
|
|
|
|
|
BlockStats<float, 1> _lidarStats; |
|
|
|
|
|
|
|
BlockStats<float, 1> _flowQStats; |
|
|
|
|
|
|
|
BlockStats<float, 3> _visionStats; |
|
|
|
|
|
|
|
BlockStats<float, 3> _mocapStats; |
|
|
|
|
|
|
|
BlockStats<double, 3> _gpsStats; |
|
|
|
|
|
|
|
|
|
|
|
// misc
|
|
|
|
// misc
|
|
|
|
struct pollfd _polls[3]; |
|
|
|
struct pollfd _polls[3]; |
|
|
|
uint64_t _timeStamp; |
|
|
|
uint64_t _timeStamp; |
|
|
|
uint64_t _time_last_xy; |
|
|
|
uint64_t _time_last_xy; |
|
|
|
|
|
|
|
uint64_t _time_last_z; |
|
|
|
|
|
|
|
uint64_t _time_last_tz; |
|
|
|
uint64_t _time_last_flow; |
|
|
|
uint64_t _time_last_flow; |
|
|
|
uint64_t _time_last_baro; |
|
|
|
uint64_t _time_last_baro; |
|
|
|
uint64_t _time_last_gps; |
|
|
|
uint64_t _time_last_gps; |
|
|
@ -253,23 +278,11 @@ private: |
|
|
|
bool _visionInitialized; |
|
|
|
bool _visionInitialized; |
|
|
|
bool _mocapInitialized; |
|
|
|
bool _mocapInitialized; |
|
|
|
|
|
|
|
|
|
|
|
// init counts
|
|
|
|
|
|
|
|
int _baroInitCount; |
|
|
|
|
|
|
|
int _gpsInitCount; |
|
|
|
|
|
|
|
int _lidarInitCount; |
|
|
|
|
|
|
|
int _sonarInitCount; |
|
|
|
|
|
|
|
int _flowInitCount; |
|
|
|
|
|
|
|
int _visionInitCount; |
|
|
|
|
|
|
|
int _mocapInitCount; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// reference altitudes
|
|
|
|
// reference altitudes
|
|
|
|
float _altHome; |
|
|
|
float _altHome; |
|
|
|
bool _altHomeInitialized; |
|
|
|
bool _altHomeInitialized; |
|
|
|
float _baroAltHome; |
|
|
|
float _baroAltHome; |
|
|
|
float _gpsAltHome; |
|
|
|
float _gpsAltHome; |
|
|
|
float _lidarAltHome; |
|
|
|
|
|
|
|
float _sonarAltHome; |
|
|
|
|
|
|
|
float _flowAltHome; |
|
|
|
|
|
|
|
Vector3f _visionHome; |
|
|
|
Vector3f _visionHome; |
|
|
|
Vector3f _mocapHome; |
|
|
|
Vector3f _mocapHome; |
|
|
|
|
|
|
|
|
|
|
@ -285,7 +298,10 @@ private: |
|
|
|
// status
|
|
|
|
// status
|
|
|
|
bool _canEstimateXY; |
|
|
|
bool _canEstimateXY; |
|
|
|
bool _canEstimateZ; |
|
|
|
bool _canEstimateZ; |
|
|
|
|
|
|
|
bool _canEstimateT; |
|
|
|
bool _xyTimeout; |
|
|
|
bool _xyTimeout; |
|
|
|
|
|
|
|
bool _zTimeout; |
|
|
|
|
|
|
|
bool _tzTimeout; |
|
|
|
|
|
|
|
|
|
|
|
// sensor faults
|
|
|
|
// sensor faults
|
|
|
|
fault_t _baroFault; |
|
|
|
fault_t _baroFault; |
|
|
@ -296,9 +312,7 @@ private: |
|
|
|
fault_t _visionFault; |
|
|
|
fault_t _visionFault; |
|
|
|
fault_t _mocapFault; |
|
|
|
fault_t _mocapFault; |
|
|
|
|
|
|
|
|
|
|
|
bool _visionTimeout; |
|
|
|
// performance counters
|
|
|
|
bool _mocapTimeout; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
perf_counter_t _loop_perf; |
|
|
|
perf_counter_t _loop_perf; |
|
|
|
perf_counter_t _interval_perf; |
|
|
|
perf_counter_t _interval_perf; |
|
|
|
perf_counter_t _err_perf; |
|
|
|
perf_counter_t _err_perf; |
|
|
|