Skip to content

Commit

Permalink
Merge pull request #187 from thedropbears/auto-start-pose-get
Browse files Browse the repository at this point in the history
autonomous: Add get_starting_pose() method
  • Loading branch information
LucienMorey authored Mar 11, 2024
2 parents d1274eb + 6c600c9 commit a7b2cca
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions autonomous/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,8 @@ def setup(self) -> None:

def on_enable(self):
# Setup starting position in the simulator
if RobotBase.isSimulation() and self.starting_pose is not None:
starting_pose = self.starting_pose
if not game.is_red():
starting_pose = game.field_flip_pose2d(self.starting_pose)
starting_pose = self.get_starting_pose()
if RobotBase.isSimulation() and starting_pose is not None:
self.chassis.set_pose(starting_pose)
super().on_enable()

Expand All @@ -91,6 +89,14 @@ def is_close_enough_to_shoot(self) -> bool:
).norm() < self.SHOOTING_POSITION_TOLERANCE
return False

def get_starting_pose(self) -> Pose2d | None:
starting_pose = self.starting_pose
if starting_pose is None:
return None
if not game.is_red():
starting_pose = game.field_flip_pose2d(starting_pose)
return starting_pose

@state(first=True)
def initialise(self) -> None:
# Make a working copy of the NotePaths so that we can pop
Expand Down

0 comments on commit a7b2cca

Please sign in to comment.