Skip to content

Commit

Permalink
Fix gimbal rotate command #29
Browse files Browse the repository at this point in the history
  • Loading branch information
RexBerry committed Nov 15, 2024
1 parent 58c2009 commit 79473e7
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions flight/camera.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,9 @@ async def mapping_move_to(
info: dict[str, CameraParameters] = {}

drone.gimbal.rotate(
-drone.attitude.pitch - 90,
-drone.attitude.roll,
heading, # pitch and roll are relative to the drone
round(-drone.attitude.pitch - 90), # must use integers
round(-drone.attitude.roll),
round(heading), # pitch and roll are relative to the drone
)
await asyncio.sleep(1.0)

Expand Down Expand Up @@ -185,7 +185,9 @@ 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, -drone.attitude.roll, heading)
drone.gimbal.rotate(
round(-drone.attitude.pitch - 90), round(-drone.attitude.roll), round(heading)
)

position: dronekit.LocationGlobalRelative = drone.location.global_relative_frame

Expand All @@ -206,7 +208,9 @@ async def mapping_move_to(

await asyncio.sleep(0.25)

drone.gimbal.rotate(-drone.attitude.pitch - 90, -drone.attitude.roll, heading)
drone.gimbal.rotate(
round(-drone.attitude.pitch - 90), round(-drone.attitude.roll), round(heading)
)
await asyncio.sleep(1.0)

camera_parameters = await self._get_camera_parameters(drone)
Expand Down Expand Up @@ -268,9 +272,9 @@ async def odlc_move_to(
if take_photos:
# Point the gimbal straight down
drone.gimbal.rotate(
-drone.gimbal.pitch - 90, # pitch is relative to the drone
-drone.gimbal.roll,
heading,
round(-drone.gimbal.pitch - 90),
round(-drone.gimbal.roll),
round(heading),
)

await asyncio.sleep(2)
Expand Down

0 comments on commit 79473e7

Please sign in to comment.