Skip to content

Commit

Permalink
SITL: sailboat motor enabled only for sailboat-motor frame
Browse files Browse the repository at this point in the history
  • Loading branch information
rmackay9 committed Aug 21, 2019
1 parent 0ce1ce9 commit 257152a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
7 changes: 4 additions & 3 deletions libraries/SITL/SIM_Sailboat.cpp
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions libraries/SITL/SIM_Sailboat.h
Expand Up @@ -69,6 +69,7 @@ class Sailboat : public Aircraft {
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

0 comments on commit 257152a

Please sign in to comment.