Skip to content

Commit

Permalink
Lookahead runs in simulation, but not on real robot
Browse files Browse the repository at this point in the history
  • Loading branch information
gerth2 committed Nov 15, 2024
1 parent 91c152b commit f1cc8fe
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
4 changes: 0 additions & 4 deletions drivetrain/poseEstimation/drivetrainPoseTelemetry.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,6 @@ def update(self, estPose:Pose2d, moduleAngles):
self.field.getObject("curObstaclesFull").setPoses([Pose2d(x, Rotation2d()) for x in self.fullObstacles])
self.field.getObject("curObstaclesThird").setPoses([Pose2d(x, Rotation2d()) for x in self.thirdObstacles])
self.field.getObject("curObstaclesAlmostGone").setPoses([Pose2d(x, Rotation2d()) for x in self.almostGoneObstacles])
#print("Full: " + str(len(self.fullObstacles)))
#print("Third: " + str(len(self.thirdObstacles)))
#print("Almost gone: " + str(len(self.almostGoneObstacles)))


self.field.getObject("visionObservations").setPoses(self.visionPoses)
self.visionPoses = []
Expand Down
9 changes: 8 additions & 1 deletion navigation/repulsorFieldPlanner.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from wpilib import TimedRobot
from wpimath.geometry import Pose2d, Translation2d, Rotation2d

from utils.mapLookup2d import MapLookup2D
Expand Down Expand Up @@ -261,7 +262,13 @@ def update(self, curCmd:DrivetrainCommand, stepSize_m:float) -> DrivetrainComman
self.startSlowFactor = min(self.startSlowFactor, 1.0)

nextCmd = self._getCmd(curCmd, stepSize_m)
# self._doLookahead(curCmd)

if(TimedRobot.isSimulation()):
# Lookahead is for telemetry and debug only, and is very
# time expensive. We'll do it in simulation, but not on the
# real robot.
self._doLookahead(curCmd)

return nextCmd

def _getCmd(self, curCmd:DrivetrainCommand, stepSize_m:float) -> DrivetrainCommand:
Expand Down

0 comments on commit f1cc8fe

Please sign in to comment.