robotpy / robotpy/mostrobotpy

[BUG-ish]: Python's duck typing hides a loud C++ API break

Open
#136 4 comments 0 reactions 0 assignees View on GitHub
package: wpimath
Dominant language
Python
Stars
27
Forks
29
Avg merge
4d 6h
Merged PRs (30d)
12

Description

### Problem description

2024: https://robotpy.readthedocs.io/projects/robotpy/en/2024.3.2.1/wpimath.controller/SimpleMotorFeedforwardMeters.html#wpimath.controller.SimpleMotorFeedforwardMeters.calculate

`calculate(curVel, curAccel)`

versus

2025: https://robotpy.readthedocs.io/projects/robotpy/en/stable/wpimath.controller/SimpleMotorFeedforwardMeters.html#wpimath.controller.SimpleMotorFeedforwardMeters.calculate

`calculate(curVel, nextVel)`

Here's where we got burned:

https://github.com/RobotCasserole1736/RobotCasserole2025/blob/902ba40f83ad67a8f2dd23db6c10b35afdf920c9/drivetrain/swerveModuleControl.py#L202

The change in API is mentioned (indirectly-ish) in the wpilib 2025 change notes (and shows up in the doc text for that function), so we were able to find it within ~30 minutes of debug.

However, per a quick chat with Peter, this is maybe something to consider, since the API break relied on C++'s units implementation, which is currently collapsed away in python.

I'm not sure what exactly could be done to help catch this in python in future years (typehinting checks?), but I also haven't thought about it a ton. I will do some more thinking/asking around, and make some comments if I have ideas.

### Operating System

Windows

### Installed Python Packages

```text
N/A
```

### Reproducible example code

```text
See links above.
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.