Tools: autotest: refactor setting of rc defaults

This commit is contained in:
Peter Barker 2019-02-03 21:43:07 +11:00 committed by Peter Barker
parent 9b540a6380
commit fa37ad344b
5 changed files with 51 additions and 21 deletions

View File

@ -1014,10 +1014,11 @@ Brakes have negligible effect (with=%0.2fm without=%0.2fm delta=%0.2fm)
])
return ret
def set_rc_default(self):
super(AutoTestRover, self).set_rc_default()
self.set_rc(3, 1000)
self.set_rc(8, 1800)
def rc_defaults(self):
ret = super(AutoTestRover, self).rc_defaults()
ret[3] = 1000
ret[8] = 1800
return ret;
def default_mode(self):
return 'MANUAL'

View File

@ -2574,9 +2574,10 @@ class AutoTestCopter(AutoTest):
def default_mode(self):
return "STABILIZE"
def set_rc_default(self):
super(AutoTestCopter, self).set_rc_default()
self.set_rc(3, 1000)
def rc_defaults(self):
ret = super(AutoTestCopter, self).rc_defaults()
ret[3] = 1000
return ret
def tests(self):
'''return list of all tests'''
@ -2742,11 +2743,11 @@ class AutoTestHeli(AutoTestCopter):
AVCHOME.heading)
self.frame = 'heli'
def set_rc_default(self):
super(AutoTestCopter, self).set_rc_default()
self.progress("Lowering rotor speed")
self.set_rc(8, 1000)
self.set_rc(3, 1000) # collective
def rc_defaults(self):
ret = super(AutoTestHeli, self).rc_defaults()
ret[8] = 1000
ret[3] = 1000 # collective
return ret
def tests(self):
'''return list of all tests'''

View File

@ -730,10 +730,11 @@ class AutoTestPlane(AutoTest):
lambda: self.fly_mission(
os.path.join(testdir, "ap1.txt")))
def set_rc_default(self):
super(AutoTestPlane, self).set_rc_default()
self.set_rc(3, 1000)
self.set_rc(8, 1800)
def rc_defaults(self):
ret = super(AutoTestPlane, self).rc_defaults()
ret[3] = 1000
ret[8] = 1800
return ret
def default_mode(self):
return "MANUAL"

View File

@ -53,9 +53,10 @@ class AutoTestBalanceBot(AutoTestRover):
self.do_set_mode_via_command_long("HOLD")
self.do_set_mode_via_command_long("MANUAL")
def set_rc_default(self):
super(AutoTestBalanceBot, self).set_rc_default()
self.set_rc(3, 1500)
def rc_defaults(self):
ret = super(AutoTestBalanceBot, self).rc_defaults()
ret[3] = 1500
return ret
def tests(self):
'''return list of all tests'''

View File

@ -602,10 +602,36 @@ class AutoTest(ABC):
self.progress("num_wp: %d" % num_wp)
return num_wp
def rc_defaults(self):
return {
1: 1500,
2: 1500,
3: 1500,
4: 1500,
5: 1500,
6: 1500,
7: 1500,
8: 1500,
9: 1500,
10: 1500,
11: 1500,
12: 1500,
13: 1500,
14: 1500,
15: 1500,
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_default(self):
"""Setup all simulated RC control to 1500."""
for chan in range(1, 16):
self.mavproxy.send('rc %u 1500\n' % chan)
_defaults = self.rc_defaults()
self.set_rc_from_map(_defaults)
def set_rc(self, chan, pwm, timeout=2000):
"""Setup a simulated RC control to a PWM value"""