Skip to content

Commit

Permalink
style: format with black
Browse files Browse the repository at this point in the history
  • Loading branch information
megarubber committed Feb 29, 2024
1 parent 0b3d747 commit 0a3777b
Show file tree
Hide file tree
Showing 9 changed files with 41 additions and 34 deletions.
2 changes: 0 additions & 2 deletions 2023-base-code/version1/robot.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,10 @@ def robotInit(self):
self.stick = wpilib.Joystick(0)

def teleopInit(self):

self.myRobot.setSafetyEnabled(True)
self.compressor.disable()

def teleopPeriodic(self):

self.myRobot.arcadeDrive(
self.stick.getRawAxis(1), self.stick.getRawAxis(0) * 1.15, True
)
Expand Down
2 changes: 0 additions & 2 deletions 2023-base-code/version2/robot.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,10 @@ def robotInit(self):
self.stick = wpilib.Joystick(0)

def teleopInit(self):

self.myRobot.setSafetyEnabled(True)
self.compressor.disable()

def teleopPeriodic(self):

self.myRobot.arcadeDrive(
self.stick.getRawAxis(1), self.stick.getRawAxis(0) * 1.15, True
)
Expand Down
52 changes: 29 additions & 23 deletions 2023-base-code/version3-offseason/robot.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import ctre
import rev


class Taubatexas(wpilib.TimedRobot):
def robotInit(self):
# Drivetrain
Expand All @@ -21,7 +22,9 @@ def robotInit(self):
self.intake_bar_left = ctre.WPI_VictorSPX(5)
self.intake_bar_right = ctre.WPI_VictorSPX(12)
self.intake_bar_right.setInverted(True)
self.intake = wpilib.MotorControllerGroup(self.intake_bar_left, self.intake_bar_right)
self.intake = wpilib.MotorControllerGroup(
self.intake_bar_left, self.intake_bar_right
)

# Arm
self.length = rev.CANSparkMax(52, rev.CANSparkMaxLowLevel.MotorType.kBrushless)
Expand All @@ -40,25 +43,27 @@ def robotInit(self):
self.smartdashboard.putNumber("Intake Right", 0.25)
self.smartdashboard.putNumber("Arm Length Speed", 1)
self.smartdashboard.putNumber("Arm Angle Duty Cycle", 0.15)

# Joystick
self.joystick = wpilib.Joystick(0)

# Timer
self.timer = wpilib.Timer()

#self.angle_encoder.setPosition(0)
# self.angle_encoder.setPosition(0)

def robotPeriodic(self):
self.smartdashboard.putNumber('Arm Angle Encoder', self.angle_encoder.getPosition())
self.smartdashboard.putNumber(
"Arm Angle Encoder", self.angle_encoder.getPosition()
)

def getSpecificAxis(self):
if self.joystick.getRawAxis(4) > 0:
return self.joystick.getRawAxis(4)
return self.joystick.getRawAxis(4)
elif self.joystick.getRawAxis(3) > 0:
return -self.joystick.getRawAxis(3)
return -self.joystick.getRawAxis(3)
else:
return 0
return 0

def setIntake(self, left: float, right: float):
self.intake_bar_left.set(left)
Expand All @@ -74,23 +79,23 @@ def teleopPeriodic(self):
)

if self.joystick.getRawButton(1):
#self.intake.set(0.5)
# self.intake.set(0.5)
self.setIntake(
-self.smartdashboard.getNumber("Intake Left", 0.25),
-self.smartdashboard.getNumber("Intake Right", 0.25)
-self.smartdashboard.getNumber("Intake Right", 0.25),
)
elif self.joystick.getRawButton(2):
#self.intake.set(-0.5)
# self.intake.set(-0.5)
self.setIntake(
self.smartdashboard.getNumber("Intake Left", 0.25),
self.smartdashboard.getNumber("Intake Right", 0.25)
self.smartdashboard.getNumber("Intake Right", 0.25),
)
elif self.joystick.getRawButton(9):
self.intake_bar_left.set(0.1)
elif self.joystick.getRawButton(10):
self.intake_bar_right.set(0.1)
else:
#self.intake.set(0)
# self.intake.set(0)
self.setIntake(0, 0)

