SITL: sailboat motor enabled only for sailboat-motor frame

This commit is contained in:
Randy Mackay 2019-08-21 12:29:18 +09:00
parent 0ce1ce9c4f
commit 257152aa55
2 changed files with 5 additions and 3 deletions

View File

@ -43,6 +43,7 @@ Sailboat::Sailboat(const char *frame_str) :
steering_angle_max(35),
turning_circle(1.8)
{
motor_connected = (strcmp(frame_str, "sailboat-motor") == 0);
}
// 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)
// gives throttle force == hull drag at 10m/s
float throttle_force = 0.0f;
uint16_t throttle_in = input.servos[THROTTLE_SERVO_CH];
if (throttle_in > 900 && throttle_in < 2100) {
throttle_force = (throttle_in-1500) * 0.1f;
if (motor_connected) {
const uint16_t throttle_out = constrain_int16(input.servos[THROTTLE_SERVO_CH], 1000, 2000);
throttle_force = (throttle_out-1500) * 0.1f;
}
// accel in body frame due acceleration from sail and deceleration from hull friction

View File

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