perf(sensors/flight_mode_manager): drop two per-cycle topic copies (#29263)

VotedSensorsUpdate::imuPoll() copied the whole vehicle_imu_status of
each IMU on every vehicle_imu sample (200 Hz or more) to read two error
counters that are published at 10 Hz. Keep the latest counters and
update them only when a new status arrives; the voter gets the same
values as before.

FlightTaskManualAcceleration::update() copied vehicle_local_position by
value on every run, although it only reads it and the subscription only
changes in updateInitialize(). Take it by reference.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
This commit is contained in:
Benjamin Cabé authored and GitHub committed 2026-10-16 17:41:45 -06:00
1 parent 4ee456bd90
commit 9368a9826a
3 files changed
+12 -6

No files matched your search

@@ -64,7 +64,7 @@ bool FlightTaskManualAcceleration::activate(const trajectory_setpoint_s &last_se
bool FlightTaskManualAcceleration::update()
{
const vehicle_local_position_s vehicle_local_pos = _sub_vehicle_local_position.get();
const vehicle_local_position_s &vehicle_local_pos = _sub_vehicle_local_position.get();
setMaxDistanceToGround(vehicle_local_pos.hagl_max_xy);
bool ret = FlightTaskManualAltitudeSmoothVel::update();
+9 -5
View File
@@ -174,9 +174,13 @@ void VotedSensorsUpdate::imuPoll(struct sensor_combined_s &raw)
if (_vehicle_imu_sub[uorb_index].update(&imu_report) && imuEnabled(uorb_index)) {
// copy corresponding vehicle_imu_status for accel & gyro error counts
vehicle_imu_status_s imu_status{};
_vehicle_imu_status_subs[uorb_index].copy(&imu_status);
// update the accel & gyro error counts from the corresponding vehicle_imu_status
vehicle_imu_status_s imu_status;
if (_vehicle_imu_status_subs[uorb_index].update(&imu_status)) {
_accel_error_count[uorb_index] = imu_status.accel_error_count;
_gyro_error_count[uorb_index] = imu_status.gyro_error_count;
}
_accel_device_id[uorb_index] = imu_report.accel_device_id;
_gyro_device_id[uorb_index] = imu_report.gyro_device_id;
@@ -207,10 +211,10 @@ void VotedSensorsUpdate::imuPoll(struct sensor_combined_s &raw)
_last_accel_timestamp[uorb_index] = imu_report.timestamp_sample;
_accel.voter.put(uorb_index, imu_report.timestamp, _last_sensor_data[uorb_index].accelerometer_m_s2,
imu_status.accel_error_count, _accel.priority[uorb_index]);
_accel_error_count[uorb_index], _accel.priority[uorb_index]);
_gyro.voter.put(uorb_index, imu_report.timestamp, _last_sensor_data[uorb_index].gyro_rad,
imu_status.gyro_error_count, _gyro.priority[uorb_index]);
_gyro_error_count[uorb_index], _gyro.priority[uorb_index]);
}
}
@@ -173,6 +173,8 @@ private:
uORB::SubscriptionCallbackWorkItem(&_vehicle_imu_sub)[MAX_SENSOR_COUNT];
uORB::SubscriptionMultiArray<vehicle_imu_status_s, MAX_SENSOR_COUNT> _vehicle_imu_status_subs{ORB_ID::vehicle_imu_status};
uint32_t _accel_error_count[MAX_SENSOR_COUNT] {}; /**< latest vehicle_imu_status error counts */
uint32_t _gyro_error_count[MAX_SENSOR_COUNT] {};
uORB::Subscription _sensor_selection_sub{ORB_ID(sensor_selection)};