Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix heli ice/turbine cooldown and add autotest #28310

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions Tools/autotest/helicopter.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from pysim import vehicleinfo

import copy
import operator


class AutoTestHelicopter(AutoTestCopter):
Expand Down Expand Up @@ -697,6 +698,52 @@ def check_airspeeds(mav, m):
self.disarm_vehicle()
self.context_pop()

def TurbineCoolDown(self, timeout=200):
"""Check Turbine Cool Down Feature"""
# set option for Turbine
RAMP_TIME = 4
SETPOINT = 66
IDLE = 15
COOLDOWN_TIME = 5
self.set_parameter("RC6_OPTION", 161)
self.set_parameter("H_RSC_RAMP_TIME", RAMP_TIME)
self.set_parameter("H_RSC_SETPOINT", SETPOINT)
self.set_parameter("H_RSC_IDLE", IDLE)
self.set_parameter("H_RSC_CLDWN_TIME", COOLDOWN_TIME)
Comment on lines +708 to +712
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

set_parameters can be faster.

self.set_rc(3, 1000)
self.set_rc(8, 1000)

self.progress("Starting turbine")
self.wait_ready_to_arm()
self.arm_vehicle()

self.set_rc(6, 2000)
self.wait_statustext('Turbine startup')
Comment on lines +720 to +721
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a race condition here, should collect statustext in the context and check_context=True


# Engage interlock to run up to head speed
self.set_rc(8, 2000)

# Check throttle gets to setpoint
expected_thr = SETPOINT * 0.01 * 1000 + 1000 - 1 # servo end points are 1000 to 2000
self.wait_servo_channel_value(8, expected_thr, timeout=RAMP_TIME+1, comparator=operator.ge)

self.progress("Checking cool down behaviour, idle x 1.5")
self.set_rc(8, 1000)
tstart = self.get_sim_time()
expected_thr = IDLE * 1.5 * 0.01 * 1000 + 1000 + 1
self.wait_servo_channel_value(8, expected_thr, timeout=2, comparator=operator.le)

# Check that the throttle drops to idle after cool down time
expected_thr = IDLE * 0.01 * 1000 + 1000 + 1
self.wait_servo_channel_value(8, expected_thr, timeout=COOLDOWN_TIME+1, comparator=operator.le)

measured_time = self.get_sim_time() - tstart
if (abs(measured_time - COOLDOWN_TIME) > 1.0):
raise NotAchievedException('Throttle did not reduce to idle within H_RSC_CLDWN_TIME')

self.set_rc(6, 1000)
self.wait_disarmed(timeout=20)

def TurbineStart(self, timeout=200):
"""Check Turbine Start Feature"""
RAMP_TIME = 4
Expand Down Expand Up @@ -980,6 +1027,7 @@ def tests(self):
self.FlyEachFrame,
self.AirspeedDrivers,
self.TurbineStart,
self.TurbineCoolDown,
self.NastyMission,
self.PIDNotches,
self.AutoTune,
Expand Down
22 changes: 14 additions & 8 deletions libraries/AP_Motors/AP_MotorsHeli_RSC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,10 @@ void AP_MotorsHeli_RSC::output(RotorControlState state)

// ensure _idle_throttle not set to invalid value
_idle_throttle = get_idle_output();

// reset fast idle timer
_fast_idle_timer = 0.0;

break;

case RotorControlState::IDLE:
Expand Down Expand Up @@ -331,14 +335,11 @@ void AP_MotorsHeli_RSC::output(RotorControlState state)
_starting = false;
}
} else {
if (_cooldown_time > 0) {
_idle_throttle = get_idle_output() * 1.5f;
_fast_idle_timer += dt;
if (_fast_idle_timer > (float)_cooldown_time) {
_fast_idle_timer = 0.0f;
}
} else {
_idle_throttle = get_idle_output();
_idle_throttle = get_idle_output();
if (_fast_idle_timer > 0.0) {
// running at fast idle for engine cool down
_idle_throttle *= 1.5;
_fast_idle_timer -= dt;
}
}
// this resets the bailout feature if the aircraft has landed.
Expand All @@ -353,6 +354,11 @@ void AP_MotorsHeli_RSC::output(RotorControlState state)
// set main rotor ramp to increase to full speed
update_rotor_ramp(1.0f, dt);

// set fast idle timer so next time RSC goes to idle, the cooldown timer starts
if (_cooldown_time.get() > 0) {
_fast_idle_timer = _cooldown_time.get();
}

// ensure _idle_throttle not set to invalid value due to premature switch out of turbine start
if (_starting) {
_idle_throttle = get_idle_output();
Expand Down
Loading