Skip to content

Commit 5f5ae7a

Browse files
authored
Merge pull request #89 from robotpy/fix-examples-and-update
Fix examples and update
2 parents f6085a7 + 29651ec commit 5f5ae7a

19 files changed

Lines changed: 367 additions & 52 deletions

File tree

.github/workflows/dist.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,13 @@ on:
66
push:
77
branches:
88
- main
9+
- '2027'
910
tags:
1011
- '*'
1112

1213
jobs:
1314
ci:
14-
uses: robotpy/build-actions/.github/workflows/package-ci.yml@v2026
15+
uses: robotpy/build-actions/.github/workflows/package-ci.yml@v2027
1516
with:
1617
artifactory_repo_type: vendor
1718
enable_raspbian: false

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: 11 additions & 7 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~=2026.2.1",
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>=2026.2.1,<2027",
19+
"wpilib==2027.0.0a6.post1",
2020
]
2121

2222
[[project.authors]]
@@ -44,23 +44,23 @@ packages = ["rev"]
4444
artifact_id = "REVLib-cpp"
4545
group_id = "com.revrobotics.frc"
4646
repo_url = "https://maven.revrobotics.com"
47-
version = "2026.0.4"
47+
version = "2027.0.0-alpha-3"
4848
staticlibs = ["REVLib"]
4949
extract_to = "lib"
5050

5151
[[tool.hatch.build.hooks.robotpy.maven_lib_download]]
5252
artifact_id = "REVLib-driver"
5353
group_id = "com.revrobotics.frc"
5454
repo_url = "https://maven.revrobotics.com"
55-
version = "2026.0.4"
55+
version = "2027.0.0-alpha-3"
5656
staticlibs = [ "REVLibDriver"]
5757
extract_to = "lib"
5858

