Skip to content

Commit

Permalink
Merge pull request #21 from thedropbears/switch_to_uv
Browse files Browse the repository at this point in the history
  • Loading branch information
LucienMorey authored Jan 19, 2025
2 parents a578a7e + b5c3a4a commit 122dcd5
Show file tree
Hide file tree
Showing 10 changed files with 813 additions and 836 deletions.
62 changes: 62 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,65 @@
# pysysid

The Drop Bears' robot code for sysid in common mechanism types

## Setup

### Install dependencies

We use `uv` to manage our dependencies in our development environments.
This includes the Python version, and any Python packages such as `wpilib`.

Install `uv` by following the [`uv` docs](https://docs.astral.sh/uv/).

After installing `uv`, use it to create a virtual environment and install our dependencies.

```sh
uv sync
```

Then, download the roboRIO dependencies.

```sh
uv run python -m ensurepip
uv run robotpy --main <SYSID_PROJECT> sync --no-install
```

### pre-commit

[pre-commit][] is configured to run our formatters and linters.
These are enforced for all code committed to this project.

To use pre-commit, you must install it outside of this project's virtual environment.
Either use your system package manager, or use `uv tool`:

```sh
uv tool install pre-commit
```

You can then set up the pre-commit hooks to run on commit:

```sh
pre-commit install
```

## Run

### Simulation

``` bash
uv run robotpy --main <SYSID_PROJECT> sim
```

### Deploy to Robot

Once on robots network

``` bash
uv run robotpy --main <SYSID_PROJECT> deploy
```

### Test

``` bash
uv run robotpy --main <SYSID_PROJECT> test
```
1 change: 0 additions & 1 deletion flywheel/robot.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
# the WPILib BSD license file in the root directory of this project.

from commands2 import CommandScheduler, TimedCommandRobot

from sysidroutinebot import SysIdRoutineBot


Expand Down
6 changes: 1 addition & 5 deletions flywheel/subsystems/flywheel.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,15 @@
#

import phoenix6

from commands2 import Command, Subsystem
from commands2.sysid import SysIdRoutine
from wpilib import sysid

from phoenix6 import SignalLogger
from phoenix6.configs import FeedbackConfigs, MotorOutputConfigs
from phoenix6.controls import Follower, VoltageOut
from phoenix6.signals import NeutralModeValue

from wpilib import sysid
from wpimath.units import volts


FollowerDescriptor = tuple[phoenix6.hardware.TalonFX, bool]


Expand Down
4 changes: 1 addition & 3 deletions flywheel/sysidroutinebot.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@
from commands2 import Command
from commands2.button import CommandXboxController
from commands2.sysid import SysIdRoutine

from subsystems.flywheel import Flywheel

from constants import OIConstants, TalonIds
from subsystems.flywheel import Flywheel


class SysIdRoutineBot:
Expand Down
788 changes: 0 additions & 788 deletions pdm.lock

This file was deleted.

68 changes: 40 additions & 28 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
[tool.coverage.run]
branch = true
omit = ["config.py", "config-3.py"]

[tool.coverage.report]
exclude_lines = [
Expand All @@ -16,14 +17,27 @@ warn_unused_ignores = true
warn_unreachable = true
strict_equality = true

[[tool.mypy.overrides]]
module = "choreo.*"
ignore_missing_imports = true

[tool.pyright]
exclude = [
"ctre_sim",
"logs",
# Default excludes
"**/__pycache__",
"**/.*",
]

[tool.pytest.ini_options]
addopts = "--strict-markers -v --maxfail=2"
pythonpath = "."
testpaths = ["tests"]
xfail_strict = true

[tool.ruff]
target-version = "py39"
target-version = "py311"

[tool.ruff.lint]
select = [
Expand All @@ -33,6 +47,8 @@ select = [
"F",
# flake8-bugbear
"B",
# isort
"I",
# pyupgrade
"UP",
# flake8-comprehensions
Expand All @@ -46,20 +62,19 @@ select = [
# perflint
"PERF",
]
ignore = ["E501"]

[tool.pdm]
package-type = "application"

[tool.pdm.scripts]
deploy = "robotpy --main {args}/robot.py deploy"
download = "robotpy sync --no-install"
sim = "robotpy --main {args}/robot.py sim"
test = "robotpy --main {args}/robot.py test --"
ignore = [
"E501", # long lines
"B905", # zip() without strict=
]

[tool.pdm.dev-dependencies]
dev = ["hypothesis", "pytest>=7.2.0", "pytest-integration>=0.2.3"]
typing = ["mypy>=1.8.0"]
[tool.uv]
dev-dependencies = [
"hypothesis>=6.112.1",
"mypy>=1.8.0",
"pytest>=7.2.0",
"pytest-integration>=0.2.3",
]
prerelease = "allow"

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

dependencies = [
"phoenix6~=24.2.0",
"robotpy==2024.3.1.0",
"robotpy-commands-v2~=2024.3.1",
"robotpy-navx~=2024.1.0",
"robotpy-rev~=2024.2.1",
"robotpy-urcl~=2024.0.1",
"phoenix6~=25.1.0",
"robotpy==2025.2.1.0",
"robotpy-commands-v2~=2025.1.1",
"robotpy-rev~=2025.0.1",
"robotpy-urcl~=2025.0.0",
]

[tool.robotpy]
requires = [
"phoenix6~=24.2.0",
"robotpy-commands-v2~=2023.3.1",
"robotpy-navx~=2024.1.0",
"robotpy-rev~=2024.2.1",
"robotpy-urcl~=2024.0.1",
"phoenix6~=25.1.0",
"robotpy-commands-v2~=2025.1.1",
"robotpy-rev~=2025.0.1",
"robotpy-urcl~=2025.0.0",
# Not needed for these routines, but keep them on the robot for production.
"numpy",
"photonlibpy",
]
robotpy_version = "2024.3.1.0"
robotpy_extras = ["apriltag"]
robotpy_version = "2025.2.1.0"
1 change: 0 additions & 1 deletion swerve_drive/robot.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
# the WPILib BSD license file in the root directory of this project.

from commands2 import CommandScheduler, TimedCommandRobot

from sysidroutinebot import SysIdRoutineBot


Expand Down
14 changes: 7 additions & 7 deletions swerve_drive/subsystems/drive.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,21 @@

from commands2 import Command, Subsystem
from commands2.sysid import SysIdRoutine
from wpilib import sysid

from constants import TalonIds
from phoenix6 import SignalLogger
from phoenix6.hardware import TalonFX
from phoenix6.configs import FeedbackConfigs, MotorOutputConfigs
from phoenix6.configs.config_groups import NeutralModeValue
from phoenix6.controls import VoltageOut

from phoenix6.hardware import TalonFX
from wpilib import sysid
from wpimath.units import volts

from constants import TalonIds


class Drive(Subsystem):
DRIVE_GEAR_RATIO = (14.0 / 50.0) * (25.0 / 19.0) * (15.0 / 45.0)
L1_DRIVE_GEAR_RATIO = (14.0 / 50.0) * (25.0 / 19.0) * (15.0 / 45.0)
L2_DRIVE_GEAR_RATIO = (14.0 / 50.0) * (27.0 / 17.0) * (15.0 / 45.0)

DRIVE_GEAR_RATIO = L1_DRIVE_GEAR_RATIO
WHEEL_CIRCUMFERENCE = 4 * 2.54 / 100 * math.pi

DRIVE_MOTOR_REV_TO_METRES = WHEEL_CIRCUMFERENCE * DRIVE_GEAR_RATIO
Expand Down
4 changes: 1 addition & 3 deletions swerve_drive/sysidroutinebot.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,8 @@
from commands2 import Command
from commands2.button import CommandXboxController
from commands2.sysid import SysIdRoutine

from subsystems.drive import Drive

from constants import OIConstants
from subsystems.drive import Drive


class SysIdRoutineBot:
Expand Down
Loading

0 comments on commit 122dcd5

Please sign in to comment.