Browse Source

SITL: sailboat motor enabled only for sailboat-motor frame

master
Randy Mackay 6 years ago
parent
commit
257152aa55
  1. 7
      libraries/SITL/SIM_Sailboat.cpp
  2. 1
      libraries/SITL/SIM_Sailboat.h

7
libraries/SITL/SIM_Sailboat.cpp

@ -43,6 +43,7 @@ Sailboat::Sailboat(const char *frame_str) :
steering_angle_max(35), steering_angle_max(35),
turning_circle(1.8) turning_circle(1.8)
{ {
motor_connected = (strcmp(frame_str, "sailboat-motor") == 0);
} }
// calculate the lift and drag as values from 0 to 1 // calculate the lift and drag as values from 0 to 1
@ -222,9 +223,9 @@ void Sailboat::update(const struct sitl_input &input)
// throttle force (for motor sailing) // throttle force (for motor sailing)
// gives throttle force == hull drag at 10m/s // gives throttle force == hull drag at 10m/s
float throttle_force = 0.0f; float throttle_force = 0.0f;
uint16_t throttle_in = input.servos[THROTTLE_SERVO_CH]; if (motor_connected) {
if (throttle_in > 900 && throttle_in < 2100) { const uint16_t throttle_out = constrain_int16(input.servos[THROTTLE_SERVO_CH], 1000, 2000);
throttle_force = (throttle_in-1500) * 0.1f; throttle_force = (throttle_out-1500) * 0.1f;
} }
// accel in body frame due acceleration from sail and deceleration from hull friction // accel in body frame due acceleration from sail and deceleration from hull friction

1
libraries/SITL/SIM_Sailboat.h

@ -69,6 +69,7 @@ private:
Vector3f wave_gyro; // rad/s Vector3f wave_gyro; // rad/s
float wave_heave; // m/s/s float wave_heave; // m/s/s
float wave_phase; // rads float wave_phase; // rads
bool motor_connected; // true if this frame has a motor
}; };
} // namespace SITL } // namespace SITL

Loading…
Cancel
Save