Skip to content

Commit 2a6693f

Browse files
committed
Tools: Create Manual Control autotest for Sub
1 parent 1b34668 commit 2a6693f

1 file changed

Lines changed: 59 additions & 0 deletions

File tree

Tools/autotest/ardusub.py

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
import vehicle_test_suite
1818

19+
from vehicle_test_suite import AutoTestTimeoutException
1920
from vehicle_test_suite import NotAchievedException
2021

2122
# get location of scripts
@@ -673,6 +674,63 @@ def GripperMission(self):
673674
self.wait_waypoint(1, 6, max_dist=5)
674675
self.disarm_vehicle()
675676

677+
def MANUAL_CONTROL(self):
678+
'''Test mavlink MANUAL_CONTROL'''
679+
680+
self.change_mode("MANUAL")
681+
self.wait_ready_to_arm()
682+
self.arm_vehicle()
683+
684+
self.start_subsubtest("Manual control works by default")
685+
686+
want_pitch = 0.003
687+
want_speed = 2.0
688+
tstart = self.get_sim_time_cached()
689+
while True:
690+
if self.get_sim_time_cached() - tstart > 10:
691+
raise AutoTestTimeoutException("Did not reach speed")
692+
self.set_rc(Joystick.Throttle, 1600)
693+
self.set_rc(Joystick.Forward, 1600)
694+
self.set_rc(Joystick.Lateral, 1550)
695+
self.mav.mav.manual_control_send(
696+
1, # target system
697+
500, # x forward
698+
0, # y lateral
699+
0, # z vertical
700+
0, # r yaw
701+
0, # buttons
702+
0, # buttons2
703+
192, # roll and pitch enabled
704+
0, # pitch
705+
0) # roll
706+
m = self.assert_receive_message('VFR_HUD')
707+
if m.groundspeed < want_speed:
708+
break
709+
710+
self.start_subsubtest("Manual control works for pitch axis")
711+
while True:
712+
if self.get_sim_time_cached() - tstart > 10:
713+
raise AutoTestTimeoutException("Did not reach pitch with control")
714+
self.set_rc(Joystick.Throttle, 1600)
715+
self.set_rc(Joystick.Forward, 1600)
716+
self.set_rc(Joystick.Lateral, 1550)
717+
self.mav.mav.manual_control_send(
718+
1, # target system
719+
0, # x forward
720+
0, # y lateral
721+
0, # z vertical
722+
0, # r yaw
723+
0, # buttons
724+
0, # buttons2
725+
192, # roll and pitch enabled
726+
500, # pitch
727+
0) # roll
728+
m = self.assert_receive_message('ATTITUDE')
729+
if m.pitch < want_pitch:
730+
break
731+
732+
self.disarm_vehicle()
733+
676734
def SET_POSITION_TARGET_GLOBAL_INT(self):
677735
'''Move vehicle using SET_POSITION_TARGET_GLOBAL_INT'''
678736
self.change_mode('GUIDED')
@@ -1369,6 +1427,7 @@ def tests(self):
13691427
self.MAV_mgs,
13701428
self.DiveMission,
13711429
self.GripperMission,
1430+
self.MANUAL_CONTROL,
13721431
self.DoubleCircle,
13731432
self.MotorThrustHoverParameterIgnore,
13741433
self.SET_POSITION_TARGET_GLOBAL_INT,

0 commit comments

Comments
 (0)