Skip to content

Commit 453bb39

Browse files
committed
formatting
1 parent f68a8e4 commit 453bb39

File tree

7 files changed

+29
-17
lines changed

7 files changed

+29
-17
lines changed

digital-communication/robot.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88

99

1010
class MyRobot(wpilib.TimedRobot):
11-
1211
# define ports for digitalcommunication with light controller
1312
ALLIANCE_PORT = 0
1413
ENABLED_PORT = 1

dutycycle-encoder/robot.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55

66
class MyRobot(wpilib.TimedRobot):
7-
87
def robotInit(self):
98
"""Robot initialization function"""
109

dutycycle-input/robot.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55

66
class MyRobot(wpilib.TimedRobot):
7-
87
def robotInit(self):
98
"""Robot initialization function"""
109

encoder/robot.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818

1919

2020
class MyRobot(wpilib.TimedRobot):
21-
2221
def robotInit(self):
2322
"""Robot initialization function"""
2423

flywheel-bangbang-controller/robot.py

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414

1515

1616
class MyRobot(wpilib.TimedRobot):
17-
1817
MOTOR_PORT = 0
1918
ENCODER_A_CHANNEL = 0
2019
ENCODER_B_CHANNEL = 1
@@ -32,12 +31,18 @@ class MyRobot(wpilib.TimedRobot):
3231
FLYWHEEL_GEARING = 1.0
3332

3433
# 1/2 MR²
35-
FLYWHEEL_MOMENT_OF_INERTIA = 0.5 * wpimath.units.lbsToKilograms(1.5) * math.pow(wpimath.units.inchesToMeters(4), 2)
34+
FLYWHEEL_MOMENT_OF_INERTIA = (
35+
0.5
36+
* wpimath.units.lbsToKilograms(1.5)
37+
* math.pow(wpimath.units.inchesToMeters(4), 2)
38+
)
3639

3740
def robotInit(self):
3841
"""Robot initialization function"""
3942

40-
self.feedforward = wpimath.controller.SimpleMotorFeedforwardMeters(self.FLYWHEEL_KS, self.FLYWHEEL_KV, self.FLYWHEEL_KA)
43+
self.feedforward = wpimath.controller.SimpleMotorFeedforwardMeters(
44+
self.FLYWHEEL_KS, self.FLYWHEEL_KV, self.FLYWHEEL_KA
45+
)
4146

4247
# Joystick to control setpoint
4348
self.joystick = wpilib.Joystick(0)
@@ -48,7 +53,9 @@ def robotInit(self):
4853
self.bangBangControler = wpimath.controller.BangBangController()
4954

5055
# Simulation classes help us simulate our robot
51-
self.flywheelSim = wpilib.simulation.FlywheelSim(DCMotor.NEO(1), self.FLYWHEEL_GEARING, self.FLYWHEEL_MOMENT_OF_INERTIA);
56+
self.flywheelSim = wpilib.simulation.FlywheelSim(
57+
DCMotor.NEO(1), self.FLYWHEEL_GEARING, self.FLYWHEEL_MOMENT_OF_INERTIA
58+
)
5259
self.encoderSim = wpilib.simulation.EncoderSim(self.encoder)
5360

5461
# Add bang-bang controler to SmartDashboard and networktables.
@@ -59,24 +66,33 @@ def teleopPeriodic(self):
5966

6067
# Scale setpoint value between 0 and maxSetpointValue
6168
setpoint = max(
62-
0.0,
63-
self.joystick.getRawAxis(0) * wpimath.units.rotationsPerMinuteToRadiansPerSecond(self.MAX_SETPOINT_VALUE)
69+
0.0,
70+
self.joystick.getRawAxis(0)
71+
* wpimath.units.rotationsPerMinuteToRadiansPerSecond(
72+
self.MAX_SETPOINT_VALUE
73+
),
6474
)
6575

6676
# Set setpoint and measurement of the bang-bang controller
67-
bangOutput = self.bangBangControler.calculate(self.encoder.getRate(), setpoint) * 12.0
77+
bangOutput = (
78+
self.bangBangControler.calculate(self.encoder.getRate(), setpoint) * 12.0
79+
)
6880

6981
# Controls a motor with the output of the BangBang controller and a
7082
# feedforward. The feedforward is reduced slightly to avoid overspeeding
7183
# the shooter.
72-
self.flywheelMotor.setVoltage(bangOutput + 0.9 * self.feedforward.calculate(setpoint))
84+
self.flywheelMotor.setVoltage(
85+
bangOutput + 0.9 * self.feedforward.calculate(setpoint)
86+
)
7387

7488
def _simulationPeriodic(self):
7589
"""Update our simulation. This should be run every robot loop in simulation."""
7690

7791
# To update our simulation, we set motor voltage inputs, update the
7892
# simulation, and write the simulated velocities to our simulated encoder
79-
self.flywheelSim.setInputVoltage(self.flywheelMotor.get() * wpilib.RobotController.getInputVoltage())
93+
self.flywheelSim.setInputVoltage(
94+
self.flywheelMotor.get() * wpilib.RobotController.getInputVoltage()
95+
)
8096
self.flywheelSim.update(0.02)
8197
self.encoderSim.setRate(self.flywheelSim.getAngularVelocity())
8298

gyro-mecanum/robot.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99

1010

1111
class MyRobot(wpilib.TimedRobot):
12-
1312
# gyro calibration constant, may need to be adjusted;
1413
# gyro value of 360 is set to correspond to one full revolution
1514
VOLTS_PER_DEGREE_PER_SECOND = 0.0128
@@ -43,8 +42,10 @@ def robotInit(self):
4342

4443
def teleopPeriodic(self):
4544
self.robotDrive.driveCartesian(
46-
-self.joystick.getY(), -self.joystick.getX(), -self.joystick.getZ(),
47-
self.gyro.getRotation2d()
45+
-self.joystick.getY(),
46+
-self.joystick.getX(),
47+
-self.joystick.getZ(),
48+
self.gyro.getRotation2d(),
4849
)
4950

5051

hid-rumble/robot.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88

99
class MyRobot(wpilib.TimedRobot):
10-
1110
def robotInit(self):
1211
"""Robot initialization function"""
1312

0 commit comments

Comments
 (0)