move baro and magnetometer data out of sensor_combined

This commit is contained in:
Daniel Agar
2018-04-11 23:26:58 -04:00
parent 3e6ba1d541
commit 3b5b12e1d1
31 changed files with 289 additions and 266 deletions
+28 -8
View File
@@ -85,6 +85,8 @@
#include <uORB/topics/differential_pressure.h>
#include <uORB/topics/airspeed.h>
#include <uORB/topics/sensor_preflight.h>
#include <uORB/topics/vehicle_air_data.h>
#include <uORB/topics/vehicle_magnetometer.h>
#include <DevMgr.hpp>
@@ -169,6 +171,8 @@ private:
int _params_sub{-1}; /**< notification of parameter updates */
orb_advert_t _sensor_pub{nullptr}; /**< combined sensor data topic */
orb_advert_t _airdata_pub{nullptr}; /**< combined sensor data topic */
orb_advert_t _magnetometer_pub{nullptr}; /**< combined sensor data topic */
orb_advert_t _battery_pub[BOARD_NUMBER_BRICKS] {}; /**< battery status */
#if BOARD_NUMBER_BRICKS > 1
@@ -212,7 +216,7 @@ private:
* @param raw Combined sensor data structure into which
* data should be returned.
*/
void diff_pres_poll(struct sensor_combined_s &raw);
void diff_pres_poll(const vehicle_air_data_s &airdata);
/**
* Check for changes in vehicle control mode.
@@ -285,7 +289,7 @@ Sensors::adc_init()
}
void
Sensors::diff_pres_poll(struct sensor_combined_s &raw)
Sensors::diff_pres_poll(const vehicle_air_data_s &raw)
{
bool updated;
orb_check(_diff_pres_sub, &updated);
@@ -569,7 +573,9 @@ Sensors::run()
#endif
}
struct sensor_combined_s raw = {};
sensor_combined_s raw = {};
vehicle_air_data_s airdata = {};
vehicle_magnetometer_s magnetometer = {};
struct sensor_preflight_s preflt = {};
@@ -592,14 +598,16 @@ Sensors::run()
_actuator_ctrl_0_sub = orb_subscribe(ORB_ID(actuator_controls_0));
/* get a set of initial values */
_voted_sensors_update.sensors_poll(raw);
_voted_sensors_update.sensors_poll(raw, airdata, magnetometer);
diff_pres_poll(raw);
diff_pres_poll(airdata);
_rc_update.rc_parameter_map_poll(_parameter_handles, true /* forced */);
/* advertise the sensor_combined topic and make the initial publication */
_sensor_pub = orb_advertise(ORB_ID(sensor_combined), &raw);
_airdata_pub = orb_advertise(ORB_ID(vehicle_air_data), &airdata);
_magnetometer_pub = orb_advertise(ORB_ID(vehicle_magnetometer), &magnetometer);
/* advertise the sensor_preflight topic and make the initial publication */
preflt.accel_inconsistency_m_s_s = 0.0f;
@@ -649,12 +657,15 @@ Sensors::run()
/* the timestamp of the raw struct is updated by the gyro_poll() method (this makes the gyro
* a mandatory sensor) */
_voted_sensors_update.sensors_poll(raw);
const uint64_t airdata_prev_timestamp = airdata.timestamp;
const uint64_t magnetometer_prev_timestamp = magnetometer.timestamp;
_voted_sensors_update.sensors_poll(raw, airdata, magnetometer);
/* check battery voltage */
adc_poll();
diff_pres_poll(raw);
diff_pres_poll(airdata);
if (raw.timestamp > 0) {
@@ -662,6 +673,14 @@ Sensors::run()
orb_publish(ORB_ID(sensor_combined), _sensor_pub, &raw);
if (airdata.timestamp != airdata_prev_timestamp) {
orb_publish(ORB_ID(vehicle_air_data), _airdata_pub, &airdata);
}
if (magnetometer.timestamp != magnetometer_prev_timestamp) {
orb_publish(ORB_ID(vehicle_magnetometer), _magnetometer_pub, &magnetometer);
}
_voted_sensors_update.check_failover();
/* If the the vehicle is disarmed calculate the length of the maximum difference between
@@ -673,7 +692,6 @@ Sensors::run()
_voted_sensors_update.calc_gyro_inconsistency(preflt);
_voted_sensors_update.calc_mag_inconsistency(preflt);
orb_publish(ORB_ID(sensor_preflight), _sensor_preflight, &preflt);
}
}
@@ -704,6 +722,8 @@ Sensors::run()
orb_unsubscribe(_params_sub);
orb_unsubscribe(_actuator_ctrl_0_sub);
orb_unadvertise(_sensor_pub);
orb_unadvertise(_airdata_pub);
orb_unadvertise(_magnetometer_pub);
_rc_update.deinit();
_voted_sensors_update.deinit();