Skip to content
This repository has been archived by the owner on Jan 10, 2025. It is now read-only.

Commit

Permalink
Destroy swerve module
Browse files Browse the repository at this point in the history
  • Loading branch information
KenwoodFox committed Feb 29, 2024
1 parent 11b7ec0 commit 9c95706
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 8 deletions.
26 changes: 22 additions & 4 deletions rio/commands/climb.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import typing
import logging
import commands2

from constants import ClimberConstants
Expand All @@ -7,7 +9,15 @@


class Climb(commands2.Command):
def __init__(self, speed, _climber: Climber, _shooter: Shooter):
def __init__(
self,
_speed: typing.Callable[
[],
float,
],
_climber: Climber,
_shooter: Shooter,
):
"""
rotates the climber
"""
Expand All @@ -18,20 +28,28 @@ def __init__(self, speed, _climber: Climber, _shooter: Shooter):
self.shooter = _shooter

# local var of speed
self.speed = speed
self.speed = _speed

# Command requires
self.addRequirements((self.climber, self.shooter))

def execute(self):
if self.speed >= 0:
logging.debug(f"Climb is {self.speed()}")

if self.speed() == 0 or self.speed() >= 0.5:
# Positive numbers imply we're pulling DOWN
self.climber.setServoAngle(ClimberConstants.kServoLock)
self.shooter.rotateManual(
-self.speed() * ClimberConstants.kClimberShooterForward
)
else:
# Negative numbers imply we're relaxing
self.climber.setServoAngle(ClimberConstants.kservoOpen)
self.shooter.rotateManual(
-self.speed() * ClimberConstants.kClimberShooterBackward
)

self.climber.setClimberMotorSpeed(self.speed)
self.climber.setClimberMotorSpeed(self.speed())

def end(self, interrupted: bool):
self.climber.setClimberMotorSpeed(0)
4 changes: 3 additions & 1 deletion rio/commands/shooterROT.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ def initialize(self):
def execute(self):
self.subsystem.setRotateAngle(self.angle)

logging.debug(f"Still moving... {self.subsystem.getAngle()} to {self.angle}")
logging.info(
f"Shooter still moving... {self.subsystem.getAngle()} to {self.angle}"
)

def isFinished(self) -> bool:
return abs(self.subsystem.getAngle() - self.angle) < 10
Expand Down
4 changes: 2 additions & 2 deletions rio/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,10 +198,10 @@ class ClimberConstants:
kServoID = 0

# inversions
kInversion = False
kInversion = True

# servo angles
kServoLock = 0.0
kServoLock = -0.1
kservoOpen = 0.165

# Relationship between climber speed and shooter angle (rough but ugh..)
Expand Down
2 changes: 1 addition & 1 deletion rio/robotcontainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ def configureButtonBindings(self) -> None:
# Climbing
self.opController.rightBumper().whileTrue(
Climb(
self.opController.getRightTriggerAxis()
lambda: self.opController.getRightTriggerAxis()
- self.opController.getLeftTriggerAxis(),
self.climber,
self.shooter,
Expand Down

0 comments on commit 9c95706

Please sign in to comment.