Skip to content

Commit

Permalink
WIP - the isStuck isn't working super great. It isn't actually stopping
Browse files Browse the repository at this point in the history
  • Loading branch information
1736student committed Oct 11, 2024
1 parent 4fe0d93 commit 7506b58
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
11 changes: 8 additions & 3 deletions drivetrain/controlStrategies/autoDrive.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,16 @@ class AutoDrive(metaclass=Singleton):
def __init__(self):
self._toSpeaker = False
self._toPickup = False
self._isStuck = False
self.rfp = RepulsorFieldPlanner()
self._trajCtrl = HolonomicDriveController()
self._telemTraj = []
self._obsDet = ObstacleDetector()

def setRequest(self, toSpeaker, toPickup) -> None:
def setRequest(self, toSpeaker, toPickup, isStuck) -> None:
self._toSpeaker = toSpeaker
self._toPickup = toPickup
self._isStuck = isStuck

def getTrajectory(self) -> Trajectory|None:
return None # TODO
Expand All @@ -52,13 +54,14 @@ def update(self, cmdIn: DrivetrainCommand, curPose: Pose2d) -> DrivetrainCommand
self.rfp._decay_observations()

# Handle command changes

if(self._toPickup):
self.rfp.setGoal(transform(GOAL_PICKUP))
elif(self._toSpeaker):
self.rfp.setGoal(transform(GOAL_SPEAKER))
elif(not self._toSpeaker and not self._toPickup):
self.rfp.setGoal(None)

# If being asked to auto-align, use the command from the dynamic path planner
if(self._toPickup or self._toSpeaker):
olCmd = self.rfp.update(curPose, MAX_DT_LINEAR_SPEED*0.02*SPEED_SCALAR)
Expand All @@ -67,6 +70,8 @@ def update(self, cmdIn: DrivetrainCommand, curPose: Pose2d) -> DrivetrainCommand
log("AutoDrive Rot Cmd", olCmd.velT, "radpers")
if( olCmd.desPose is not None):
retCmd = self._trajCtrl.update2(olCmd.velX, olCmd.velY, olCmd.velT, olCmd.desPose, curPose)

if(self._isStuck):
olCmd = self.rfp.update(curPose,0)
retCmd = self._trajCtrl.update2(0,0,0,curPose,curPose)

return retCmd
2 changes: 1 addition & 1 deletion robot.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ def teleopPeriodic(self):
obs = PointObstacle(location=(ct+tf), strength=0.7)
self.autodrive.rfp.add_obstcale_observaton(obs)

self.autodrive.setRequest(self.dInt.getNavToSpeaker(), self.dInt.getNavToPickup())
self.autodrive.setRequest(self.dInt.getNavToSpeaker(), self.dInt.getNavToPickup(), self.autodrive.rfp.isStuck())

# No trajectory in Teleop
Trajectory().setCmd(None)
Expand Down

0 comments on commit 7506b58

Please sign in to comment.