Browse Source

SITL: SIM_Frame: add number of motors to json spec

apm_2208
Iampete1 3 years ago committed by Andrew Tridgell
parent
commit
f61d96dd5c
  1. 5
      libraries/SITL/SIM_Frame.cpp
  2. 3
      libraries/SITL/SIM_Frame.h

5
libraries/SITL/SIM_Frame.cpp

@ -411,6 +411,7 @@ void Frame::load_frame_params(const char *model_json) @@ -411,6 +411,7 @@ void Frame::load_frame_params(const char *model_json)
FRAME_VAR(disc_area),
FRAME_VAR(mdrag_coef),
{"moment_inertia", &model.moment_of_inertia, VarType::VECTOR3F},
FRAME_VAR(num_motors),
};
for (uint8_t i=0; i<ARRAY_SIZE(vars); i++) {
@ -523,6 +524,10 @@ void Frame::init(const char *frame_str, Battery *_battery) @@ -523,6 +524,10 @@ void Frame::init(const char *frame_str, Battery *_battery)
battery->setup(model.battCapacityAh, model.refBatRes, model.maxVoltage);
if (uint8_t(model.num_motors) != num_motors) {
::printf("Warning model expected %u motors and got %u\n", uint8_t(model.num_motors), num_motors);
}
for (uint8_t i=0; i<num_motors; i++) {
motors[i].setup_params(model.pwmMin, model.pwmMax, model.spin_min, model.spin_max, model.propExpo, model.slew_max,
model.diagonal_size, power_factor, model.maxVoltage, effective_prop_area, velocity_max,

3
libraries/SITL/SIM_Frame.h

@ -144,6 +144,9 @@ private: @@ -144,6 +144,9 @@ private:
Vector3f motor_thrust_vec[12];
float yaw_factor[12] = {0};
// number of motors
float num_motors = 4;
} default_model;
protected:

Loading…
Cancel
Save