generated from Choate-Robotics/7407-DriveCode-Template-v2
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added arm command file & config angles
- Loading branch information
1 parent
48263e2
commit 7b5f076
Showing
2 changed files
with
91 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
import math | ||
|
||
import wpilib # noqa | ||
from commands2 import SequentialCommandGroup # noqa | ||
|
||
import config | ||
import constants # noqa | ||
import utils # noqa | ||
from oi.keymap import Controllers # noqa | ||
from subsystem import Arm | ||
from toolkit.command import SubsystemCommand | ||
from units.SI import radians | ||
from enum import Enum | ||
|
||
|
||
# cmds: set arm (angle), zero arm, specific positions that inherit from set arm | ||
|
||
class SetArm(SubsystemCommand[Arm]): | ||
""" | ||
Sets the wrist to a given angle (radians). | ||
param: angle in radians | ||
""" | ||
|
||
def __init__(self, subsystem: Arm, angle: float): | ||
super().__init__(subsystem) | ||
self.subsystem = subsystem | ||
self.angle = angle | ||
|
||
def initialize(self): | ||
# change to actual name | ||
self.subsystem.set_angle(self.angle) | ||
self.subsystem.is_rotating = True | ||
|
||
def execute(self): | ||
pass | ||
|
||
def isFinished(self): | ||
return self.subsystem.is_at_angle(self.angle) | ||
|
||
def end(self, interrupted: bool): | ||
if interrupted: | ||
arm_angle = self.subsystem.get_angle() | ||
|
||
self.subsystem.is_rotating = False | ||
|
||
|
||
class ZeroArm(SubsystemCommand[Arm]): | ||
""" | ||
Zeros the arm. | ||
""" | ||
|
||
def __init__(self, subsystem: Arm): | ||
super().__init__(subsystem) | ||
self.subsystem = subsystem | ||
|
||
def initialize(self): | ||
# change to actual name | ||
self.subsystem.zero_arm() | ||
|
||
def execute(self): | ||
pass | ||
|
||
def isFinished(self): | ||
return self.subsystem.is_zeroed() | ||
|
||
def end(self, interrupted: bool): | ||
if not interrupted: | ||
self.subsystem.arm_zeroed = True | ||
else: | ||
... | ||
|
||
|
||
class SetSpeakerPosition(SetArm): | ||
def __init__(self, subsystem: Arm): | ||
super().__init__(subsystem, radians(config.speaker_angle)) | ||
|
||
|
||
class SetAmpPosition(SetArm): | ||
def __init__(self, subsystem: Arm): | ||
super().__init__(subsystem, radians(config.amp_angle)) | ||
|
||
|
||
class SetIntakePosition(SetArm): | ||
def __init__(self, subsystem: Arm): | ||
super().__init__(subsystem, radians(config.intake_angle)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters