Skip to content

Commit 122dcd5

Browse files
authored
Merge pull request #21 from thedropbears/switch_to_uv
2 parents a578a7e + b5c3a4a commit 122dcd5

File tree

10 files changed

+813
-836
lines changed

10 files changed

+813
-836
lines changed

README.md

+62
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,65 @@
11
# pysysid
22

33
The Drop Bears' robot code for sysid in common mechanism types
4+
5+
## Setup
6+
7+
### Install dependencies
8+
9+
We use `uv` to manage our dependencies in our development environments.
10+
This includes the Python version, and any Python packages such as `wpilib`.
11+
12+
Install `uv` by following the [`uv` docs](https://docs.astral.sh/uv/).
13+
14+
After installing `uv`, use it to create a virtual environment and install our dependencies.
15+
16+
```sh
17+
uv sync
18+
```
19+
20+
Then, download the roboRIO dependencies.
21+
22+
```sh
23+
uv run python -m ensurepip
24+
uv run robotpy --main <SYSID_PROJECT> sync --no-install
25+
```
26+
27+
### pre-commit
28+
29+
[pre-commit][] is configured to run our formatters and linters.
30+
These are enforced for all code committed to this project.
31+
32+
To use pre-commit, you must install it outside of this project's virtual environment.
33+
Either use your system package manager, or use `uv tool`:
34+
35+
```sh
36+
uv tool install pre-commit
37+
```
38+
39+
You can then set up the pre-commit hooks to run on commit:
40+
41+
```sh
42+
pre-commit install
43+
```
44+
45+
## Run
46+
47+
### Simulation
48+
49+
``` bash
50+
uv run robotpy --main <SYSID_PROJECT> sim
51+
```
52+
53+
### Deploy to Robot
54+
55+
Once on robots network
56+
57+
``` bash
58+
uv run robotpy --main <SYSID_PROJECT> deploy
59+
```
60+
61+
### Test
62+
63+
``` bash
64+
uv run robotpy --main <SYSID_PROJECT> test
65+
```

flywheel/robot.py

-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
# the WPILib BSD license file in the root directory of this project.
66

77
from commands2 import CommandScheduler, TimedCommandRobot
8-
98
from sysidroutinebot import SysIdRoutineBot
109

1110

flywheel/subsystems/flywheel.py

+1-5
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,15 @@
44
#
55

66
import phoenix6
7-
87
from commands2 import Command, Subsystem
98
from commands2.sysid import SysIdRoutine
10-
from wpilib import sysid
11-
129
from phoenix6 import SignalLogger
1310
from phoenix6.configs import FeedbackConfigs, MotorOutputConfigs
1411
from phoenix6.controls import Follower, VoltageOut
1512
from phoenix6.signals import NeutralModeValue
16-
13+
from wpilib import sysid
1714
from wpimath.units import volts
1815

19-
2016
FollowerDescriptor = tuple[phoenix6.hardware.TalonFX, bool]
2117

2218

flywheel/sysidroutinebot.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,8 @@
66
from commands2 import Command
77
from commands2.button import CommandXboxController
88
from commands2.sysid import SysIdRoutine
9-
10-
from subsystems.flywheel import Flywheel
11-
129
from constants import OIConstants, TalonIds
10+
from subsystems.flywheel import Flywheel
1311

1412

1513
class SysIdRoutineBot:

pdm.lock

-788
This file was deleted.

pyproject.toml

+40-28
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
[tool.coverage.run]
22
branch = true
3+
omit = ["config.py", "config-3.py"]
34

45
[tool.coverage.report]
56
exclude_lines = [
@@ -16,14 +17,27 @@ warn_unused_ignores = true
1617
warn_unreachable = true
1718
strict_equality = true
1819

20+
[[tool.mypy.overrides]]
21+
module = "choreo.*"
22+
ignore_missing_imports = true
23+
24+
[tool.pyright]
25+
exclude = [
26+
"ctre_sim",
27+
"logs",
28+
# Default excludes
29+
"**/__pycache__",
30+
"**/.*",
31+
]
32+
1933
[tool.pytest.ini_options]
2034
addopts = "--strict-markers -v --maxfail=2"
2135
pythonpath = "."
2236
testpaths = ["tests"]
2337
xfail_strict = true
2438

2539
[tool.ruff]
26-
target-version = "py39"
40+
target-version = "py311"
2741

2842
[tool.ruff.lint]
2943
select = [
@@ -33,6 +47,8 @@ select = [
3347
"F",
3448
# flake8-bugbear
3549
"B",
50+
# isort
51+
"I",
3652
# pyupgrade
3753
"UP",
3854
# flake8-comprehensions
@@ -46,20 +62,19 @@ select = [
4662
# perflint
4763
"PERF",
4864
]
49-
ignore = ["E501"]
50-
51-
[tool.pdm]
52-
package-type = "application"
53-
54-
[tool.pdm.scripts]
55-
deploy = "robotpy --main {args}/robot.py deploy"
56-
download = "robotpy sync --no-install"
57-
sim = "robotpy --main {args}/robot.py sim"
58-
test = "robotpy --main {args}/robot.py test --"
65+
ignore = [
66+
"E501", # long lines
67+
"B905", # zip() without strict=
68+
]
5969

60-
[tool.pdm.dev-dependencies]
61-
dev = ["hypothesis", "pytest>=7.2.0", "pytest-integration>=0.2.3"]
62-
typing = ["mypy>=1.8.0"]
70+
[tool.uv]
71+
dev-dependencies = [
72+
"hypothesis>=6.112.1",
73+
"mypy>=1.8.0",
74+
"pytest>=7.2.0",
75+
"pytest-integration>=0.2.3",
76+
]
77+
prerelease = "allow"
6378

6479
[project]
6580
name = "pysysid"
@@ -68,27 +83,24 @@ description = "The Drop Bears' ongoing system identification code"
6883
authors = [{ name = "The Drop Bears", email = "[email protected]" }]
6984
readme = "README.md"
7085
license = { text = "MIT" }
71-
requires-python = ">=3.10,<3.13"
86+
requires-python = ">=3.12,<3.14"
7287

7388
dependencies = [
74-
"phoenix6~=24.2.0",
75-
"robotpy==2024.3.1.0",
76-
"robotpy-commands-v2~=2024.3.1",
77-
"robotpy-navx~=2024.1.0",
78-
"robotpy-rev~=2024.2.1",
79-
"robotpy-urcl~=2024.0.1",
89+
"phoenix6~=25.1.0",
90+
"robotpy==2025.2.1.0",
91+
"robotpy-commands-v2~=2025.1.1",
92+
"robotpy-rev~=2025.0.1",
93+
"robotpy-urcl~=2025.0.0",
8094
]
8195

8296
[tool.robotpy]
8397
requires = [
84-
"phoenix6~=24.2.0",
85-
"robotpy-commands-v2~=2023.3.1",
86-
"robotpy-navx~=2024.1.0",
87-
"robotpy-rev~=2024.2.1",
88-
"robotpy-urcl~=2024.0.1",
98+
"phoenix6~=25.1.0",
99+
"robotpy-commands-v2~=2025.1.1",
100+
"robotpy-rev~=2025.0.1",
101+
"robotpy-urcl~=2025.0.0",
89102
# Not needed for these routines, but keep them on the robot for production.
90103
"numpy",
91104
"photonlibpy",
92105
]
93-
robotpy_version = "2024.3.1.0"
94-
robotpy_extras = ["apriltag"]
106+
robotpy_version = "2025.2.1.0"

swerve_drive/robot.py

-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
# the WPILib BSD license file in the root directory of this project.
66

77
from commands2 import CommandScheduler, TimedCommandRobot
8-
98
from sysidroutinebot import SysIdRoutineBot
109

1110

swerve_drive/subsystems/drive.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,21 @@
77

88
from commands2 import Command, Subsystem
99
from commands2.sysid import SysIdRoutine
10-
from wpilib import sysid
11-
10+
from constants import TalonIds
1211
from phoenix6 import SignalLogger
13-
from phoenix6.hardware import TalonFX
1412
from phoenix6.configs import FeedbackConfigs, MotorOutputConfigs
1513
from phoenix6.configs.config_groups import NeutralModeValue
1614
from phoenix6.controls import VoltageOut
17-
15+
from phoenix6.hardware import TalonFX
16+
from wpilib import sysid
1817
from wpimath.units import volts
1918

20-
from constants import TalonIds
21-
2219

2320
class Drive(Subsystem):
24-
DRIVE_GEAR_RATIO = (14.0 / 50.0) * (25.0 / 19.0) * (15.0 / 45.0)
21+
L1_DRIVE_GEAR_RATIO = (14.0 / 50.0) * (25.0 / 19.0) * (15.0 / 45.0)
22+
L2_DRIVE_GEAR_RATIO = (14.0 / 50.0) * (27.0 / 17.0) * (15.0 / 45.0)
23+
24+
DRIVE_GEAR_RATIO = L1_DRIVE_GEAR_RATIO
2525
WHEEL_CIRCUMFERENCE = 4 * 2.54 / 100 * math.pi
2626

2727
DRIVE_MOTOR_REV_TO_METRES = WHEEL_CIRCUMFERENCE * DRIVE_GEAR_RATIO

swerve_drive/sysidroutinebot.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,8 @@
55
from commands2 import Command
66
from commands2.button import CommandXboxController
77
from commands2.sysid import SysIdRoutine
8-
9-
from subsystems.drive import Drive
10-
118
from constants import OIConstants
9+
from subsystems.drive import Drive
1210

1311

1412
class SysIdRoutineBot:

0 commit comments

Comments
 (0)