@@ -4599,12 +4599,25 @@ def fly_guided_stop(self,
4599
4599
m .climb < climb_tolerance ):
4600
4600
break
4601
4601
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 ):
4603
4616
self .mav .mav .set_position_target_global_int_send (
4604
4617
0 , # timestamp
4605
4618
1 , # target system_id
4606
4619
1 , # target component id
4607
- mavutil . mavlink . MAV_FRAME_GLOBAL_RELATIVE_ALT_INT ,
4620
+ frame ,
4608
4621
MAV_POS_TARGET_TYPE_MASK .POS_ONLY , # mask specifying use-only-lat-lon-alt
4609
4622
lat , # lat
4610
4623
lon , # lon
@@ -9576,6 +9589,74 @@ def MAV_CMD_CONDITION_YAW(self):
9576
9589
self ._MAV_CMD_CONDITION_YAW (self .run_cmd )
9577
9590
self .context_pop ()
9578
9591
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
+
9579
9660
def GroundEffectCompensation_touchDownExpected (self ):
9580
9661
'''Test EKF's handling of touchdown-expected'''
9581
9662
self .zero_throttle ()
@@ -10415,6 +10496,7 @@ def tests1a(self):
10415
10496
self .NavDelay ,
10416
10497
self .GuidedSubModeChange ,
10417
10498
self .MAV_CMD_CONDITION_YAW ,
10499
+ self .MAV_CMD_CONDITION_YAW_heading_relative ,
10418
10500
self .LoiterToAlt ,
10419
10501
self .PayloadPlaceMission ,
10420
10502
self .PrecisionLoiterCompanion ,
0 commit comments