Skip to content

Commit 616e7ab

Browse files
authored
Merge pull request #78 from robotpy/2024-beta
Update examples for 2024
2 parents bab2e0d + 3735a70 commit 616e7ab

File tree

34 files changed

+96
-96
lines changed

34 files changed

+96
-96
lines changed

.github/workflows/test.yml

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,28 +13,31 @@ jobs:
1313
check:
1414
runs-on: ubuntu-latest
1515
steps:
16-
- uses: actions/checkout@v3
16+
- uses: actions/checkout@v4
1717
- uses: psf/black@stable
1818

1919
test:
2020
runs-on: ${{ matrix.os }}
2121
strategy:
2222
matrix:
23-
os: [windows-latest, macos-latest, ubuntu-22.04]
24-
python_version: [3.7, 3.8, 3.9, "3.10", "3.11"]
23+
os: ["ubuntu-22.04", "macos-12", "windows-2022"]
24+
python_version:
25+
# - '3.8'
26+
# - '3.9'
27+
- '3.10'
28+
- '3.11'
29+
- '3.12'
2530

2631
steps:
27-
- uses: actions/checkout@v3
32+
- uses: actions/checkout@v4
2833
- uses: actions/setup-python@v4
2934
with:
3035
python-version: ${{ matrix.python_version }}
3136
architecture: ${{ matrix.architecture }}
3237
- name: Install deps
3338
run: |
34-
pip install numpy
3539
pip install -U pip
36-
pip install 'robotpy[commands2]<2024.0.0,>=2023.1.1.0' pytest
37-
#pip install 'robotpy[commands2,romi]<2024.0.0,>=2023.0.0b3' pytest
40+
pip install 'robotpy[commands2]<2025.0.0,>=2024.0.0b3' numpy pytest
3841
- name: Run tests
3942
run: bash run_tests.sh
4043
shell: bash

arm-simulation/physics.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ def __init__(self, physics_controller: PhysicsInterface, robot: "MyRobot"):
5454
math.radians(-75),
5555
math.radians(255),
5656
True,
57+
0,
5758
)
5859
self.encoderSim = wpilib.simulation.EncoderSim(robot.encoder)
5960
self.motorSim = wpilib.simulation.PWMSim(robot.motor.getChannel())

commands-v2/armbot/subsystems/drivesubsystem.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import constants
1010

1111

12-
class DriveSubsystem(commands2.SubsystemBase):
12+
class DriveSubsystem(commands2.Subsystem):
1313
# Creates a new DriveSubsystem
1414
def __init__(self) -> None:
1515
super().__init__()

commands-v2/armbotoffboard/subsystems/drivesubsystem.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import typing
1111

1212

13-
class DriveSubsystem(commands2.SubsystemBase):
13+
class DriveSubsystem(commands2.Subsystem):
1414
def __init__(self) -> None:
1515
super().__init__()
1616

commands-v2/drive-distance-offboard/subsystems/drivesubsystem.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
import examplesmartmotorcontroller
1414

1515

16-
class DriveSubsystem(commands2.SubsystemBase):
16+
class DriveSubsystem(commands2.Subsystem):
1717
def __init__(self) -> None:
1818
"""Creates a new DriveSubsystem"""
1919
super().__init__()

commands-v2/frisbee-bot/subsystems/drivesubsystem.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import constants
1111

1212

13-
class DriveSubsystem(commands2.SubsystemBase):
13+
class DriveSubsystem(commands2.Subsystem):
1414
def __init__(self) -> None:
1515
"""Creates a new DriveSubsystem"""
1616
super().__init__()

commands-v2/gyro-drive-commands/subsystems/drivesubsystem.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
import constants
1212

1313

14-
class DriveSubsystem(commands2.SubsystemBase):
14+
class DriveSubsystem(commands2.Subsystem):
1515
def __init__(self) -> None:
1616
"""Creates a new DriveSubsystem"""
1717
super().__init__()

commands-v2/hatchbot-inlined/commands/autos.py

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ class Autos:
2020
def __init__(self) -> None:
2121
raise Exception("This is a utility class!")
2222

23+
@staticmethod
2324
def simpleAuto(drive: subsystems.drivesubsystem.DriveSubsystem):
2425
"""A simple auto routine that drives forward a specified distance, and then stops."""
2526
return commands2.FunctionalCommand(
@@ -35,42 +36,41 @@ def simpleAuto(drive: subsystems.drivesubsystem.DriveSubsystem):
3536
# Require the drive subsystem
3637
)
3738

