46 #include <drivers/drv_mag.h> 52 #include <lib/ecl/validation/data_validator.h> 53 #include <lib/ecl/validation/data_validator_group.h> 55 #include <uORB/topics/sensor_combined.h> 56 #include <uORB/topics/sensor_preflight.h> 57 #include <uORB/topics/sensor_correction.h> 58 #include <uORB/topics/sensor_selection.h> 59 #include <uORB/topics/vehicle_air_data.h> 60 #include <uORB/topics/vehicle_magnetometer.h> 61 #include <uORB/topics/subsystem_info.h> 89 int init(sensor_combined_s &raw);
112 void sensors_poll(sensor_combined_s &raw, vehicle_air_data_s &airdata, vehicle_magnetometer_s &magnetometer);
125 int num_gyros()
const {
return _gyro.subscription_count; }
126 int gyro_fd(
int idx)
const {
return _gyro.subscription[idx]; }
128 int best_gyro_fd()
const {
return _gyro.subscription[_gyro.last_best_vote]; }
150 subscription_count(0),
152 last_failover_count(0)
154 for (
unsigned i = 0; i < SENSOR_COUNT_MAX; i++) {
156 subscription[i] = -1;
161 bool enabled[SENSOR_COUNT_MAX];
163 int subscription[SENSOR_COUNT_MAX];
164 uint8_t priority[SENSOR_COUNT_MAX];
165 uint8_t last_best_vote;
166 int subscription_count;
167 DataValidatorGroup voter;
168 unsigned int last_failover_count;
171 void init_sensor_class(
const struct orb_metadata *meta, SensorData &sensor_data, uint8_t sensor_count_max);
179 void accel_poll(
struct sensor_combined_s &raw);
187 void gyro_poll(
struct sensor_combined_s &raw);
195 void mag_poll(vehicle_magnetometer_s &magnetometer);
203 void baro_poll(vehicle_air_data_s &airdata);
209 bool check_failover(SensorData &sensor,
const char *sensor_name,
const uint64_t type);
219 bool apply_gyro_calibration(DriverFramework::DevHandle &h,
const struct gyro_calibration_s *gcal,
const int device_id);
229 bool apply_accel_calibration(DriverFramework::DevHandle &h,
const struct accel_calibration_s *acal,
230 const int device_id);
240 bool apply_mag_calibration(DriverFramework::DevHandle &h,
const struct mag_calibration_s *mcal,
const int device_id);
249 sensor_combined_s _last_sensor_data[SENSOR_COUNT_MAX];
250 vehicle_air_data_s _last_airdata[SENSOR_COUNT_MAX];
251 vehicle_magnetometer_s _last_magnetometer[SENSOR_COUNT_MAX];
253 uint64_t _last_accel_timestamp[ACCEL_COUNT_MAX];
255 matrix::Dcmf _board_rotation;
256 matrix::Dcmf _mag_rotation[MAG_COUNT_MAX];
259 const bool _hil_enabled;
261 float _accel_diff[3][2];
262 float _gyro_diff[3][2];
263 float _mag_diff[3][2];
267 struct sensor_correction_s _corrections;
269 bool _corrections_changed =
false;
272 struct sensor_selection_s _selection = {};
274 bool _selection_changed =
false;
277 struct subsystem_info_s _info;
280 uint32_t _accel_device_id[SENSOR_COUNT_MAX] = {};
281 uint32_t _baro_device_id[SENSOR_COUNT_MAX] = {};
282 uint32_t _gyro_device_id[SENSOR_COUNT_MAX] = {};
283 uint32_t _mag_device_id[SENSOR_COUNT_MAX] = {};
void sensors_poll(sensor_combined_s &raw, vehicle_air_data_s &airdata, vehicle_magnetometer_s &magnetometer)
read new sensor data
Definition: voted_sensors_update.cpp:1058
Accelerometer driver interface.
int init(sensor_combined_s &raw)
initialize subscriptions etc.
Definition: voted_sensors_update.cpp:92
Gyroscope driver interface.
gyro scaling factors; Vout = (Vin * Vscale) + Voffset
Definition: drv_gyro.h:54
void set_relative_timestamps(sensor_combined_s &raw)
set the relative timestamps of each sensor timestamp, based on the last sensors_poll, so that the data can be published.
Definition: voted_sensors_update.cpp:1103
void calc_gyro_inconsistency(sensor_preflight_s &preflt)
Calculates the magnitude in rad/s of the largest difference between the primary and any other gyro se...
Definition: voted_sensors_update.cpp:1161
void deinit()
deinitialize the object (we cannot use the destructor because it is called on the wrong thread) ...
Definition: voted_sensors_update.cpp:113
void check_failover()
check if a failover event occured.
Definition: voted_sensors_update.cpp:1095
void parameters_update()
call this whenever parameters got updated.
Definition: voted_sensors_update.cpp:132
mag scaling factors; Vout = (Vin * Vscale) + Voffset
Definition: drv_mag.h:56
__BEGIN_DECLS typedef void * orb_advert_t
ORB topic advertiser handle.
Definition: uORB.h:134
High-resolution timer with callouts and timekeeping.
accel scaling factors; Vout = Vscale * (Vin + Voffset)
Definition: drv_accel.h:54
Definition: parameters.h:58
Sensor correction methods.
void calc_accel_inconsistency(sensor_preflight_s &preflt)
Calculates the magnitude in m/s/s of the largest difference between the primary and any other accel s...
Definition: voted_sensors_update.cpp:1112
void initialize_sensors()
This tries to find new sensor instances.
Definition: voted_sensors_update.cpp:105
Common header for mathlib exports.
void calc_mag_inconsistency(sensor_preflight_s &preflt)
Calculates the magnitude in Gauss of the largest difference between the primary and any other magneto...
Definition: voted_sensors_update.cpp:1210
Barometric pressure sensor driver interface.
defines the list of parameters that are used within the sensors module
class TemperatureCompensation Applies temperature compensation to sensor data.
Definition: temperature_compensation.h:66
class VotedSensorsUpdate
Definition: voted_sensors_update.h:76
VotedSensorsUpdate(const Parameters ¶meters, bool hil_enabled)
Definition: voted_sensors_update.cpp:54