Skip to content

Commit 29651ec

Browse files
committed
Update examples, CI, build requirements
1 parent 1c08b5b commit 29651ec

7 files changed

Lines changed: 42 additions & 38 deletions

File tree

.github/workflows/dist.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ on:
66
push:
77
branches:
88
- main
9+
- '2027'
910
tags:
1011
- '*'
1112

examples/can-arcade-drive/robot.py

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,32 +7,35 @@
77

88
import rev
99
import wpilib
10-
from wpilib.drive import DifferentialDrive
1110

1211

1312
class Robot(wpilib.TimedRobot):
14-
def robotInit(self):
13+
def __init__(self):
14+
super().__init__()
1515
# SPARK MAX controllers are intialized over CAN by constructing a
1616
# CANSparkMax object
1717
#
18-
# The CAN ID, which can be configured using the SPARK MAX Client, is passed
19-
# as the first parameter
18+
# The CAN bus ID is passed as the first parameter, and the device ID,
19+
# which can be configured using the SPARK MAX Client, is passed as the
20+
# second parameter.
2021
#
21-
# The motor type is passed as the second parameter.
22+
# The motor type is passed as the third parameter.
2223
# Motor type can either be:
2324
# rev.CANSparkMax.MotorType.kBrushless
2425
# rev.CANSparkMax.MotorType.kBrushed
2526
#
2627
# The example below initializes four brushless motors with CAN IDs
2728
# 1, 2, 3, 4. Change these parameters to match your setup
28-
self.leftLeadMotor = rev.SparkMax(1, rev.SparkMax.MotorType.kBrushless)
29-
self.rightLeadMotor = rev.SparkMax(3, rev.SparkMax.MotorType.kBrushless)
30-
self.leftFollowMotor = rev.SparkMax(2, rev.SparkMax.MotorType.kBrushless)
31-
self.rightFollowMotor = rev.SparkMax(4, rev.SparkMax.MotorType.kBrushless)
29+
self.leftLeadMotor = rev.SparkMax(0, 1, rev.SparkMax.MotorType.kBrushless)
30+
self.rightLeadMotor = rev.SparkMax(0, 3, rev.SparkMax.MotorType.kBrushless)
31+
self.leftFollowMotor = rev.SparkMax(0, 2, rev.SparkMax.MotorType.kBrushless)
32+
self.rightFollowMotor = rev.SparkMax(0, 4, rev.SparkMax.MotorType.kBrushless)
3233

3334
# Passing in the lead motors into DifferentialDrive allows any
3435
# commmands sent to the lead motors to be sent to the follower motors.
35-
self.driveTrain = DifferentialDrive(self.leftLeadMotor, self.rightLeadMotor)
36+
self.driveTrain = wpilib.DifferentialDrive(
37+
self.leftLeadMotor, self.rightLeadMotor
38+
)
3639
self.joystick = wpilib.Joystick(0)
3740

3841
# Create new SPARK MAX configuration objects. These will store the

examples/can-tank-drive/robot.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,26 +7,27 @@
77

88
import rev
99
import wpilib
10-
from wpilib.drive import DifferentialDrive
1110

1211

1312
class Robot(wpilib.TimedRobot):
14-
def robotInit(self):
13+
def __init__(self):
14+
super().__init__()
1515
# SPARK MAX controllers are intialized over CAN by constructing a
1616
# CANSparkMax object
1717
#
18-
# The CAN ID, which can be configured using the SPARK MAX Client, is passed
19-
# as the first parameter
18+
# The CAN bus ID is passed as the first parameter, and the device ID,
19+
# which can be configured using the SPARK MAX Client, is passed as the
20+
# second parameter.
2021
#
21-
# The motor type is passed as the second parameter.
22+
# The motor type is passed as the third parameter.
2223
# Motor type can either be:
2324
# rev.CANSparkMax.MotorType.kBrushless
2425
# rev.CANSparkMax.MotorType.kBrushed
2526
#
2627
# The example below initializes two brushless motors with CAN IDs
2728
# 1 and 2. Change these parameters to match your setup
28-
self.leftMotor = rev.SparkMax(1, rev.SparkMax.MotorType.kBrushless)
29-
self.rightMotor = rev.SparkMax(2, rev.SparkMax.MotorType.kBrushless)
29+
self.leftMotor = rev.SparkMax(0, 1, rev.SparkMax.MotorType.kBrushless)
30+
self.rightMotor = rev.SparkMax(0, 2, rev.SparkMax.MotorType.kBrushless)
3031

3132
# Configure for factory defaults and invert right side motor
3233
self.globalConfig = rev.SparkMaxConfig()
@@ -42,7 +43,7 @@ def robotInit(self):
4243
rev.PersistMode.kPersistParameters,
4344
)
4445

