Skip to content

Commit

Permalink
added the new rotation approach for buoys
Browse files Browse the repository at this point in the history
  • Loading branch information
tjcanro committed Feb 25, 2024
1 parent 679108a commit 44a572f
Showing 1 changed file with 19 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from .sub_singleton import SubjuGatorMission
import numpy as np


""""
class StartSignal(SubjuGatorMission):
buoy_positions = [[5, 10, 3], [6, 8, 5], [3, 12, 10]] # x, y, z displacements
Expand All @@ -20,15 +20,30 @@ async def run(self, args):
.right(-self.buoy_positions[i][0])
.up(-self.buoy_positions[i][1].forward(-self.buoy_positions[i][2])),
)
"""

async def run_rotation(self, args):
for i in len(self.args):
pitch_angle = np.arctan(self.buoy_positions[i][2]/self.buoy_positions[i][1])
yaw_angle = np.arctan(self.buoy_positions[i][0]/self.buoy_positions[i][1])
yaw_angle = np.arctan(self.buoy_positions[i][2]/self.buoy_positions[i][0])
self.send_feedback(f"Rotating towards Buoy {i}")
await self.go(
# Yaw to the right if the x distance is positive and to the left if negative
# Yaw to left otherwise
#
self.move()
.yaw_left(yaw_angle) if self.buoy_positions[i][0] < 0 else .yaw_right(yaw_angle)

# If the pitch angle is positive, pitch up, if negative, pitch down
.pitch_up(pitch_angle) if pitch_angle > 0 else .pitch_down(abs(pitch_angle))
)
self.send_feedback(f"Traveling forward to buoy {i}")
await self.go(
self.move(
.forward(self.buoy_positions[i][2])
)
)
self.send_feedback("Back to Origin")
await self.go(
self.move()
.forward(-self.buoy_positions[i][2])
)

0 comments on commit 44a572f

Please sign in to comment.