5959
[[tool.hatch.build.hooks.robotpy.maven_lib_download]]
6060
artifact_id = "RevLibBackendDriver"
6161
group_id = "com.revrobotics.frc"
6262
repo_url = "https://maven.revrobotics.com"
63-
version = "2026.0.4"
63+
version = "2027.0.0-alpha-3"
6464
staticlibs = [
6565
"BackendDriver",
6666
]
@@ -71,7 +71,7 @@ use_headers = false
7171
artifact_id = "RevLibWpiBackendDriver"
7272
group_id = "com.revrobotics.frc"
7373
repo_url = "https://maven.revrobotics.com"
74-
version = "2026.0.4"
74+
version = "2027.0.0-alpha-3"
7575
staticlibs = [
7676
"REVLibWpi",
7777
]
@@ -145,6 +145,9 @@ includes = [
145145

146146
[tool.semiwrap.extension_modules."rev._rev".headers]
147147

148+
# first
149+
A301 = "first/A301.h"
150+
148151
# rev
149152
AbsoluteEncoder = "rev/AbsoluteEncoder.h"
150153
AnalogInput = "rev/AnalogInput.h"
@@ -236,4 +239,5 @@ SparkRelativeEncoderSim = "rev/sim/SparkRelativeEncoderSim.h"
236239
SparkSimFaultManager = "rev/sim/SparkSimFaultManager.h"
237240

238241
# rev/util
242+
Signal = "rev/util/Signal.h"
239243
StatusLogger = "rev/util/StatusLogger.h"

rev/__init__.py

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

55
# autogenerated by 'semiwrap create-imports rev rev._rev'
66
from ._rev import (
7+
A301,
78
AbsoluteEncoder,
89
AbsoluteEncoderConfig,
910
AbsoluteEncoderConfigAccessor,
@@ -25,6 +26,7 @@
2526
DetachedEncoderLowLevel,
2627
DetachedEncoderSim,
2728
DetachedSignalsConfig,
29+
DetachedSignalsConfigAccessor,
2830
EncoderConfig,
2931
EncoderConfigAccessor,
3032
ExternalEncoderConfig,
@@ -52,6 +54,36 @@
5254
ServoHubParameter,
5355
ServoHubSim,
5456
ServoHubSimFaultManager,
57+
Signal_A301Faults,
58+
Signal_A301Warnings,
59+
Signal_ClosedLoopSlot,
60+
Signal_DetachedFaults,
61+
Signal_DetachedPeriodicStatus1,
62+
Signal_DetachedPeriodicStatus2,
63+
Signal_DetachedPeriodicStatus3,
64+
Signal_DetachedPeriodicStatus4,
65+
Signal_ServoHubFaults,
66+
Signal_ServoHubPeriodicStatus0,
67+
Signal_ServoHubPeriodicStatus1,
68+
Signal_ServoHubPeriodicStatus2,
69+
Signal_ServoHubPeriodicStatus3,
70+
Signal_ServoHubPeriodicStatus4,
71+
Signal_ServoHubWarnings,
72+
Signal_SparkFaults,
73+
Signal_SparkPeriodicStatus0,
74+
Signal_SparkPeriodicStatus1,
75+
Signal_SparkPeriodicStatus2,
76+
Signal_SparkPeriodicStatus3,
77+
Signal_SparkPeriodicStatus4,
78+
Signal_SparkPeriodicStatus5,
79+
Signal_SparkPeriodicStatus6,
80+
Signal_SparkPeriodicStatus7,
81+
Signal_SparkPeriodicStatus8,
82+
Signal_SparkPeriodicStatus9,
83+
Signal_SparkWarnings,
84+
Signal_bool,
85+
Signal_double,
86+
Signal_int,
5587
SignalsConfig,
5688
SignalsConfigAccessor,
5789
SoftLimitConfig,
@@ -90,6 +122,7 @@
90122
)
91123

92124
__all__ = [
125+
"A301",
93126
"AbsoluteEncoder",
94127
"AbsoluteEncoderConfig",
95128
"AbsoluteEncoderConfigAccessor",
@@ -111,6 +144,7 @@
111144
"DetachedEncoderLowLevel",
112145
"DetachedEncoderSim",
113146
"DetachedSignalsConfig",
147+
"DetachedSignalsConfigAccessor",
114148
"EncoderConfig",
115149
"EncoderConfigAccessor",
116150
"ExternalEncoderConfig",
@@ -138,6 +172,36 @@
138172
"ServoHubParameter",
139173
"ServoHubSim",
140174
"ServoHubSimFaultManager",
175+
"Signal_A301Faults",
176+
"Signal_A301Warnings",
177+
"Signal_ClosedLoopSlot",
178+
"Signal_DetachedFaults",
179+
"Signal_DetachedPeriodicStatus1",
180+
"Signal_DetachedPeriodicStatus2",
181+
"Signal_DetachedPeriodicStatus3",
182+
"Signal_DetachedPeriodicStatus4",
183+
"Signal_ServoHubFaults",
184+
"Signal_ServoHubPeriodicStatus0",
185+
"Signal_ServoHubPeriodicStatus1",
186+
"Signal_ServoHubPeriodicStatus2",
187+
"Signal_ServoHubPeriodicStatus3",
188+
"Signal_ServoHubPeriodicStatus4",
189+
"Signal_ServoHubWarnings",
190+
"Signal_SparkFaults",
191+
"Signal_SparkPeriodicStatus0",
192+
"Signal_SparkPeriodicStatus1",
193+
"Signal_SparkPeriodicStatus2",
194+
"Signal_SparkPeriodicStatus3",
195+
"Signal_SparkPeriodicStatus4",
196+
"Signal_SparkPeriodicStatus5",
197+
"Signal_SparkPeriodicStatus6",
198+
"Signal_SparkPeriodicStatus7",
199+
"Signal_SparkPeriodicStatus8",
200+
"Signal_SparkPeriodicStatus9",
201+
"Signal_SparkWarnings",
202+
"Signal_bool",
203+
"Signal_double",
204+
"Signal_int",
141205
"SignalsConfig",
142206
"SignalsConfigAccessor",
143207
"SoftLimitConfig",

0 commit comments

Comments
 (0)