mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-22 22:23:33 +08:00
uORB::Publication improvements and cleanup (#14784)
- create common uORB::PublicationBase - uORB::PublicationQueued types are now type aliases - ORB_PRIO use enum type everywhere to avoid accidental misuse - PX4Accelerometer/PX4Gyroscope/etc driver libs explicitly advertise on construction, unadvertise on destruction. This is a workaround for any potential issues that might appear when accel/gyro cdev and uORB indexing doesn't align.
This commit is contained in:
@@ -154,7 +154,7 @@ void VotedSensorsUpdate::parametersUpdate()
|
||||
_gyro.enabled[driver_index] = (device_enabled == 1);
|
||||
|
||||
if (!_gyro.enabled[driver_index]) {
|
||||
_gyro.priority[driver_index] = 0;
|
||||
_gyro.priority[driver_index] = ORB_PRIO_UNINITIALIZED;
|
||||
}
|
||||
|
||||
gyro_calibration_s gscale{};
|
||||
@@ -250,7 +250,7 @@ void VotedSensorsUpdate::parametersUpdate()
|
||||
_accel.enabled[driver_index] = (device_enabled == 1);
|
||||
|
||||
if (!_accel.enabled[driver_index]) {
|
||||
_accel.priority[driver_index] = 0;
|
||||
_accel.priority[driver_index] = ORB_PRIO_UNINITIALIZED;
|
||||
}
|
||||
|
||||
accel_calibration_s ascale{};
|
||||
@@ -387,7 +387,7 @@ void VotedSensorsUpdate::parametersUpdate()
|
||||
// the mags that were published after the initial parameterUpdate
|
||||
// would be given the priority even if disabled. Reset it to 0 in this case
|
||||
if (!_mag.enabled[topic_instance]) {
|
||||
_mag.priority[topic_instance] = 0;
|
||||
_mag.priority[topic_instance] = ORB_PRIO_UNINITIALIZED;
|
||||
}
|
||||
|
||||
mag_calibration_s mscale{};
|
||||
@@ -702,14 +702,16 @@ bool VotedSensorsUpdate::checkFailover(SensorData &sensor, const char *sensor_na
|
||||
((flags & DataValidator::ERROR_FLAG_HIGH_ERRDENSITY) ? " ERR DNST" : ""));
|
||||
|
||||
// reduce priority of failed sensor to the minimum
|
||||
sensor.priority[failover_index] = 1;
|
||||
sensor.priority[failover_index] = ORB_PRIO_MIN;
|
||||
|
||||
PX4_ERR("Sensor %s #%i failed. Reconfiguring sensor priorities.", sensor_name, failover_index);
|
||||
|
||||
int ctr_valid = 0;
|
||||
|
||||
for (uint8_t i = 0; i < sensor.subscription_count; i++) {
|
||||
if (sensor.priority[i] > 1) { ctr_valid++; }
|
||||
if (sensor.priority[i] > ORB_PRIO_MIN) {
|
||||
ctr_valid++;
|
||||
}
|
||||
|
||||
PX4_WARN("Remaining sensors after failover event %u: %s #%u priority: %u", failover_index, sensor_name, i,
|
||||
sensor.priority[i]);
|
||||
|
||||
@@ -54,7 +54,6 @@
|
||||
#include <lib/mag_compensation/MagCompensation.hpp>
|
||||
|
||||
#include <uORB/Publication.hpp>
|
||||
#include <uORB/PublicationQueued.hpp>
|
||||
#include <uORB/Subscription.hpp>
|
||||
#include <uORB/topics/sensor_accel_integrated.h>
|
||||
#include <uORB/topics/sensor_combined.h>
|
||||
@@ -156,7 +155,7 @@ private:
|
||||
uORB::Subscription subscription[SENSOR_COUNT_MAX]; /**< raw sensor data subscription */
|
||||
DataValidatorGroup voter{1};
|
||||
unsigned int last_failover_count{0};
|
||||
uint8_t priority[SENSOR_COUNT_MAX] {}; /**< sensor priority */
|
||||
ORB_PRIO priority[SENSOR_COUNT_MAX] {}; /**< sensor priority */
|
||||
uint8_t last_best_vote{0}; /**< index of the latest best vote */
|
||||
uint8_t subscription_count{0};
|
||||
bool enabled[SENSOR_COUNT_MAX] {true, true, true, true};
|
||||
|
||||
Reference in New Issue
Block a user