|
|
@ -5596,6 +5596,32 @@ class AutoTest(ABC): |
|
|
|
pos += 1 |
|
|
|
pos += 1 |
|
|
|
return None |
|
|
|
return None |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def get_rpm(self, rpm_sensor): |
|
|
|
|
|
|
|
m = self.assert_receive_message('RPM') |
|
|
|
|
|
|
|
if rpm_sensor == 1: |
|
|
|
|
|
|
|
ret = m.rpm1 |
|
|
|
|
|
|
|
elif rpm_sensor == 2: |
|
|
|
|
|
|
|
ret = m.rpm2 |
|
|
|
|
|
|
|
else: |
|
|
|
|
|
|
|
raise ValueError("Bad sensor id") |
|
|
|
|
|
|
|
if ret < 0.000001: |
|
|
|
|
|
|
|
# yay filtering! |
|
|
|
|
|
|
|
return 0 |
|
|
|
|
|
|
|
return ret |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def wait_rpm(self, rpm_sensor, rpm_min, rpm_max, **kwargs): |
|
|
|
|
|
|
|
'''wait for RPM to be between rpm_min and rpm_max''' |
|
|
|
|
|
|
|
def validator(value2, target2=None): |
|
|
|
|
|
|
|
return rpm_min <= value2 <= rpm_max |
|
|
|
|
|
|
|
self.wait_and_maintain( |
|
|
|
|
|
|
|
value_name="RPM%u" % rpm_sensor, |
|
|
|
|
|
|
|
target=(rpm_min+rpm_max)/2.0, |
|
|
|
|
|
|
|
current_value_getter=lambda: self.get_rpm(rpm_sensor), |
|
|
|
|
|
|
|
accuracy=rpm_max-rpm_min, |
|
|
|
|
|
|
|
validator=lambda value2, target2: validator(value2, target2), |
|
|
|
|
|
|
|
**kwargs |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
def wait_esc_telem_rpm(self, esc, rpm_min, rpm_max, **kwargs): |
|
|
|
def wait_esc_telem_rpm(self, esc, rpm_min, rpm_max, **kwargs): |
|
|
|
'''wait for ESC to be between rpm_min and rpm_max''' |
|
|
|
'''wait for ESC to be between rpm_min and rpm_max''' |
|
|
|
def validator(value2, target2=None): |
|
|
|
def validator(value2, target2=None): |
|
|
@ -5750,6 +5776,8 @@ class AutoTest(ABC): |
|
|
|
count_of_achieved_values = 0 |
|
|
|
count_of_achieved_values = 0 |
|
|
|
called_function = kwargs.get("called_function", None) |
|
|
|
called_function = kwargs.get("called_function", None) |
|
|
|
minimum_duration = kwargs.get("minimum_duration", 0) |
|
|
|
minimum_duration = kwargs.get("minimum_duration", 0) |
|
|
|
|
|
|
|
if minimum_duration >= timeout: |
|
|
|
|
|
|
|
raise ValueError("minimum_duration >= timeout") |
|
|
|
if type(target) is Vector3: |
|
|
|
if type(target) is Vector3: |
|
|
|
self.progress("Waiting for %s=(%s) with accuracy %.02f" % (value_name, str(target), accuracy)) |
|
|
|
self.progress("Waiting for %s=(%s) with accuracy %.02f" % (value_name, str(target), accuracy)) |
|
|
|
else: |
|
|
|
else: |
|
|
@ -11300,7 +11328,7 @@ switch value''' |
|
|
|
tstart = self.get_sim_time() |
|
|
|
tstart = self.get_sim_time() |
|
|
|
while True: |
|
|
|
while True: |
|
|
|
t = self.get_sim_time_cached() |
|
|
|
t = self.get_sim_time_cached() |
|
|
|
if t - tstart > 10: |
|
|
|
if t - tstart > timeout: |
|
|
|
raise AutoTestTimeoutException("Failed to do get valid RPM") |
|
|
|
raise AutoTestTimeoutException("Failed to do get valid RPM") |
|
|
|
rpm = self.mav.recv_match( |
|
|
|
rpm = self.mav.recv_match( |
|
|
|
type='RPM', |
|
|
|
type='RPM', |
|
|
|