This repository was archived by the owner on Jan 5, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d7ab473
commit c574e1e
Showing
22 changed files
with
342 additions
and
136 deletions.
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,45 @@ | ||
from commands2 import SequentialCommandGroup | ||
|
||
from commands.autonomouscommandgroup import AutonomousCommandGroup | ||
|
||
from custom import driverhud | ||
|
||
from networktables import NetworkTables | ||
|
||
excludedMethods = [ | ||
"interrupted" | ||
] # Methods that aren't from the parents but aren't autos. If you want to exclude a program because it might not work, add it here. | ||
|
||
table = NetworkTables.getTable("Autonomous") | ||
autoVars = [var.lower() for var in dir(AutonomousCommandGroup)] | ||
|
||
definedAutos = [] | ||
for auto in autoVars: | ||
if ( | ||
auto[0] != "_" # Make sure it's not one of Python's methods. | ||
and auto | ||
not in [ | ||
var.lower() for var in dir(SequentialCommandGroup) | ||
] # Make sure it's not from the parent. | ||
and auto | ||
not in excludedMethods # Other methods to exclude that are in the Auto command group. | ||
): | ||
definedAutos.append(auto) | ||
|
||
|
||
def init(): | ||
print(definedAutos) | ||
table.putStringArray("autos", [a.lower() for a in definedAutos]) | ||
try: | ||
table.putString("selectedAuto", definedAutos[0].lower()) | ||
except(IndexError): | ||
table.putString("selectedAuto", "NO AUTO FOUND") | ||
|
||
def getAutoProgram(): | ||
""" | ||
Returns the first defined auto if none are selected. | ||
""" | ||
try: | ||
return table.getString("selectedAuto", (definedAutos[0]).lower()) | ||
except(IndexError): | ||
raise Exception("You don't have any autos defined!") |
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
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
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
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 |
---|---|---|
@@ -1,15 +1,13 @@ | ||
from wpilib.command import InstantCommand | ||
from commands2 import InstantCommand | ||
|
||
import robot | ||
|
||
class ResetTiltCommand(InstantCommand): | ||
|
||
def __init__(self): | ||
super().__init__('Set Tilt to 0') | ||
|
||
self.requires(robot.drivetrain) | ||
self.setRunWhenDisabled(True) | ||
super().__init__() | ||
|
||
self.addRequirements(robot.drivetrain) | ||
|
||
def initialize(self): | ||
robot.drivetrain.resetTilt() |
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
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
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 |
---|---|---|
@@ -1,14 +1,17 @@ | ||
from wpilib.command import CommandGroup | ||
import commandbased.flowcontrol as fc | ||
from commands2 import ParallelCommandGroup | ||
|
||
import robot | ||
|
||
from .drivetrain.resettiltcommand import ResetTiltCommand | ||
|
||
class StartUpCommandGroup(CommandGroup): | ||
class StartUpCommandGroup(ParallelCommandGroup): | ||
|
||
def __init__(self): | ||
super().__init__('Start Up') | ||
self.setRunWhenDisabled(True) | ||
super().__init__() | ||
|
||
self.addParallel(ResetTiltCommand()) | ||
robot.drivetrain.initDefaultCommand() | ||
|
||
self.addCommands(ResetTiltCommand()) | ||
|
||
def runsWhenDisabled(self): | ||
return True |
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
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
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
This file was deleted.
Oops, something went wrong.
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
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
Oops, something went wrong.