Tools: autotest: more efficient set_rc_from_map

This commit is contained in:
Peter Barker authored and Peter Barker committed 2019-06-02 10:02:24 +10:00
1 parent 3f71a84894
commit e9552ec4e1
1 file changed
+17 -5
+17 -5
View File
@@ -740,11 +740,23 @@ class AutoTest(ABC):
16: 1500,
}
def set_rc_from_map(self, _map):
for chan in _map:
value = _map[chan]
self.set_rc(chan, value)
# self.mavproxy.send('rc %u value\n' % (chan, value))
def set_rc_from_map(self, _map, timeout=2000):
copy = _map.copy()
tstart = self.get_sim_time()
while len(copy.keys()):
if self.get_sim_time_cached() - tstart > timeout:
raise SetRCTimeout("Failed to set RC channels")
for chan in copy:
value = copy[chan]
self.send_set_rc(chan, value)
m = self.mav.recv_match(type='RC_CHANNELS', blocking=True)
self.progress("m: %s" % m)
new = dict()
for chan in copy:
chan_pwm = getattr(m, "chan" + str(chan) + "_raw")
if chan_pwm != copy[chan]:
new[chan] = copy[chan]
copy = new
def set_rc_default(self):
"""Setup all simulated RC control to 1500."""