Skip to content

Commit 16b3e1c

Browse files
committed
autotest: add test for heading-relative yaw
1 parent a2e139b commit 16b3e1c

File tree

1 file changed

+84
-2
lines changed

1 file changed

+84
-2
lines changed

Tools/autotest/arducopter.py

Lines changed: 84 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4599,12 +4599,25 @@ def fly_guided_stop(self,
45994599
m.climb < climb_tolerance):
46004600
break
46014601

4602-
def send_set_position_target_global_int(self, lat, lon, alt):
4602+
def send_set_position_target_global_int_loc(self, loc):
4603+
self.send_set_position_target_global_int(
4604+
int(loc.lat*1e7),
4605+
int(loc.lng*1e7),
4606+
loc.alt,
4607+
frame=mavutil.mavlink.MAV_FRAME_GLOBAL,
4608+
)
4609+
4610+
def send_set_position_target_global_int(
4611+
self,
4612+
lat,
4613+
lon,
4614+
alt,
4615+
frame=mavutil.mavlink.MAV_FRAME_GLOBAL_RELATIVE_ALT_INT):
46034616
self.mav.mav.set_position_target_global_int_send(
46044617
0, # timestamp
46054618
1, # target system_id
46064619
1, # target component id
4607-
mavutil.mavlink.MAV_FRAME_GLOBAL_RELATIVE_ALT_INT,
4620+
frame,
46084621
MAV_POS_TARGET_TYPE_MASK.POS_ONLY, # mask specifying use-only-lat-lon-alt
46094622
lat, # lat
46104623
lon, # lon
@@ -9576,6 +9589,74 @@ def MAV_CMD_CONDITION_YAW(self):
95769589
self._MAV_CMD_CONDITION_YAW(self.run_cmd)
95779590
self.context_pop()
95789591

9592+
def MAV_CMD_CONDITION_YAW_heading_relative(self):
9593+
'''check relative-to-CoG yaw'''
9594+
self.takeoff(10, mode='GUIDED')
9595+
self.progress("First make sure it cancelsan absolute yaw")
9596+
for heading in 30, 60:
9597+
self.run_cmd_int(
9598+
mavutil.mavlink.MAV_CMD_CONDITION_YAW,
9599+
p1=heading, # target angle
9600+
p2=360, # degrees/second
9601+
p3=1, # -1 is counter-clockwise, 1 clockwise
9602+
p4=0, # 1 for relative, 0 for absolute
9603+
)
9604+
self.wait_heading(heading, minimum_duration=5)
9605+
9606+
here = self.mav.location()
9607+
t = self.offset_location_ne(here, 2000, 0)
9608+
9609+
self.do_reposition(t, frame=mavutil.mavlink.MAV_FRAME_GLOBAL)
9610+
9611+
# reposition cancels the condition-yaw:
9612+
self.run_cmd_int(
9613+
mavutil.mavlink.MAV_CMD_CONDITION_YAW,
9614+
p1=heading, # target angle
9615+
p2=360, # degrees/second
9616+
p3=1, # -1 is counter-clockwise, 1 clockwise
9617+
p4=0, # 1 for relative, 0 for absolute
9618+
)
9619+
self.wait_heading(60, minimum_duration=10)
9620+
9621+
self.progress("switch to yaw-looks-ahead")
9622+
self.run_cmd_int(
9623+
mavutil.mavlink.MAV_CMD_CONDITION_YAW,
9624+
p1=0, # target angle
9625+
p2=360, # degrees/second
9626+
p3=1, # -1 is counter-clockwise, 1 clockwise
9627+
p4=2, # 1 for relative, 0 for absolute, 2 for heading-relative
9628+
)
9629+
self.wait_heading(0, minimum_duration=10)
9630+
9631+
# turn on preserve-yaw
9632+
self.set_parameter("GUID_OPTIONS", 256)
9633+
9634+
self.progress("Now point 45-degrees to right of vehicle heading")
9635+
self.run_cmd_int(
9636+
mavutil.mavlink.MAV_CMD_CONDITION_YAW,
9637+
p1=45, # target angle
9638+
p2=360, # degrees/second
9639+
p3=1, # -1 is counter-clockwise, 1 clockwise
9640+
p4=2, # 1 for relative, 0 for absolute, 2 for heading-relative
9641+
)
9642+
self.wait_heading(45, minimum_duration=10)
9643+
9644+
self.progress("Heading east, checking yaw remains 45-degrees-to-heading")
9645+
here = self.mav.location()
9646+
t = self.offset_location_ne(here, 0, 2000)
9647+
9648+
self.send_set_position_target_global_int_loc(t)
9649+
self.wait_heading(135, minimum_duration=10)
9650+
9651+
self.progress("Heading east, checking yaw remains 45-degrees-to-heading")
9652+
here = self.mav.location()
9653+
t = self.offset_location_ne(here, 0, -2000)
9654+
9655+
self.send_set_position_target_global_int_loc(t)
9656+
self.wait_heading(315, minimum_duration=10)
9657+
9658+
self.do_RTL()
9659+
95799660
def GroundEffectCompensation_touchDownExpected(self):
95809661
'''Test EKF's handling of touchdown-expected'''
95819662
self.zero_throttle()
@@ -10415,6 +10496,7 @@ def tests1a(self):
1041510496
self.NavDelay,
1041610497
self.GuidedSubModeChange,
1041710498
self.MAV_CMD_CONDITION_YAW,
10499+
self.MAV_CMD_CONDITION_YAW_heading_relative,
1041810500
self.LoiterToAlt,
1041910501
self.PayloadPlaceMission,
1042010502
self.PrecisionLoiterCompanion,

0 commit comments

Comments
 (0)