Commit Graph

80 Commits

Author SHA1 Message Date
amquake
39216db143 [photonlib] Invert simulated target yaw (#1243) 2024-02-18 20:59:54 -05:00
Tim Winters
0eb0a4e3c5 Store the last pose on update (#1207)
* Store the last pose on update

* Don't clear lastPose if pose isn't calculated

---------

Co-authored-by: Mohammad Durrani <46766905+mdurrani808@users.noreply.github.com>
2024-02-05 09:50:36 -05:00
Sriman Achanta
d85bafa0eb fix naming (#1089) 2024-01-04 13:20:29 -05:00
Matt
7f09f9e4f5 Save calibration data and show preliminary GUI (#1078)
* Serialize all calibration data

* Run lint

* typing nit

* fix code

* move these tables around some

* Add cool formatting

* add request to get snapshots by resolution and camera

* re-enable all resolutions

* add wip so i can change computers (SQUASH ME AND KILL ME AHHHH)

* Get everything working but viewing snapshots

* Update RequestHandler.java

* Update CameraCalibrationInfoCard.vue

* Update CameraCalibrationInfoCard.vue

* add observation viewer

* round

* fix illiegal import

* Swap to PNG and serialize insolution

* move import/export buttons TO THE TOP

* Update WebsocketDataTypes.ts

* Add snapshotname to observation

* Refactor to serialize snapshot image itself

* Run lint

* Use new base64 image data in info card

* Update SettingTypes.ts

* Create calibration json -> mrcal converter script

* Update calibrationUtils.py

* Fix calibrate NPEs in teest

* Run lint

* Always run cornersubpix

* Update CameraCalibrationInfoCard.vue

Update CameraCalibrationInfoCard.vue

* Update OpenCVHelp.java

* Update OpenCVHelp.java

* Replace test mode camera JSONs

* Run wpiformat

* Revert intrinsics but keep other data

* Remove misc comments

* Rename JsonMat->JsonImageMat and add calobject_warp

* Update Server.java

* Rename cameraExtrinsics to distCoeffs

* fix typing issues

* use util methods

* Formatting fixes

* fix styling

* move to devTools

* remove unneeded or unused imports

* Remove fixed-right css

If its really that big of a deal, we can add it back later, kind of a drag to fix rn.

* Create util method

* Remove extra legacy calibration things

---------

Co-authored-by: Sriman Achanta <68172138+srimanachanta@users.noreply.github.com>
2024-01-03 16:32:04 -05:00
Drew Williams
96de176ba2 Changes sim to use 36h11 tags (#1056)
Fixes #1041

---------

Co-authored-by: Drew Williams <DrewW@iARx.com>
Co-authored-by: Matt <matthew.morley.ca@gmail.com>
2024-01-02 08:09:32 -07:00
Chris Gerth
b9c2d839f4 Update big friendly warning to look better. (#1101)
The driver station supports neither monospace fonts nor unicode, so we can't be as... ummm... artistic... with what we put there.
2024-01-01 17:30:57 -05:00
Chris Gerth
e3eff8731f Version mismatch is harder to miss. (#1088) 2023-12-30 15:34:52 -05: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
2e39549771 Bump wpilib to 2024-beta-4 and report resource photon usage ids from 2024v2 image (#1042) 2023-12-16 13:14:52 -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
Matt
524b135142 Fix OpenCV load in simuated robot projects (#1001) 2023-11-05 15:13:00 -08:00
amquake
9370937280 [photon-lib] Make PhotonPoseEstimator coprocessor multitag result relative to tag layout origin (#997)
Fixes #991.
2023-11-04 12:25:49 -04: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
amquake
d61225eba3 [photon-lib] Simulate multitag result (#973) 2023-10-25 18:35:06 -07:00
amquake
5b2be119e7 [photon-lib] Cleanup simulation Rotation3d usage (#982) 2023-10-25 18:19:48 -07: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
Matt
6e8e3a0cba [OpenCVHelp] Use correct Rotation3d constructor (#934)
This fixes a occasional division by zero
2023-10-09 09:44:45 -04:00
amquake
2881741226 Fix false-positive vision estimation edgecase (#932)
> there is a problem if the found tags are a valid one plus an invalid tag, so eg it sees a tag but finds noise on the wall, and so lists tags 2 and 15. Lines 90-99 will ignore tag 15, and put 4 corners into the list. It will get past the test on line 100 (there are 4 corners). BUT then at line 106, there are 2 entries in visTags, so it will go to the "else" and try to use solvePNP_SQPNP().
2023-10-07 20:59:19 -04:00
amquake
ce0d28da93 Update Java Simulation Examples (#913)
Removes apriltagExample and simposeest, replacing them with swervedriveposeestsim

---------

Co-authored-by: Matt <matthew.morley.ca@gmail.com>
2023-10-05 08:57:38 -04:00
amquake
7f283640c4 [photonlib] Simulation Visualization Update (#895) 2023-09-19 19:10:04 -04:00
Ryan Blue
de394418f6 Improve docs for PhotonPoseEstimator (#901)
In particular, document that update() ensures that new data is only used once.
2023-08-30 18:49:26 -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
4a94775639 Update PhotonPoseEstimator.java (#869) 2023-06-18 06:38:43 -05:00
Matt
f6756bdb9a Don't add bad corners to multi-tag solution (#817)
Closes #837


---------

Co-authored-by: Chris Gerth <gerth2@users.noreply.github.com>
2023-06-18 01:16:10 -04:00
Sriman Achanta
a723d3dc5c [PhotonPoseEstimator] Check for CalibData before adding Tags when using SolvePNP method (#826)
Closes #825 by re-organizing multi-tag strategy order. Should be NFC


---------

Co-authored-by: Matt <matthew.morley.ca@gmail.com>
2023-06-18 00:00:30 -04:00
person4268
6d2eae7f20 Add ignored cameras regex to command-line arguemnts (#849)
This adds a regex that ignores cameras if they match it, for if you have another piece of software running that needs a second camera, or if you have a webcam in your laptop that cscore hates.
2023-06-03 21:04:04 -04:00
Sriman Achanta
c148331b69 Bump License year to 2023 (#841)
* Bump version

* remove year entirely
2023-04-18 18:49:40 -04:00
Murad
2d586fe1c0 Add PhotonPoseEstimator constructor without a PhotonCamera instance (#840)
- Made alternate constructor for ```PhotonPoseEstimator``` that doesn't need ```PhotonCamera```
- Changed ```update``` function to take in missing cameraMatrixData and coeffsData that were previously received from PhotonCamera.
- Changed the internal ```update``` and ```multiTagPNP``` function to take in cameraMatrixData & coeffsData
- If not needed for the specified strategy then the parameters are simply not used. Also if PhotonCamera is used in constructor it instead backs up to that.

Co-authored-by: Matt <matthew.morley.ca@gmail.com>
2023-04-18 13:50:23 -04:00
Matt
8e724ef60f Fix driver mode pub/sub key mixup (#810) 2023-02-17 09:21:10 -05:00
Matt
a4554d9bd4 Fix non-checked optional in mulit-tag (#808)
* Fix non-checked optional in mulit-tag

* Fix fallback return

* Run format
2023-02-14 19:50:17 -05:00
Matt
abe32a1aae Fix calibration NT table in PhotonCamera (#805)
* Fix wrong table in calibration subscriber

* Update example to load 2023 layout

* Update PhotonCamera.java
2023-02-14 13:49:28 -05:00
Andrew Gasser
bf4a4db874 Docs corrections related to PhotonPoseEstimator (#804) 2023-02-14 13:49:08 -05: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
PJ Reiniger
0255798d6c Add ability query camera results outside of PhotonPoseEstimator (#786) 2023-02-09 14:43:52 -05:00
Matt
6886663688 Robustify setting pipeline index (#790) 2023-02-08 21:07:12 -05:00
Mihir Patankar
241961ae7a Un-finalize robotToCamera, add getters and setters (#789)
Allows teams with a mechanism that moves the camera's position (eg, a pan and tilt mechanism) to update the location of their camera for their pose calculations.

---------

Co-authored-by: Matthew Morley <matthew.morley.ca@gmail.com>
2023-02-06 09:51:35 -05:00
Matt
f6e3c9b3ee Fix desync between web UI and NT (#778)
Actually calls VisionModule::setPipeline when changing pipelines (needed to change video modes)
2023-01-29 23:30:34 -05:00
Sriman Achanta
167a4661ca [NFC] Update RobotPoseEstimator documentation (#740)
* update documentation

* add suggested changes

* rename April Tag to AprilTag

* Update RobotPoseEstimator.java

Co-authored-by: Mohammad Durrani <46766905+mdurrani808@users.noreply.github.com>
2023-01-17 20:34:21 -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
Nick Hadley
39f6ab8805 Add method to clear sim targets (#733)
Closes #731
2023-01-11 12:33:19 -05:00
Matt
53c67a07e4 [photonlib] Only link to apriltag_shared (#730) 2023-01-10 10:09:24 -05:00
Matt
967be84b4b Expose detected tag corners (#702)
Removes GetCorners, replaces with getMinAreaRectCorners and getDetectedCorners
2023-01-06 22:20:27 -05:00
Matt
087429dab9 [Workaround] Publish rawBytes as periodic (#707)
Closes #704 -- addressed by upstream PR https://github.com/wpilibsuite/allwpilib/pull/4903 (not released yet)
2023-01-06 17:53:19 -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
0f427bb52b Update PhotonCamera error messages to be more specific (#697)
Closes #692
2023-01-05 19:28:32 -05:00
Matt
e68e6f3181 Update SimPhotonCamera.java (#703) 2023-01-05 06:43:23 -06: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