Skip to content

Commit

Permalink
more intuitive variable names
Browse files Browse the repository at this point in the history
 - NB_MOTORS -> NB_ACTUATORS_MAX. the _u array also contains control
   surface deflections.
 - thrust -> throttle_cmd to match the other arguments
  • Loading branch information
mbjd committed Jan 8, 2025
1 parent e73e6cf commit eacbdc2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions src/modules/simulation/simulator_sih/sih.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ void Sih::read_motors(const float dt)
if (_actuator_out_sub.update(&actuators_out)) {
_last_actuator_output_time = actuators_out.timestamp;

for (int i = 0; i < NB_MOTORS; i++) { // saturate the motor signals
for (int i = 0; i < NUM_ACTUATORS_MAX; i++) { // saturate the motor signals
if ((_vehicle == VehicleType::FW && i < 3) || (_vehicle == VehicleType::TS && i > 3)) {
_u[i] = actuators_out.output[i];

Expand Down Expand Up @@ -352,16 +352,16 @@ void Sih::generate_force_and_torques()
}
}

void Sih::generate_fw_aerodynamics(const float roll_cmd, const float pitch_cmd, const float yaw_cmd, const float thrust)
void Sih::generate_fw_aerodynamics(const float roll_cmd, const float pitch_cmd, const float yaw_cmd, const float throttle_cmd)
{
const Vector3f v_B = _q_E.rotateVectorInverse(_v_E);
const float &alt = _lla.altitude();

_wing_l.update_aero(v_B, _w_B, alt, roll_cmd * FLAP_MAX);
_wing_r.update_aero(v_B, _w_B, alt, -roll_cmd * FLAP_MAX);

_tailplane.update_aero(v_B, _w_B, alt, pitch_cmd * FLAP_MAX, _T_MAX * thrust);
_fin.update_aero(v_B, _w_B, alt, yaw_cmd * FLAP_MAX, _T_MAX * thrust);
_tailplane.update_aero(v_B, _w_B, alt, pitch_cmd * FLAP_MAX, _T_MAX * throttle_cmd);
_fin.update_aero(v_B, _w_B, alt, yaw_cmd * FLAP_MAX, _T_MAX * throttle_cmd);
_fuselage.update_aero(v_B, _w_B, alt);

// sum of aerodynamic forces
Expand Down
4 changes: 2 additions & 2 deletions src/modules/simulation/simulator_sih/sih.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ class Sih : public ModuleBase<Sih>, public ModuleParams
uORB::Subscription _actuator_out_sub{ORB_ID(actuator_outputs)};

// hard constants
static constexpr uint16_t NB_MOTORS = 9;
static constexpr uint16_t NUM_ACTUATORS_MAX = 9;
static constexpr float T1_C = 15.0f; // ground temperature in Celsius
static constexpr float T1_K = T1_C - atmosphere::kAbsoluteNullCelsius; // ground temperature in Kelvin
static constexpr float TEMP_GRADIENT = -6.5f / 1000.0f; // temperature gradient in degrees per metre
Expand Down Expand Up @@ -218,7 +218,7 @@ class Sih : public ModuleBase<Sih>, public ModuleParams
matrix::Vector3f _v_E_dot{};
matrix::Dcmf _R_N2E; // local navigation to ECEF frame rotation matrix

float _u[NB_MOTORS] {}; // thruster signals
float _u[NUM_ACTUATORS_MAX] {}; // thruster signals

enum class VehicleType {MC, FW, TS, SVTOL};
VehicleType _vehicle = VehicleType::MC;
Expand Down

0 comments on commit eacbdc2

Please sign in to comment.