mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-22 10:03:35 +08:00
uORB: increase ORB_MULTI_MAX_INSTANCES 4 -> 10
- put more realistic bounds on maximum number of battery instances, gps, etc
This commit is contained in:
@@ -72,7 +72,7 @@ bool MavlinkStreamHighLatency2::send(const hrt_abstime t)
|
||||
bool updated = _airspeed.valid();
|
||||
updated |= _airspeed_sp.valid();
|
||||
|
||||
for (int i = 0; i < MAX_BATTERIES; i++) {
|
||||
for (int i = 0; i < battery_status_s::MAX_INSTANCES; i++) {
|
||||
updated |= _batteries[i].analyzer.valid();
|
||||
}
|
||||
|
||||
@@ -112,7 +112,7 @@ bool MavlinkStreamHighLatency2::send(const hrt_abstime t)
|
||||
|
||||
int lowest = 0;
|
||||
|
||||
for (int i = 1; i < MAX_BATTERIES; i++) {
|
||||
for (int i = 1; i < battery_status_s::MAX_INSTANCES; i++) {
|
||||
const bool battery_connected = _batteries[i].connected && _batteries[i].analyzer.valid();
|
||||
const bool battery_is_lowest = _batteries[i].analyzer.get_scaled(100.0f) <= _batteries[lowest].analyzer.get_scaled(
|
||||
100.0f);
|
||||
@@ -183,7 +183,7 @@ void MavlinkStreamHighLatency2::reset_analysers(const hrt_abstime t)
|
||||
_airspeed.reset();
|
||||
_airspeed_sp.reset();
|
||||
|
||||
for (int i = 0; i < MAX_BATTERIES; i++) {
|
||||
for (int i = 0; i < battery_status_s::MAX_INSTANCES; i++) {
|
||||
_batteries[i].analyzer.reset();
|
||||
}
|
||||
|
||||
@@ -227,10 +227,11 @@ bool MavlinkStreamHighLatency2::write_attitude_sp(mavlink_high_latency2_t *msg)
|
||||
|
||||
bool MavlinkStreamHighLatency2::write_battery_status(mavlink_high_latency2_t *msg)
|
||||
{
|
||||
struct battery_status_s battery;
|
||||
bool updated = false;
|
||||
|
||||
for (int i = 0; i < MAX_BATTERIES; i++) {
|
||||
for (int i = 0; i < battery_status_s::MAX_INSTANCES; i++) {
|
||||
battery_status_s battery;
|
||||
|
||||
if (_batteries[i].subscription.update(&battery)) {
|
||||
updated = true;
|
||||
_batteries[i].connected = battery.connected;
|
||||
@@ -486,7 +487,7 @@ void MavlinkStreamHighLatency2::update_battery_status()
|
||||
{
|
||||
battery_status_s battery;
|
||||
|
||||
for (int i = 0; i < MAX_BATTERIES; i++) {
|
||||
for (int i = 0; i < battery_status_s::MAX_INSTANCES; i++) {
|
||||
if (_batteries[i].subscription.update(&battery)) {
|
||||
_batteries[i].connected = battery.connected;
|
||||
_batteries[i].analyzer.add_value(battery.remaining, _update_rate_filtered);
|
||||
|
||||
@@ -138,8 +138,7 @@ private:
|
||||
hrt_abstime _last_update_time = 0;
|
||||
float _update_rate_filtered = 0.0f;
|
||||
|
||||
static constexpr int MAX_BATTERIES = 4;
|
||||
PerBatteryData _batteries[MAX_BATTERIES] {0, 1, 2, 3};
|
||||
PerBatteryData _batteries[battery_status_s::MAX_INSTANCES] {0, 1, 2, 3};
|
||||
|
||||
/* do not allow top copying this class */
|
||||
MavlinkStreamHighLatency2(MavlinkStreamHighLatency2 &);
|
||||
|
||||
@@ -649,7 +649,7 @@ public:
|
||||
private:
|
||||
uORB::Subscription _status_sub{ORB_ID(vehicle_status)};
|
||||
uORB::Subscription _cpuload_sub{ORB_ID(cpuload)};
|
||||
uORB::SubscriptionMultiArray<battery_status_s> _battery_status_subs{ORB_ID::battery_status};
|
||||
uORB::SubscriptionMultiArray<battery_status_s, battery_status_s::MAX_INSTANCES> _battery_status_subs{ORB_ID::battery_status};
|
||||
|
||||
/* do not allow top copying this class */
|
||||
MavlinkStreamSysStatus(MavlinkStreamSysStatus &) = delete;
|
||||
@@ -669,7 +669,7 @@ protected:
|
||||
cpuload_s cpuload{};
|
||||
_cpuload_sub.copy(&cpuload);
|
||||
|
||||
battery_status_s battery_status[ORB_MULTI_MAX_INSTANCES] {};
|
||||
battery_status_s battery_status[battery_status_s::MAX_INSTANCES] {};
|
||||
|
||||
for (int i = 0; i < _battery_status_subs.size(); i++) {
|
||||
_battery_status_subs[i].copy(&battery_status[i]);
|
||||
@@ -753,7 +753,7 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
uORB::SubscriptionMultiArray<battery_status_s> _battery_status_subs{ORB_ID::battery_status};
|
||||
uORB::SubscriptionMultiArray<battery_status_s, battery_status_s::MAX_INSTANCES> _battery_status_subs{ORB_ID::battery_status};
|
||||
|
||||
/* do not allow top copying this class */
|
||||
MavlinkStreamBatteryStatus(MavlinkStreamSysStatus &) = delete;
|
||||
@@ -877,7 +877,7 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
uORB::SubscriptionMultiArray<battery_status_s> _battery_status_subs{ORB_ID::battery_status};
|
||||
uORB::SubscriptionMultiArray<battery_status_s, battery_status_s::MAX_INSTANCES> _battery_status_subs{ORB_ID::battery_status};
|
||||
|
||||
/* do not allow top copying this class */
|
||||
MavlinkStreamSmartBatteryInfo(MavlinkStreamSysStatus &) = delete;
|
||||
@@ -960,7 +960,7 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
uORB::SubscriptionMultiArray<vehicle_imu_s> _vehicle_imu_subs{ORB_ID::vehicle_imu};
|
||||
uORB::SubscriptionMultiArray<vehicle_imu_s, 3> _vehicle_imu_subs{ORB_ID::vehicle_imu};
|
||||
uORB::Subscription _sensor_selection_sub{ORB_ID(sensor_selection)};
|
||||
uORB::Subscription _bias_sub{ORB_ID(estimator_sensor_bias)};
|
||||
uORB::Subscription _differential_pressure_sub{ORB_ID(differential_pressure)};
|
||||
@@ -2993,7 +2993,7 @@ public:
|
||||
|
||||
private:
|
||||
uORB::Subscription _sensor_selection_sub{ORB_ID(sensor_selection)};
|
||||
uORB::SubscriptionMultiArray<vehicle_imu_status_s> _vehicle_imu_status_subs{ORB_ID::vehicle_imu_status};
|
||||
uORB::SubscriptionMultiArray<vehicle_imu_status_s, 3> _vehicle_imu_status_subs{ORB_ID::vehicle_imu_status};
|
||||
|
||||
/* do not allow top copying this class */
|
||||
MavlinkStreamVibration(MavlinkStreamVibration &) = delete;
|
||||
@@ -4622,7 +4622,7 @@ protected:
|
||||
{
|
||||
bool updated = false;
|
||||
|
||||
for (int i = 0; i < ORB_MULTI_MAX_INSTANCES; i++) {
|
||||
for (int i = 0; i < _distance_sensor_subs.size(); i++) {
|
||||
distance_sensor_s dist_sensor;
|
||||
|
||||
if (_distance_sensor_subs[i].update(&dist_sensor)) {
|
||||
|
||||
Reference in New Issue
Block a user