From e64eec1fb3481ef20985c38c8a84c529644b8dd5 Mon Sep 17 00:00:00 2001 From: RexBerry <59031902+RexBerry@users.noreply.github.com> Date: Thu, 14 Nov 2024 18:15:52 -0600 Subject: [PATCH] Fix roll in gimbal rotation #29 --- flight/camera.py | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/flight/camera.py b/flight/camera.py index ffca31bb..899039a5 100644 --- a/flight/camera.py +++ b/flight/camera.py @@ -153,7 +153,9 @@ async def mapping_move_to( info: dict[str, CameraParameters] = {} drone.gimbal.rotate( - -drone.attitude.pitch - 90, 0, heading # pitch is relative to the drone + -drone.attitude.pitch - 90, + -drone.attitude.roll, + heading, # pitch and roll are relative to the drone ) await asyncio.sleep(1.0) @@ -183,9 +185,7 @@ async def mapping_move_to( next_interval_count: int = 1 while not goto_task.done(): # Keep gimbal pointed straight down - drone.gimbal.rotate( - -drone.attitude.pitch - 90, 0, heading # pitch is relative to the drone - ) + drone.gimbal.rotate(-drone.attitude.pitch - 90, -drone.attitude.roll, heading) position: dronekit.LocationGlobalRelative = drone.location.global_relative_frame @@ -206,9 +206,7 @@ async def mapping_move_to( await asyncio.sleep(0.25) - drone.gimbal.rotate( - -drone.attitude.pitch - 90, 0, heading # pitch is relative to the drone - ) + drone.gimbal.rotate(-drone.attitude.pitch - 90, -drone.attitude.roll, heading) await asyncio.sleep(1.0) camera_parameters = await self._get_camera_parameters(drone) @@ -271,7 +269,7 @@ async def odlc_move_to( # Point the gimbal straight down drone.gimbal.rotate( -drone.gimbal.pitch - 90, # pitch is relative to the drone - drone.gimbal.roll, + -drone.gimbal.roll, heading, )