Skip to content

Commit

Permalink
autotest: add simple test for ship operations
Browse files Browse the repository at this point in the history
  • Loading branch information
peterbarker committed Oct 19, 2023
1 parent def0f8e commit 1e7a5e5
Show file tree
Hide file tree
Showing 2 changed files with 90 additions and 0 deletions.
45 changes: 45 additions & 0 deletions Tools/autotest/ArduCopter_Tests/ShipOps/ShipLanding.param
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
FOLL_ENABLE,1
FOLL_OFS_TYPE,1
FOLL_OFS_X,0
FOLL_OFS_Y,0
FOLL_OFS_Z,0
FOLL_POS_P,0.1
FOLL_SYSID,17
FOLL_YAW_BEHAVE,2
BATT_FS_LOW_ACT,7
FS_GCS_ENABLE,7
FS_THR_ENABLE,7
FS_EKF_ACTION,1
GRIP_ENABLE,1
GRIP_GRAB,1000
GRIP_NEUTRAL,1000
GRIP_REGRAB,0
GRIP_RELEASE,2000
GRIP_TYPE,1
GRIP_CAN_ID,0
INS_GYR_CAL,0
LOG_BITMASK,176127
PSC_ANGLE_MAX,25
RC6_OPTION,174
RC7_OPTION,175
RC8_OPTION,19
SERVO9_FUNCTION,146
SERVO9_MAX,2000
SERVO9_MIN,1000
SERVO9_REVERSED,1
SERVO9_TRIM,1500
SERVO10_FUNCTION,28
SERVO10_MAX,2000
SERVO10_MIN,1000
SERVO10_REVERSED,0
SERVO10_TRIM,1500
SIM_SHIP_DSIZE,10
SIM_SHIP_ENABLE,1
SIM_SHIP_OFS_X,0
SIM_SHIP_OFS_Y,0
SIM_SHIP_OFS_Z,0
SIM_SHIP_PSIZE,1000
SIM_SHIP_SPEED,3
SIM_SHIP_SYSID,17
WPNAV_SPEED_DN,250
WPNAV_SPEED_UP,250
45 changes: 45 additions & 0 deletions Tools/autotest/arducopter.py
Original file line number Diff line number Diff line change
Expand Up @@ -8001,6 +8001,50 @@ def ShipTakeoff(self):
# ship will have moved on, so we land on the water which isn't moving
self.wait_groundspeed(0, 2)

def ShipOps(self):
'''Fly Simulated Ship Operations'''
self.load_params_file("ShipLanding.param")

self.progress("Change to ShipOps mode")
self.change_mode(29) # 29 is ship ops
self.wait_ready_to_arm()

ship_speed = self.get_parameter('SIM_SHIP_SPEED')

self.progress("ensure we are be moving with the ship")
self.wait_groundspeed(ship_speed-0.1, ship_speed+0.1)

self.progress("arm vehicle and make sure we continue to move with ship")
self.arm_vehicle()
self.wait_groundspeed(ship_speed-0.1, ship_speed+0.1, minimum_duration=2)

self.progress("put system into launch/retrieve mode")
aux_func_ship_ops = 175
self.run_auxfunc(aux_func_ship_ops, 2)

abs_alt = self.get_altitude(relative=False)

perch_alt = self.get_parameter('SHIP_PCH_ALT')

# self.set_parameter("SIM_SPEEDUP", 1)

self.progress("trigger launch")
self.set_rc(3, 2000)

self.wait_altitude(perch_alt-0.5, perch_alt+0.5, minimum_duration=5, relative=True, timeout=30)

# should retain our groundspeed to match the vehicle we are following
self.wait_groundspeed(ship_speed-0.1, ship_speed+0.1, minimum_duration=10)

# check offsets here
# self.mavproxy.interact()
self.progress("trigger recovery")
self.set_rc(3, 1000)

self.wait_altitude(abs_alt-5, abs_alt+5, minimum_duration=5, timeout=60)
self.wait_disarmed()


def ParameterValidation(self):
'''Test parameters are checked for validity'''
# wait 10 seconds for initialisation
Expand Down Expand Up @@ -9807,6 +9851,7 @@ def tests2b(self): # this block currently around 9.5mins here
self.FlyMissionTwice,
self.IMUConsistency,
self.AHRSTrimLand,
self.ShipOps,
])
return ret

Expand Down

0 comments on commit 1e7a5e5

Please sign in to comment.