AP_HAL_SITL: handle negative throttle

- negative throttle was causing negative voltage offsets
This commit is contained in:
Tom Pittenger 2016-01-26 18:18:12 -08:00 committed by Andrew Tridgell
parent b55294920b
commit f695f37ca3
1 changed files with 2 additions and 2 deletions

View File

@ -405,10 +405,10 @@ void SITL_State::_simulator_servos(Aircraft::sitl_input &input)
// simulate simple battery setup // simulate simple battery setup
float throttle = _sitl->motors_on?(input.servos[2]-1000) / 1000.0f:0; float throttle = _sitl->motors_on?(input.servos[2]-1000) / 1000.0f:0;
// lose 0.7V at full throttle // lose 0.7V at full throttle
voltage = _sitl->batt_voltage - 0.7f*throttle; voltage = _sitl->batt_voltage - 0.7f*fabsf(throttle);
// assume 50A at full throttle // assume 50A at full throttle
_current = 50.0f * throttle; _current = 50.0f * fabsf(throttle);
} else { } else {
// FDM provides voltage and current // FDM provides voltage and current
voltage = _sitl->state.battery_voltage; voltage = _sitl->state.battery_voltage;