add boolean parameters to enable/disable each sensor

This commit is contained in:
Daniel Agar 2017-10-26 20:45:22 -04:00 committed by Lorenz Meier
parent e1e3c9fca9
commit 9fde19259e
5 changed files with 110 additions and 10 deletions

View File

@ -45,6 +45,14 @@ PARAM_DEFINE_INT32(CAL_ACC_PRIME, 0);
*/
PARAM_DEFINE_INT32(CAL_ACC0_ID, 0);
/**
* Accelerometer 0 enabled
*
* @boolean
* @group Sensor Calibration
*/
PARAM_DEFINE_INT32(CAL_ACC0_EN, 1);
/**
* Accelerometer X-axis offset
*
@ -94,6 +102,14 @@ PARAM_DEFINE_FLOAT(CAL_ACC0_ZSCALE, 1.0f);
*/
PARAM_DEFINE_INT32(CAL_ACC1_ID, 0);
/**
* Accelerometer 1 enabled
*
* @boolean
* @group Sensor Calibration
*/
PARAM_DEFINE_INT32(CAL_ACC1_EN, 1);
/**
* Accelerometer X-axis offset
*
@ -143,6 +159,14 @@ PARAM_DEFINE_FLOAT(CAL_ACC1_ZSCALE, 1.0f);
*/
PARAM_DEFINE_INT32(CAL_ACC2_ID, 0);
/**
* Accelerometer 2 enabled
*
* @boolean
* @group Sensor Calibration
*/
PARAM_DEFINE_INT32(CAL_ACC2_EN, 1);
/**
* Accelerometer X-axis offset
*

View File

@ -45,6 +45,14 @@ PARAM_DEFINE_INT32(CAL_GYRO_PRIME, 0);
*/
PARAM_DEFINE_INT32(CAL_GYRO0_ID, 0);
/**
* Gyro 0 enabled
*
* @boolean
* @group Sensor Calibration
*/
PARAM_DEFINE_INT32(CAL_GYRO0_EN, 1);
/**
* Gyro X-axis offset
*
@ -94,6 +102,14 @@ PARAM_DEFINE_FLOAT(CAL_GYRO0_ZSCALE, 1.0f);
*/
PARAM_DEFINE_INT32(CAL_GYRO1_ID, 0);
/**
* Gyro 1 enabled
*
* @boolean
* @group Sensor Calibration
*/
PARAM_DEFINE_INT32(CAL_GYRO1_EN, 1);
/**
* Gyro X-axis offset
*
@ -143,6 +159,14 @@ PARAM_DEFINE_FLOAT(CAL_GYRO1_ZSCALE, 1.0f);
*/
PARAM_DEFINE_INT32(CAL_GYRO2_ID, 0);
/**
* Gyro 2 enabled
*
* @boolean
* @group Sensor Calibration
*/
PARAM_DEFINE_INT32(CAL_GYRO2_EN, 1);
/**
* Gyro X-axis offset
*

View File

@ -65,6 +65,14 @@ PARAM_DEFINE_INT32(CAL_MAG_SIDES, 63);
*/
PARAM_DEFINE_INT32(CAL_MAG0_ID, 0);
/**
* Mag 0 enabled
*
* @boolean
* @group Sensor Calibration
*/
PARAM_DEFINE_INT32(CAL_MAG0_EN, 1);
/**
* Rotation of magnetometer 0 relative to airframe.
*
@ -156,6 +164,14 @@ PARAM_DEFINE_FLOAT(CAL_MAG0_ZSCALE, 1.0f);
*/
PARAM_DEFINE_INT32(CAL_MAG1_ID, 0);
/**
* Mag 1 enabled
*
* @boolean
* @group Sensor Calibration
*/
PARAM_DEFINE_INT32(CAL_MAG1_EN, 1);
/**
* Rotation of magnetometer 1 relative to airframe.
*
@ -247,6 +263,14 @@ PARAM_DEFINE_FLOAT(CAL_MAG1_ZSCALE, 1.0f);
*/
PARAM_DEFINE_INT32(CAL_MAG2_ID, 0);
/**
* Mag 2 enabled
*
* @boolean
* @group Sensor Calibration
*/
PARAM_DEFINE_INT32(CAL_MAG2_EN, 1);
/**
* Rotation of magnetometer 2 relative to airframe.
*
@ -340,6 +364,14 @@ PARAM_DEFINE_FLOAT(CAL_MAG2_ZSCALE, 1.0f);
*/
PARAM_DEFINE_INT32(CAL_MAG3_ID, 0);
/**
* Mag 3 enabled
*
* @boolean
* @group Sensor Calibration
*/
PARAM_DEFINE_INT32(CAL_MAG3_EN, 1);
/**
* Rotation of magnetometer 2 relative to airframe.
*

View File

@ -168,10 +168,10 @@ void VotedSensorsUpdate::parameters_update()
if (temp < 0) {
PX4_ERR("gyro temp compensation init: failed to find device ID %u for instance %i",
report.device_id, topic_instance);
_corrections.gyro_mapping[topic_instance] = 0;
_corrections.gyro_mapping[topic_instance] = 0;
} else {
_corrections.gyro_mapping[topic_instance] = temp;
_corrections.gyro_mapping[topic_instance] = temp;
}
}
@ -192,10 +192,10 @@ void VotedSensorsUpdate::parameters_update()
if (temp < 0) {
PX4_ERR("accel temp compensation init: failed to find device ID %u for instance %i",
report.device_id, topic_instance);
_corrections.accel_mapping[topic_instance] = 0;
_corrections.accel_mapping[topic_instance] = 0;
} else {
_corrections.accel_mapping[topic_instance] = temp;
_corrections.accel_mapping[topic_instance] = temp;
}
}
@ -215,10 +215,10 @@ void VotedSensorsUpdate::parameters_update()
if (temp < 0) {
PX4_ERR("baro temp compensation init: failed to find device ID %u for instance %i",
report.device_id, topic_instance);
_corrections.baro_mapping[topic_instance] = 0;
_corrections.baro_mapping[topic_instance] = 0;
} else {
_corrections.baro_mapping[topic_instance] = temp;
_corrections.baro_mapping[topic_instance] = temp;
}
}
@ -258,6 +258,12 @@ void VotedSensorsUpdate::parameters_update()
int32_t device_id;
failed = failed || (OK != param_get(param_find(str), &device_id));
(void)sprintf(str, "CAL_GYRO%u_EN", i);
int32_t device_enabled = 0;
failed = failed || (OK != param_get(param_find(str), &device_enabled));
_gyro.enabled[i] = (device_enabled == 1);
if (failed) {
continue;
}
@ -340,6 +346,12 @@ void VotedSensorsUpdate::parameters_update()
int32_t device_id;
failed = failed || (OK != param_get(param_find(str), &device_id));
(void)sprintf(str, "CAL_ACC%u_EN", i);
int32_t device_enabled = 0;
failed = failed || (OK != param_get(param_find(str), &device_enabled));
_accel.enabled[i] = (device_enabled == 1);
if (failed) {
continue;
}
@ -450,6 +462,12 @@ void VotedSensorsUpdate::parameters_update()
int32_t device_id;
failed = failed || (OK != param_get(param_find(str), &device_id));
(void)sprintf(str, "CAL_MAG%u_EN", i);
int32_t device_enabled = 0;
failed = failed || (OK != param_get(param_find(str), &device_enabled));
_mag.enabled[i] = (device_enabled == 1);
if (failed) {
continue;
}
@ -531,7 +549,7 @@ void VotedSensorsUpdate::accel_poll(struct sensor_combined_s &raw)
bool accel_updated;
orb_check(_accel.subscription[uorb_index], &accel_updated);
if (accel_updated) {
if (accel_updated && _accel.enabled[uorb_index]) {
struct accel_report accel_report;
orb_copy(ORB_ID(sensor_accel), _accel.subscription[uorb_index], &accel_report);
@ -638,7 +656,7 @@ void VotedSensorsUpdate::gyro_poll(struct sensor_combined_s &raw)
bool gyro_updated;
orb_check(_gyro.subscription[uorb_index], &gyro_updated);
if (gyro_updated) {
if (gyro_updated && _gyro.enabled[uorb_index]) {
struct gyro_report gyro_report;
orb_copy(ORB_ID(sensor_gyro), _gyro.subscription[uorb_index], &gyro_report);
@ -743,7 +761,7 @@ void VotedSensorsUpdate::mag_poll(struct sensor_combined_s &raw)
bool mag_updated;
orb_check(_mag.subscription[uorb_index], &mag_updated);
if (mag_updated) {
if (mag_updated && _mag.enabled[uorb_index]) {
struct mag_report mag_report;
orb_copy(ORB_ID(sensor_mag), _mag.subscription[uorb_index], &mag_report);
@ -803,7 +821,7 @@ void VotedSensorsUpdate::baro_poll(struct sensor_combined_s &raw)
bool baro_updated;
orb_check(_baro.subscription[uorb_index], &baro_updated);
if (baro_updated) {
if (baro_updated && _baro.enabled[uorb_index]) {
struct baro_report baro_report;
orb_copy(ORB_ID(sensor_baro), _baro.subscription[uorb_index], &baro_report);

View File

@ -164,6 +164,8 @@ private:
}
}
bool enabled[SENSOR_COUNT_MAX];
int subscription[SENSOR_COUNT_MAX]; /**< raw sensor data subscription */
uint8_t priority[SENSOR_COUNT_MAX]; /**< sensor priority */
uint8_t last_best_vote; /**< index of the latest best vote */