Commit Graph

55 Commits

Author SHA1 Message Date
Gold856
0dfca8c04f Always statically import JUnit Assertions 2025-04-19 17:17:34 -07:00
Gold87
8d4024b8c8 Add alerts for timesync and disconnection (#1799) 2025-03-13 23:13:51 -07:00
Gold87
f6736fc730 Force load opencv before using OpenCV functions (#1808)
Force loads OpenCV before any OpenCV functions are used. `OpenCVLoader`
has all of its loading done in a static initializer field, so it's only
loaded once.

Also deprecates `OpenCVHelp.forceLoadOpenCV()`, since it's functionality
is the exact same.

Resolves #1803
2025-03-14 07:50:41 +08: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
Julius
01a3d31734 Add 6328's implementation of PNP distance for Trig Solving to PhotonPoseEstimator (#1767)
https://discord.com/channels/725836368059826228/725846784131203222/1334309604946874460


https://www.chiefdelphi.com/t/frc-6328-mechanical-advantage-2025-build-thread/477314/85

Helps with ambiguous single tag estimates and produces more stability.
2025-02-13 11:45:18 -08:00
Matt Morley
8f816cf1af Verify WPILib/OpenCV versions at runtime (#1772) 2025-02-10 17:52:48 -08:00
Joseph Eng
99427d888a Fix fallback for the multitag on rio pose strategy (#1755) 2025-02-01 14:09:43 -08:00
Gold856
1303a0eaae Fix typos and incorrect param order in Javadoc (#1740) 2025-01-19 22:56:47 -05:00
Nolan Brown
b7a2636e97 [photon-lib] Fix sim tag ambiguity (#1653) 2024-12-29 17:43:55 -05:00
Matt
faa9eb0093 Disable VisionSystemSimTest entirely (#1584)
This test is still failing on main, see
https://github.com/PhotonVision/photonvision/actions/runs/11875827435/job/33093483193
2024-11-18 01:55:00 -05:00
Matt
478723ca2c Skip Vision System Sim Tests on Windows (#1581) 2024-11-16 20:09:41 -08:00
Jade
75e2498f53 Fix typos (#1508)
Signed-off-by: Jade Turner <spacey-sooty@proton.me>
2024-11-01 23:51:16 -04:00
Matt
7a4ea3dd56 Assert that version checking won't throw on startup (#1512)
# Overview

Previously if the coproc came up later, getProperty would return the
string literal "null", which made us print the BFW. Add tests to make
sure that we don't do that anymore by rebooting a sim coproc +
robot in a combination of different orders.
2024-11-01 23:50:21 -04:00
Matt
37aaa49b32 Create timesync JNI for testing client (#1433) 2024-10-31 08:27:19 -07:00
Cameron (3539)
937bafa8e2 Bump to WPILib 2025 Beta 1 & remove C++ protobuf (#1484)
Remove C++ protobuf support until
https://github.com/wpilibsuite/allwpilib/issues/7250 is addressed.
Developers should upgrade to wpilib vscode 2025 beta 1.

---------

Co-authored-by: Matt <matthew.morley.ca@gmail.com>
2024-10-31 02:59:39 -04:00
Cameron (3539)
546058593e Roll Back to 2024.3.2 (#1423)
Roll back to 2024.3.2 to get some good testing on actual robots.
2024-09-15 20:01:11 -04:00
Matt
169595e56e Auto-generate packet dataclasses with Jinja (#1374) 2024-08-31 13:44:19 -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
Matt
98633e9150 Bump wpilib to latest dev (#1327) 2024-05-26 14:02:07 -05:00
Matt
1708376df8 Expose object detection class id/conf in photonlib (#1266)
* Implement class id/conf in photonlib

* Maybe fix things

* run lint

* Update Packet.java comments

* Update Packet.java comments again

* Update comments

* oops

* Update packet.py

---------

Co-authored-by: Chris Gerth <gerth2@users.noreply.github.com>
2024-05-10 14:52:16 -04:00
Matt
113951100e Add sequence ID, capture, publish and recieve timestamp to PhotonPipelineResult (#1305)
Closes #1304
2024-05-10 14:04:34 -04:00
amquake
39216db143 [photonlib] Invert simulated target yaw (#1243) 2024-02-18 20:59:54 -05:00
Thad House
6917ec8401 Fix vendordep including all wpilib libraries (#1155)
* Fix vendordep including all wpilib libraries. Without this fix, users were consuming a massively oversized .jar
2024-01-13 18:57:56 -06:00
Sriman Achanta
5be9b8be2c Add PacketSerde interface and expand PacketUtils for more wpimath classes (#1058)
Follows a similar system to the current Protobuf implementation that helps make code more readable and expandable. Also wraps the NT topic to be more useful. Impl stuff is hidden so it can't be extended. Optimizes AT-specific classes by only serializing data when needed, won't save on size but will on time.

closes #1003
2023-12-24 19:56:08 -05:00
Sriman Achanta
308fd801d4 [photon-targeting][photon-lib] Add tests to the targeting classes and cleanup photon-lib & photon-targeting (#1007)
* Make MultiTagPNPResult and PNPResult singular

* add java tests

* Formatting fixes

* bring in the rest of the little stuff

* final things

* Formatting fixes

* add multisubscriber back

* Formatting fixes

* make comments better about x and y relationship
2023-11-15 18:28:26 -05:00
Sriman Achanta
0898dfe2f7 Aruco/Multitag 36h11 support (#981)
- Aruco pipeline now infers tag width from tag family like the AprilTag pipeline
- Removes unused Aruco and 200mm AprilTag models
- `VisionEstimation.estimateCamPosePNP()` now requires a target model instead of assuming 16h5
  - Multitarget pipeline similarly infers target model of tag family now
  - `PhotonPoseEstimator` can have target model set for on-rio multitarget

---------

Co-authored-by: amquake <noleetarrr@gmail.com>
2023-10-29 23:02:16 -04:00
Sriman Achanta
63147786b9 Fix MacOS OpenCV library loading and use wpi buildTools versions (#978)
* Bump to beta 2

* Reduce copy paste spam going forwards

* Bump gradle

* oops

* fix gradlew

* update gradle wrapper props

* remove unused imports

* Update node task

* Fix shadowjar

* fix more deps

* ?

* core works

* revert changes to index

* Formatting fixes

* Update config.gradle

* Fix PhotonLib gradle

* fix tests and sim loading native libraries

* re-enable macos build

* fix?

* Update build.gradle

---------

Co-authored-by: Matt <matthew.morley.ca@gmail.com>
2023-10-25 20:27:56 -04:00
Matt
47bd077bbb Run multitag on coprocessor (#816) 2023-10-17 10:20:00 -04:00
amquake
c8c9e779ab [photon-core] 2D Detection data accuracy (#896)
Use calibration data for 2d target info when available (principal point, FOV)

Correct perspective distortion in 2d yaw/pitch info
2023-10-15 13:44:47 -04:00
amquake
7f283640c4 [photonlib] Simulation Visualization Update (#895) 2023-09-19 19:10:04 -04:00
amquake
816bbca2f1 [photonlib] Simulation robustness (#874)
- `PNPResults` can now be empty (`isPresent` = false)
- solvePNP methods actually handle errors and return empty `PNPResults`
  - This reveals an odd error where some inputs to `solvePNP_SQUARE()` resulted in an estimated transform with NaN values, and attempts to handle it
- Overwrites java changes from #817 since #742 had duplicate fixes
- Minor bugfixes
2023-07-23 18:32:36 -07:00
amquake
f1cadc1e1e [WIP] Simulation Overhaul (#742)
### What does this do?

- Deprecates previous sim classes
- Has a `CameraProperties` class for describing a camera's basic/calibration info, and performance values for simulation. Calibration values can be loaded from the `config.json` in the settings exported by photonvision.
- `OpenCVHelp` provides convenience functions for using opencv methods with wpilib/photonvision classes, mainly to project 3d points to a camera's 2d image and perform solvePnP with the above camera calibration info.
  - `TargetModel`s describe the 3d shape of a target, both for projecting into the camera's 2d image and use in solvePnP.
- `PhotonCameraSim` uses camera properties to simulate how 3d targets would appear in its view, and has simulated noise, latency, and FPS. For apriltags, the best/alternate camera-to-target transform is also estimated with solvePnP.
  - `VideoSimUtil` has helper functions for drawing apriltags to a simulated raw and processed MJPEG stream for each camera using the projected tag corners.
- `VisionSystemSim` stores `VisionTargetSim`s and `PhotonCameraSim`s, and is periodically updated with the robot's simulated pose. When updating, camera sims are automatically processed and published with their visible targets from their respective poses with proper latency.

### What's still not working?

- Mac Arm builds are broken
- More examples
- Update website/docs
2023-06-18 18:54:12 -04:00
Sriman Achanta
c148331b69 Bump License year to 2023 (#841)
* Bump version

* remove year entirely
2023-04-18 18:49:40 -04:00
Joseph Eng
545e016d04 Cache pose calculations in PhotonPoseEstimator (#788)
* Add pose caching to Java

* Refactor strategy fallthrough

* Hopefully add pose caching to C++

* Make Java switch same order as enum and C++ switch

* C++ absolute value in timestamp check

* Fix Java NPE

* Use `units::second_t` in timestamp

Co-authored-by: Matt <matthew.morley.ca@gmail.com>

* Expand Java unit test

* Copy comments into C++

* Add tests to C++

* Run format

* Update PhotonCamera.cpp

* Probably fix bad access exception

* a

* init timestamp

* Remove prints

---------

Co-authored-by: Matt <matthew.morley.ca@gmail.com>
Co-authored-by: Joseph Eng <joseng2358@gmail.com>
2023-02-13 21:22:22 -05:00
Matt
5b86360b9b Multi-tag pnp in robot code (#787)
---------

Co-authored-by: Banks Troutman <btrout.dhrs@gmail.com>
Co-authored-by: Joseph Farkas <16584585+MrRedness@users.noreply.github.com>
2023-02-13 17:57:01 -05:00
Andrew Gasser
357d8a518a Return named type from PhotonPoseEstimator (#734)
Adds PhotonPoseEstimator class, and deprecates RobotPoseEstimator
2023-01-14 10:06:15 -05:00
Matt
967be84b4b Expose detected tag corners (#702)
Removes GetCorners, replaces with getMinAreaRectCorners and getDetectedCorners
2023-01-06 22:20:27 -05:00
Nick Hadley
dbe7464ea9 Change pose estimator to take robotToCamera (#698)
Co-authored-by: Matt <matthew.morley.ca@gmail.com>
2023-01-06 17:41:47 -05:00
Nick Hadley
0b5256df12 RobotPoseEstimator Enhancements (#677)
* Use List for RobotPoseEstimator constructor

* Update `RobotPoseEstimator` constructor to accept wpilib `AprilTagFieldLayout` java

* Initial cpp changes

* Java return optional from update

* Fix java test

* Clean up strategy switch

* small lint

* Actually link to vision_shared

* Fix auto optimized imports

* format

* report error

* small method changes

* format and clean up

Co-authored-by: Matt <matthew.morley.ca@gmail.com>
2023-01-02 18:22:39 -06:00
Chris Gerth
aaa886bd73 Java-side bugfixes for RobotPoseEstimator and PhotonCamera (#685)
Closes #684
Closes #683
Closes #681
Closes #680
Closes #678
2023-01-01 22:40:48 -05:00
Jack
550194152a Add RobotPoseEstimator (#571)
RobotPoseEstimator can pick the most likely pose for the robot given a number of possible poses, using a number of different strategies. Examples are still WIP.
2022-12-30 01:40:13 -05:00
Mohammad Durrani
915f784d9d Add distance, yaw, and robot pose methods to photonlib (#642) 2022-12-25 00:00:00 -05:00
shueja-personal
bb63af601d Update to wpilib 2023 beta 7 (#607)
We now need platform specific jars -- reworks actions to support that. Currently only generates 32 bit pi images.
2022-12-16 20:05:23 -05:00
Chris Gerth
b408a58e9e Sim Updates for 2023 (#512)
* WIP updating sim stuff for 2023 and pose3d's

* vision system build fixups, but test not yet passing.

* WIP Sim fixups and working on testcases

* Still doesn't work, but closer

* tests pass

* removed C++ sim support

* formatting update

* adjusted target height above ground per review

* Turns out its unused

* missed example removal
2022-11-03 15:05:37 -05:00
Matt
2d7a88e231 Expose both pose solutions (#521)
* Half-add second pose

* add c++

* run wpiformat

* Fix c++
2022-10-22 06:42:45 -05:00
Matt
2c6b0ddac3 Expose pose ambiguity (#483)
* Expose pose ambiguity

* Run spotless

* Add tooltips and expose number of iterations
2022-10-08 09:27:00 -04:00
shueja-personal
a764ace7f2 Initial AprilTag support (#458)
(Very) beta AprilTag support in PhotonVision. Disables Picam GPU acceleration until we can debug auto exposure in the MMAL driver.

Co-authored-by: Banks Troutman <btrout.dhrs@gmail.com>
Co-authored-by: Matt <matthew.morley.ca@gmail.com>
Co-authored-by: Chris Gerth <gerth2@users.noreply.github.com>
Co-authored-by: Chris <chrisgerth010592@gmail.com>
Co-authored-by: mdurrani808 <mdurrani808@gmail.com>
2022-09-28 21:21:41 -04:00
Matt
9090aa6bcc Add version verification disable switch in photonlib (#437) 2022-02-28 07:37:52 -05:00
Tyler Veness
9893cf1f7e Update photonlib and photonlib example license headers to MIT (#395) 2022-01-20 22:35:28 -05:00
Matt
3ad476bc28 Send corners of min area rectangles (#382)
Adds a new corners entry to targets. Breaks byte-packed backwards compatibility. 

Co-authored-by: Tyler Veness <calcmogul@gmail.com>
2022-01-10 20:31:36 -08:00