Commit Graph

64 Commits

Author SHA1 Message Date
Kevin Cooney
ab854e91e5 [photon-lib] Invalidate pose cache when setting referencePose (#2040) 2025-08-08 00:14:44 -05:00
Kevin Cooney
29e24bbac2 [photon-lib] Python support for PNP_DISTANCE_TRIG_SOLVE (#2015)
This adds support for PNP_DISTANCE_TRIG_SOLVE in the the python
PhotonPoseEstimator, mirroring the implementation in the Java
PhotonPoseEstimator.

Changes:
- Add PoseStrategy.PNP_DISTANCE_TRIG_SOLVE
- Add addHeadingData() and resetHeadingData() to PhotonPoseEstimator
- Fix PhotonCameraSim.process() to set ntReceiveTimestampMicros in the
result
- Minor readability improvements to PhotonPipelineResult
- Minor test improvements to PhotonPoseEstimatorTest
- Add .vscode/settings.json (to make running python tests in VSCode
easier)

Merge checklist:
- [x] Pull Request title is [short, imperative
summary](https://cbea.ms/git-commit/) of proposed changes
- [x] The description documents the _what_ and _why_
- [ ] If this PR changes behavior or adds a feature, user documentation
is updated
- [ ] If this PR touches photon-serde, all messages have been
regenerated and hashes have not changed unexpectedly
- [ ] If this PR touches configuration, this is backwards compatible
with settings back to v2024.3.1
- [ ] If this PR touches pipeline settings or anything related to data
exchange, the frontend typing is updated
- [ ] If this PR addresses a bug, a regression test for it is added

---------

Co-authored-by: Sam948-byte <samf.236@proton.me>
2025-08-01 11:04:01 -07:00
Jade
647c238987 Fix usage reporting. (#1964)
## Description

Fixes the amount of cameras and pose estimators reported by usage reporting.

## Meta

Merge checklist:
- [x] Pull Request title is [short, imperative
summary](https://cbea.ms/git-commit/) of proposed changes
- [x] The description documents the _what_ and _why_
- [ ] If this PR changes behavior or adds a feature, user documentation
is updated
- [ ] If this PR touches photon-serde, all messages have been
regenerated and hashes have not changed unexpectedly
- [ ] If this PR touches configuration, this is backwards compatible
with settings back to v2024.3.1
- [ ] If this PR touches pipeline settings or anything related to data
exchange, the frontend typing is updated
- [ ] If this PR addresses a bug, a regression test for it is added

---------

Signed-off-by: Jade Turner <spacey-sooty@proton.me>
2025-06-30 23:08:23 -04:00
Sam Freund
44893b14b0 Bump Wpiformat (#1892) 2025-04-14 22:00:18 +00:00
Sam Freund
30645803e6 chore: bump wpilib to 2025.3.2 and fix mypy errors (#1819) 2025-03-19 01:31:59 -04:00
Matt Morley
533f8c97fd Add constrained solvePNP strategy (#1682)
Signed-off-by: Jade Turner <spacey-sooty@proton.me>
Co-authored-by: Jade Turner <spacey-sooty@proton.me>
2025-02-19 14:15:27 +08:00
Sam Freund
e97865166d [build] Bump WPILib to 2025.3.1 (#1785) 2025-02-17 14:04:25 +08:00
David Vo
ab41d2d1ed photonlibpy: Explicitly re-export (#1737) 2025-01-17 18:28:16 -08:00
David Vo
a08dc374c8 photonlibpy: License under MIT (#1700)
Everything under the `photon-lib` directory is intended to all be
licensed under MIT:


e40c8fbca0/photon-lib/.styleguide-license (L2)

Presumably we don't want to force teams to release their robot code
under GPL.
2025-01-13 12:00:09 -05:00
Jade
5f75619063 Bump python projects to 2025.2.1 (#1705)
Blocked on robotpy release

---------

Signed-off-by: Jade Turner <spacey-sooty@proton.me>
Co-authored-by: Matt Morley <matthew.morley.ca@gmail.com>
2025-01-12 16:24:36 -05:00
DeltaDizzy
d487e1c466 Fix deprecation warnings in PhotonLib examples (#1699)
The following deprecation warnings have been fixed:
- `SwerveModuleState.optimize(desiredState, currentRotation);`, which is
now an instance method
- `AprilTagFields.kDefaultField.loadAprilTagLayoutField();`, which is
now `AprilTagFieldLayout.loadField(AprilTagFields.kDefaultField);`

WIP:
- [x] C++
- [x] Python
2025-01-11 23:30:24 -05:00
mythgarr
159b848234 [python] Fix PhotonPipelineMetadata constructor arg order (#1698)
Relates to https://github.com/PhotonVision/photonvision/pull/1578
2025-01-11 23:29:19 -05:00
David Vo
53e6890f20 photon-serde: Relicense generated files under MIT (#1709) 2025-01-11 16:55:55 -07:00
Jochem
cc740c92c9 Added constructor overload to PhotonCameraSim for AprilTagFieldLayout (#1692) 2025-01-08 11:43:46 -07:00
Chris Gerth
6c7a174424 Adding timeSyncServer for Python (#1675) 2025-01-03 12:23:27 -06:00
Jade
7c254ec5dc Change from k2024Crescendo to kDefaultField for AprilTagFieldLayout (#1667)
This reduces the things we need to update each year

Signed-off-by: Jade Turner <spacey-sooty@proton.me>
Co-authored-by: Matt <matthew.morley.ca@gmail.com>
2025-01-03 22:03:00 +08:00
Nolan Brown
b7a2636e97 [photon-lib] Fix sim tag ambiguity (#1653) 2024-12-29 17:43:55 -05:00
Jade
ffc4e06ac6 Move to main over master (#1642)
Resolves https://github.com/PhotonVision/photonvision/issues/251

---------

Signed-off-by: Jade Turner <spacey-sooty@proton.me>
2024-12-20 09:24:52 -08:00
Craig Schardt
6a8d638853 Fix typehint problem with ndarrays (#1631)
mypy was inferring the wrong type for ndarrays in photonCameraSim.py.
This fixes the problem by adding typehints using numpy.typing.NDArray.
2024-12-09 05:21:37 +00:00
Craig Schardt
4997ad9115 Fix formating errors that are in master (#1627)
A few files with format mistakes were merged into master and they cause
spotless and wpiformat to fail. This PR fixes those files.
2024-12-06 22:21:05 +00:00
James Ward
1dbd2e5990 [python] Correct time units (#1605) 2024-11-28 16:12:52 +00:00
Lucien Morey
61552ad6ca Tidy up of python autogenerated messages (#1594)
This fixes mostly formatting issues so there is no longer any diff with
things after rerunning the generation script. Yes, most of this can be
fixed by running wpiformat but that doesn't exist as a pre-commit hook
atm, so I think this is nicer.

It also removes any reference to the java encode/decode within the
python message gen
2024-11-21 04:43:33 +00:00
Lucien Morey
fa66ed866c add file marker for type checking (#1598)
I think this is the correct way to do this based on my understanding of
the guide to making a [pep561 compliant
package](https://mypy.readthedocs.io/en/stable/installed_packages.html#creating-pep-561-compatible-packages)
and this example in
[black](https://github.com/psf/black/pull/1395/files). Given that I get
all the type-checking info from a local installation, I don't know if
this is testable until it's published on Pypi.

resolves #1210
2024-11-21 04:43:05 +00:00
Lucien Morey
c536a1c312 add missing log and use logger over print (#1596)
This is closer to a port of the Java/C++ stuff and will mean we get a
more standard print output with the rest of the logging in the lib
2024-11-21 03:01:08 +00:00
James Ward
3a9d22c76b Handle remote UUID mismatch properly (#1590)
Check for no response
Only throw if incorrect version, and not when missing

Resolves #1569
2024-11-18 21:28:07 -05:00
Lucien Morey
097e641789 [Python] remove opencv dependency for robot installations (#1580) 2024-11-16 18:26:07 -08:00
James Ward
f107c94d05 [python] Fix population of metadata (#1578) 2024-11-16 18:25:43 -08:00
Lucien Morey
04191efc51 sphinxify java docs for python code (#1575) 2024-11-15 18:01:33 -08:00
Lucien Morey
dfed7e3621 Break up masssive python overload hacks (#1573)
What it says on the tin. This is all stuff from our initial effort to
port the sim things. Right now it is coupled to #1557 because this fixes
things up in that. Lets merge that one before dealing with this one
2024-11-14 14:59:55 -08:00
Lucien Morey
c50c657193 Add Python test harness for openCVHelp class (#1557) 2024-11-14 11:10:08 -05:00
Lucien Morey
a64491a59e [photonlibpy] add mypy to ci (#1570)
Co-authored-by: James Ward <james@thedropbears.org.au>
2024-11-13 10:39:02 -05:00
Lucien Morey
a7319ce1d6 [photonlibpy] bump python dependencies for 2025 (#1567)
I tasked my team with updating our upcoming Reefscape codebase to target
2025 packages, only to realise we have created an unsolvable dependency
nightmare with these things being neglected...
2024-11-13 10:38:44 -05:00
Lucien Morey
02c94ea7ed [photonlibpy] stop getting full stack trace on test failure (#1568)
Signal/noise ratio is too low with this enabled. When dealing with #1567
I got ~46000 lines of errors going around in a circle rather than just
an import failure at the scope of each failed test
2024-11-13 10:38:17 -05:00
James Ward
744e522aea Correct yet more python type hinting (#1555) 2024-11-12 11:17:27 -05:00
David Vo
af03ae0a8b photonlibpy: Fix some type check failures (#1548)
This fixes a variety of type check failures raised by both mypy and pyright. See #1548
2024-11-12 00:53:43 -05:00
Lucien Morey
b3d74e56a0 Add python simulation (#1532) 2024-11-10 14:16:02 -08:00
Jade
d8de4a7863 [build] Update wpiformat to 2024.45 (#1545)
Signed-off-by: Jade Turner <spacey-sooty@proton.me>
2024-11-10 13:42:16 +08:00
Lucien Morey
d188c37466 Fix missing vars and catch bad shim (#1541)
I made a mistake when cherry-picking things into #1534. Fixing it also
prompted me to regenerate message things without thinking even though it
wasn't needed here but it helped me catch an issue with a bad shim. I
must not have saved it properly on my computer and missed it before
review.
2024-11-09 17:32:35 -05:00
Lucien Morey
14fcc5d485 generate packing for python messages (#1535)
Generate packet serialization in Python, too.
2024-11-09 13:08:45 -05:00
Lucien Morey
1d8d934a8a Enable Python tests, standardise variable spelling and fix arg checking (#1533)
I found these with a quick find-and-replace and checked against the inbuilt Python type checking. I am away from my robot and can't really
confirm there are no flow-on effects. There are no other active usages of the bad casing in the Python code, so we should be good. The generated serde messages already use this casing, so we don't need to update there.
2024-11-09 08:08:57 +08:00
Lucien Morey
bdb2949b4b Stop type hinting members as optional in PhotonTrackedTarget (#1539)
List types should never be optional if sent to NT because an empty list conveys the same
thing.

The equivalent C++ struct takes the same approach with empty vectors rather than an optional vector.
2024-11-09 07:58:56 +08:00
Lucien Morey
150561abf2 Add missing var to dataclass (#1534) 2024-11-07 18:31:21 -05:00
Matt
fc8ecac376 Create TSP Server in C++ photonlib (#1516)
Automatically starts a TCP server in C++. Also adds warnings to Python.
2024-11-01 23:32:38 -07:00
Matt
37aaa49b32 Create timesync JNI for testing client (#1433) 2024-10-31 08:27:19 -07:00
Matt
7da2ec1948 Fix PhotonCamera typestring checks (#1480)
Previously NT would quietly drop readQueue changes.
2024-10-20 22:21:24 -07:00
Matt
f33218c49c Add message UUID and type names to hash and message defintion (#1409) 2024-09-22 22:27:13 -04:00
Chris Gerth
9e6a066561 Examples Clean-Up (#1408) 2024-09-15 00:10:02 -04:00
Matt
169595e56e Auto-generate packet dataclasses with Jinja (#1374) 2024-08-31 13:44:19 -04:00
Matt
738e3646f7 Photonlibpy - Best Target Function #1223 (#1406)
Supercedes https://github.com/PhotonVision/photonvision/pull/1223

---------

Co-authored-by: vladb <vlad.bondar@frc5113.com>
2024-08-31 12:30:09 -04:00
Matt
67463a020a Use ReadQueue for PhotonCamera timestamps (#1316)
This removes the extra GetLastChange call to keep everything properly
atomic.

Closes #1303
2024-08-04 14:23:46 -04:00