if self.joystick.getRawButton(5):
Expand All @@ -102,25 +107,24 @@ def teleopPeriodic(self):

if self.joystick.getRawButton(4):
self.angle_pid.setReference(
self.smartdashboard.getNumber('Arm Angle Duty Cycle', 0.15),
rev.CANSparkMax.ControlType.kDutyCycle
self.smartdashboard.getNumber("Arm Angle Duty Cycle", 0.15),
rev.CANSparkMax.ControlType.kDutyCycle,
)
self.position = self.angle_encoder.getPosition()
elif self.joystick.getRawButton(3):
self.angle_pid.setReference(
-self.smartdashboard.getNumber('Arm Angle Duty Cycle', 0.15),
rev.CANSparkMax.ControlType.kDutyCycle
-self.smartdashboard.getNumber("Arm Angle Duty Cycle", 0.15),
rev.CANSparkMax.ControlType.kDutyCycle,
)
self.position = self.angle_encoder.getPosition()
else:
self.angle_pid.setReference(
self.position,
rev.CANSparkMax.ControlType.kPosition
self.position, rev.CANSparkMax.ControlType.kPosition
)
#def disabledInit(self):

# def disabledInit(self):
# self.angle_encoder.setPosition(0)
'''
"""
def disabledPeriodic(self):
if(self.timer.get() < 5)
self.angle_pid.setReference(
Expand All @@ -129,6 +133,8 @@ def disabledPeriodic(self):
)
else:
self.timer.stop()
'''
"""


if __name__ == "__main__":
wpilib.run(Taubatexas)
wpilib.run(Taubatexas)
8 changes: 6 additions & 2 deletions 2023-photonvision/robot.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,12 @@ def robotInit(self):
constants.kP, constants.kI, constants.kD
)
self.drive = wpilib.drive.DifferentialDrive(
wpilib.MotorControllerGroup(phoenix5.WPI_VictorSPX(0), phoenix5.WPI_VictorSPX(1)),
wpilib.MotorControllerGroup(phoenix5.WPI_VictorSPX(2), phoenix5.WPI_VictorSPX(3)),
wpilib.MotorControllerGroup(
phoenix5.WPI_VictorSPX(0), phoenix5.WPI_VictorSPX(1)
),
wpilib.MotorControllerGroup(
phoenix5.WPI_VictorSPX(2), phoenix5.WPI_VictorSPX(3)
),
)

def robotPeriodic(self):
Expand Down
1 change: 0 additions & 1 deletion drive/drivetrain-navX/robot.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ def autonomousInit(self):
pass

def autonomousPeriodic(self):

# self.m_left_front.set(0.6)
# self.m_right_front.set(0.6)
# self.m_right_back.set(0.6)
Expand Down
2 changes: 1 addition & 1 deletion navX/robot.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def teleopInit(self):

def autonomousPeriodic(self):
yaw = self.navx.getAngle()
#print(yaw)
# print(yaw)

def teleopPeriodic(self):
pass
6 changes: 3 additions & 3 deletions networktables/using_keyboard.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import time
import ntcore # pip install robotpy
import keyboard # pip install keyboard
import ntcore # pip install robotpy
import keyboard # pip install keyboard

inst = ntcore.NetworkTableInstance.getDefault()
table = inst.getTable("keyboard")
Expand All @@ -18,4 +18,4 @@
while True:
event = keyboard.read_event()
if event.name:
table.putBoolean(event.name, event.event_type == keyboard.KEY_DOWN)
table.putBoolean(event.name, event.event_type == keyboard.KEY_DOWN)
1 change: 1 addition & 0 deletions smartdashboard/combobox/robot.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
@dataclass
class Option:
"""Class for keeping track of an item in inventory."""

name: str


Expand Down
1 change: 1 addition & 0 deletions smartdashboard/robot.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import wpilib
import phoenix5


class EasyNetworkTableExample(wpilib.TimedRobot):
def robotInit(self) -> None:
inst = ntcore.NetworkTableInstance.getDefault()
Expand Down

0 comments on commit 0a3777b

Please sign in to comment.