39+
@staticmethod
3840
def complexAuto(
3941
driveSubsystem: subsystems.drivesubsystem.DriveSubsystem,
4042
hatchSubsystem: subsystems.hatchsubsystem.HatchSubsystem,
4143
):
4244
"""A complex auto routine that drives forward, drops a hatch, and then drives backward."""
4345
return commands2.cmd.sequence(
44-
[
45-
# Drive forward up to the front of the cargo ship
46-
commands2.FunctionalCommand(
47-
# Reset encoders on command start
48-
driveSubsystem.resetEncoders,
49-
# Drive forward while the command is executing
50-
lambda: driveSubsystem.arcadeDrive(constants.kAutoDriveSpeed, 0),
51-
# Stop driving at the end of the command
52-
lambda interrupt: driveSubsystem.arcadeDrive(0, 0),
53-
# End the command when the robot's driven distance exceeds the desired value
54-
lambda: driveSubsystem.getAverageEncoderDistance()
55-
>= constants.kAutoDriveDistanceInches,
56-
# Require the drive subsystem
57-
[driveSubsystem],
58-
),
59-
# Release the hatch
60-
hatchSubsystem.releaseHatch(),
61-
# Drive backward the specified distance
62-
commands2.FunctionalCommand(
63-
# Reset encoders on command start
64-
driveSubsystem.resetEncoders,
65-
# Drive backwards while the command is executing
66-
lambda: driveSubsystem.arcadeDrive(-constants.kAutoDriveSpeed, 0),
67-
# Stop driving at the end of the command
68-
lambda interrupt: driveSubsystem.arcadeDrive(0, 0),
69-
# End the command when the robot's driven distance exceeds the desired value
70-
lambda: abs(driveSubsystem.getAverageEncoderDistance())
71-
>= constants.kAutoBackupDistanceInches,
72-
# Require the drive subsystem
73-
[driveSubsystem],
74-
),
75-
]
46+
# Drive forward up to the front of the cargo ship
47+
commands2.FunctionalCommand(
48+
# Reset encoders on command start
49+
driveSubsystem.resetEncoders,
50+
# Drive forward while the command is executing
51+
lambda: driveSubsystem.arcadeDrive(constants.kAutoDriveSpeed, 0),
52+
# Stop driving at the end of the command
53+
lambda interrupt: driveSubsystem.arcadeDrive(0, 0),
54+
# End the command when the robot's driven distance exceeds the desired value
55+
lambda: driveSubsystem.getAverageEncoderDistance()
56+
>= constants.kAutoDriveDistanceInches,
57+
# Require the drive subsystem
58+
driveSubsystem,
59+
),
60+
# Release the hatch
61+
hatchSubsystem.releaseHatch(),
62+
# Drive backward the specified distance
63+
commands2.FunctionalCommand(
64+
# Reset encoders on command start
65+
driveSubsystem.resetEncoders,
66+
# Drive backwards while the command is executing
67+
lambda: driveSubsystem.arcadeDrive(-constants.kAutoDriveSpeed, 0),
68+
# Stop driving at the end of the command
69+
lambda interrupt: driveSubsystem.arcadeDrive(0, 0),
70+
# End the command when the robot's driven distance exceeds the desired value
71+
lambda: abs(driveSubsystem.getAverageEncoderDistance())
72+
>= constants.kAutoBackupDistanceInches,
73+
# Require the drive subsystem
74+
driveSubsystem,
75+
),
7676
)

commands-v2/hatchbot-inlined/physics.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@
1111

1212
import wpilib
1313
import wpilib.simulation
14-
from wpimath.system import LinearSystemId
15-
from wpimath.system.plant import DCMotor
14+
from wpimath.system.plant import DCMotor, LinearSystemId
1615

1716
import constants
1817

commands-v2/hatchbot-inlined/robotcontainer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def __init__(self) -> None:
5454
-self.driverController.getLeftY(),
5555
-self.driverController.getRightX(),
5656
),
57-
[self.driveSubsystem],
57+
self.driveSubsystem,
5858
)
5959
)
6060

0 commit comments

Comments
 (0)