Skip to content
This repository has been archived by the owner on Nov 4, 2022. It is now read-only.

Feat/week1auto move #63

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion rio/autonomous/botchauto.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

from commands.kicker_button import Kicker
from commands.catapult import Catapult
from commands.flybywire import FlyByWire
from commands.flywithwires import FlyWithWires
from commands.zero_swerve import ZeroSwerveModules


Expand All @@ -24,4 +24,5 @@ def __init__(self, yoke: Yoke, drivetrain: Drivetrain) -> None:
Catapult(yoke, 75, 0.25, True), # Shoot like dis
WaitCommand(2), # Wait again
Kicker(yoke),
FlyWithWires(drivetrain, fwd=-0.2, time=2),
)
3 changes: 2 additions & 1 deletion rio/autonomous/highBotchAuto.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

from commands.kicker_button import Kicker
from commands.catapult import Catapult
from commands.flybywire import FlyByWire
from commands.flywithwires import FlyWithWires
from commands.zero_swerve import ZeroSwerveModules


Expand All @@ -24,4 +24,5 @@ def __init__(self, yoke: Yoke, drivetrain: Drivetrain) -> None:
Catapult(yoke, 78.5, 0.52, True), # Shoot like dis
WaitCommand(2), # Wait again
Kicker(yoke),
FlyWithWires(drivetrain, fwd=-0.2, time=2),
)
2 changes: 1 addition & 1 deletion rio/commands/catapult.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def end(self, interrupted: bool) -> None:
if not self.endWhenDone:
self.yoke.setSpeed(0)

print("Catapult done")
print("Catapult command ended")

# Return true when done
return True
Expand Down
46 changes: 46 additions & 0 deletions rio/commands/flywithwires.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import commands2
import wpilib

from subsystems.drivetrain import Drivetrain


class FlyWithWires(commands2.CommandBase):
"""
Fires a ball at a fixed angle with no checks or fancy stuff.
"""

def __init__(self, drivetrain: Drivetrain, fwd=0, srf=0, rot=0, time=-1) -> None:
super().__init__()

# Local instance of drivetrain
self.drivetrain = drivetrain

self.time = time
self.fwd = fwd
self.srf = srf
self.rot = rot

self.addRequirements([drivetrain])

# Timer
self.backgroundTimer = wpilib.Timer()
self.backgroundTimer.start()

def initialize(self) -> None:
self.backgroundTimer.reset()

def execute(self) -> None:
self.drivetrain.arcadeDrive(
self.fwd,
self.srf,
self.rot,
)

def end(self, interrupted: bool) -> None:
self.drivetrain.arcadeDrive(0, 0, 0)

print("Fly with wires done")

def isFinished(self) -> bool:
if self.time != -1 and self.backgroundTimer.hasElapsed(self.time):
return True
3 changes: 3 additions & 0 deletions rio/commands/kicker_button.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,6 @@ def isFinished(self) -> bool:
if self.backgroundTimer.hasElapsed(1):
self.yoke.kick(0)
return True

def end(self, interrupted: bool) -> None:
print("Kicker command ended")
3 changes: 1 addition & 2 deletions rio/commands/zero_swerve.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ def __init__(self, drivetrain, overwrite=False) -> None:
self.overwrite = overwrite

# Require full control of the drivetrain
if not overwrite:
self.addRequirements([self.drivetrain])
self.addRequirements([self.drivetrain])

# Timer
self.backgroundTimer = wpilib.Timer()
Expand Down
4 changes: 3 additions & 1 deletion rio/robot.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,10 @@ def autonomousInit(self) -> None:
if self.autonomousCommand:
self.autonomousCommand.schedule()

# Don't trigger an enabledInit(), auto can choose for itself.

# Trigger an enabledInit()
self.container.enabledInit()
# self.container.enabledInit()

def autonomousPeriodic(self) -> None:
"""This function is called periodically during autonomous"""
Expand Down