refactor(sih): remove local variable to save stack

A recent SIH log (V6X) was full of:

WARNING: [px4] [load_mon] sih low on stack! (144 bytes left)

Using PublicationData (which holds the esc_status_s in heap rather than
stack) fixes them and adheres to the philosophy from the module
description: "Most of the variables are declared global in the .hpp file
to avoid stack overflow"
This commit is contained in:
Balduin
2026-07-03 15:16:44 +02:00
committed by Ramon Roche
parent 94c12f468c
commit d8847067a8
2 changed files with 5 additions and 3 deletions

View File

@@ -368,8 +368,10 @@ uint8_t Sih::num_motors() const
void Sih::publish_esc_status()
{
esc_status_s esc_status{};
esc_status_s &esc_status = _esc_status_pub.get();
esc_status.timestamp = hrt_absolute_time();
esc_status.esc_online_flags = 0;
esc_status.esc_armed_flags = 0;
int motor_idx = 0;
bool any_motor_running = false;
float max_rpm = 10000.f;
@@ -404,7 +406,7 @@ void Sih::publish_esc_status()
esc_status.esc_armed_flags = (1u << motor_idx) - 1;
}
_esc_status_pub.publish(esc_status);
_esc_status_pub.update();
}
void Sih::generate_force_and_torques(const float dt)

View File

@@ -132,7 +132,7 @@ private:
PX4Rangefinder _px4_rangefinder{10092548}; // 10092548: DRV_DIST_DEVTYPE_SIM, BUS: 0, ADDR: 0, TYPE: SIMULATION
uORB::Publication<airspeed_s> _airspeed_pub{ORB_ID(airspeed)};
uORB::Publication<ranging_beacon_s> _ranging_beacon_pub{ORB_ID(ranging_beacon)};
uORB::Publication<esc_status_s> _esc_status_pub{ORB_ID(esc_status)};
uORB::PublicationData<esc_status_s> _esc_status_pub{ORB_ID(esc_status)};
// groundtruth
uORB::Publication<vehicle_angular_velocity_s> _angular_velocity_ground_truth_pub{ORB_ID(vehicle_angular_velocity_groundtruth)};