45-
self.driveTrain = DifferentialDrive(self.leftMotor, self.rightMotor)
46+
self.driveTrain = wpilib.DifferentialDrive(self.leftMotor, self.rightMotor)
4647
self.l_stick = wpilib.Joystick(0)
4748
self.r_stick = wpilib.Joystick(1)
4849

examples/getting-started/robot.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,20 @@
66
#
77

88
import wpilib
9-
import wpilib.drive
109
import rev
1110

1211

1312
class MyRobot(wpilib.TimedRobot):
14-
def robotInit(self):
13+
def __init__(self):
14+
super().__init__()
1515
"""
1616
This function is called upon program startup and
1717
should be used for any initialization code.
1818
"""
19-
self.leftDrive = rev.SparkMax(1, rev.SparkMax.MotorType.kBrushless)
20-
self.rightDrive = rev.SparkMax(2, rev.SparkMax.MotorType.kBrushless)
21-
self.robotDrive = wpilib.drive.DifferentialDrive(
22-
self.leftDrive, self.rightDrive
23-
)
24-
self.controller = wpilib.XboxController(0)
19+
self.leftDrive = rev.SparkMax(0, 1, rev.SparkMax.MotorType.kBrushless)
20+
self.rightDrive = rev.SparkMax(0, 2, rev.SparkMax.MotorType.kBrushless)
21+
self.robotDrive = wpilib.DifferentialDrive(self.leftDrive, self.rightDrive)
22+
self.controller = wpilib.Gamepad(0)
2523
self.timer = wpilib.Timer()
2624

2725
# We need to invert one side of the drivetrain so that positive voltages

examples/limit-switch/robot.py

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

1515

1616
class Robot(wpilib.TimedRobot):
17-
def robotInit(self):
17+
def __init__(self):
18+
super().__init__()
1819
# Create motor
19-
self.motor = rev.SparkMax(1, rev.SparkMax.MotorType.kBrushless)
20+
self.motor = rev.SparkMax(0, 1, rev.SparkMax.MotorType.kBrushless)
2021

2122
self.joystick = wpilib.Joystick(0)
2223

@@ -60,8 +61,8 @@ def robotInit(self):
6061
)
6162

6263
def teleopPeriodic(self):
63-
# Pair motor and the joystick's Y Axis
64-
self.motor.set(self.joystick.getY())
64+
# Pair motor output and the joystick's Y Axis
65+
self.motor.setVoltage(self.joystick.getY() * 12)
6566

6667
# enable/disable limit switches based on value read from SmartDashboard
6768
if self.prevForwardLimitEnabled != wpilib.SmartDashboard.getBoolean(
@@ -101,10 +102,10 @@ def teleopPeriodic(self):
101102
# pressed. It will also return true if you do not have a switch
102103
# connected. get() will return false when the switch is released.
103104
wpilib.SmartDashboard.putBoolean(
104-
"Forward Limit Switch", self.forwardLimit.get()
105+
"Forward Limit Switch", self.forwardLimit.get().get()
105106
)
106107
wpilib.SmartDashboard.putBoolean(
107-
"Reverse Limit Switch", self.reverseLimit.get()
108+
"Reverse Limit Switch", self.reverseLimit.get().get()
108109
)
109110

110111

examples/run_examples.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@
2525
script_dir = os.path.dirname(__file__)
2626

2727
robot_files = []
28-
for root, dirs, files in os.walk("."):
28+
for root, dirs, files in os.walk(script_dir):
2929
if "robot.py" in files:
30-
robot_files.append(os.path.relpath(root, "."))
30+
robot_files.append(os.path.relpath(root, script_dir))
3131

3232
for file in robot_files:
3333
print("found: " + file)
@@ -39,5 +39,5 @@
3939
for test in TESTS:
4040
print(f"Running test: {test}")
4141
os.chdir(os.path.join(script_dir, test))
42-
subprocess.run([sys.executable, "-m", "robotpy", "test", "--builtin"])
42+
subprocess.check_call([sys.executable, "-m", "robotpy", "test", "--builtin"])
4343
os.chdir(script_dir)

pyproject.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ requires = [
44
"hatchling",
55
"hatch-vcs",
66
"semiwrap~=0.3.0",
7-
"hatch-meson~=0.1.0",
7+
"hatch-meson~=0.1.2",
88
"hatch-robotpy~=0.2.1",
9-
"wpilib==2027.0.0a6",
9+
"wpilib==2027.0.0a6.post1",
1010
]
1111

1212

@@ -16,7 +16,7 @@ dynamic = ["version"]
1616
description = "REVLib for RobotPy"
1717
license = "BSD-3-Clause"
1818
dependencies = [
19-
"wpilib==2027.0.0a6",
19+
"wpilib==2027.0.0a6.post1",
2020
]
2121

2222
[[project.authors]]

0 commit comments

Comments
 (0)