Compare commits

...

278 Commits

Author SHA1 Message Date
Jade
d78f2b8650 Add LL3g to release (#1727) 2025-01-14 06:38:42 -08:00
Devon Doyle
5e5df483e2 Camera disconnected + stream normalization improvements (#1701) 2025-01-13 23:30:25 -08:00
Matt Morley
009ec9e1d4 Bump images to v2025.0.3 (#1724) 2025-01-13 15:17:47 -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
Liam Stow
5b0ec742c4 add [[maybe_unused]] to EstimateCamPosePNP() (#1721)
Fixes #1716
2025-01-13 11:36:06 -05:00
Craig Schardt
04e28bc2d8 Bump images to v2025.0.2 (#1717) 2025-01-12 20:52:45 -07:00
Sam Freund
966b9e8c61 Yolo duplication fix (#1713)
Somebody wanted a description, so here I am.

This PR fixes an error which caused the discoverModels function to be
rerun after each upload of a new model, but without clearing the list of
available models. This causes any models that were on the list prior to
the import to be duplicated. This PR also makes it so that uploading a
model automatically updates the list of available models.

---------

Co-authored-by: Matt Morley <matthew.morley.ca@gmail.com>
Co-authored-by: Chris Gerth <gerth2@users.noreply.github.com>
2025-01-12 19:48:39 -06: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
person4268
03ff9357d7 Remove nonfunctional ignore-cameras CLI arg (#1708)
The underlying logic appears to have been removed. I don't think anyone
really used this option, and the new camera matching stuff makes it
redundant.
2025-01-12 16:23:59 -05:00
Matt Morley
d05032963d Create new tag workflow (#1645) 2025-01-12 11:34:36 -07:00
Matt Morley
7d9f9a627c Document v4l latency (#1676) 2025-01-12 11:30:36 -07:00
Jade
2d19908119 fix docs ci not running (#1707)
Signed-off-by: Jade Turner <spacey-sooty@proton.me>
2025-01-11 23:50:39 -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
Matt Morley
83c124f7fc Ingest wpilib!7609 and add turbo button (#1662)
Now that https://github.com/wpilibsuite/allwpilib/pull/7572 and
https://github.com/wpilibsuite/allwpilib/pull/7609 have been merged:
- Adds a magic hidden button to enable the new frame grabber behavior by
adding a boolean topic at `/photonvision/use_new_cscore_frametime`.
Toggle this to true to maybe increase FPS at the cost of latency
variability
- Bumps WPILib to ingest
https://github.com/wpilibsuite/allwpilib/pull/7609 , but doesn't
currently provide any user feedback about the time source. I don't think
that reporting this super matters?

---------

Co-authored-by: Jade <spacey-sooty@proton.me>
2025-01-11 07:37:09 -07:00
Jade
05348f3981 [build] Bump to WPILib 2025.2.1 (#1703)
Signed-off-by: Jade Turner <spacey-sooty@proton.me>
2025-01-11 22:09:45 +08:00
Devon Doyle
e40c8fbca0 Calibration card and PV input styling (#1695)
Images are before and after comparison.
Does the following:
- Fixes several styling issues with pv-* input elements, including top
padding, vertical alignment, and allocated input width

![image](https://github.com/user-attachments/assets/70d37e65-e0cd-4c71-8ea1-941ec2175850)

![image](https://github.com/user-attachments/assets/031d008d-3cce-4ed2-bc88-5fbecf20c94f)

- Conforms the calibration details modal to overall styling and spacing
standards

![image](https://github.com/user-attachments/assets/18281551-f924-4e12-9ad4-d2ec470dbc70)

![image](https://github.com/user-attachments/assets/db772325-7650-467d-8521-252c7d38601f)
(left the blank table there on empty calibrations to give the user a
sense of what they might see if they don't have any)
2025-01-08 16:46:31 -05:00
Sam Freund
27684eef60 Add custom models (#1687) 2025-01-08 11:44:06 -07:00
Jochem
cc740c92c9 Added constructor overload to PhotonCameraSim for AprilTagFieldLayout (#1692) 2025-01-08 11:43:46 -07:00
Jade
e673304221 Use pragma once (#1693)
Signed-off-by: Jade Turner <spacey-sooty@proton.me>
2025-01-09 00:49:53 +08:00
Matt Morley
974fcec21e Cancel previous GH commit jobs (#1690) 2025-01-08 09:24:49 -07:00
Sam Freund
36e3a1f72e Update references in docs to 2025 (#1685)
Fixes #1651
2025-01-07 15:38:20 -07:00
Craig Schardt
5993e79e00 Update images to v2025.0.0 (#1680)
Use the shiny new images for 2025.
2025-01-07 13:00:52 -05:00
Devon Doyle
484e8d4298 General UI Refinements (#1678)
Does the following:
- Adjusts the shade of red buttons and banners to increase readability
and reduce eye strain

![image](https://github.com/user-attachments/assets/7f741a9e-dc1e-4394-b87d-580e189245b1)

![image](https://github.com/user-attachments/assets/b23202f1-4cf6-46c1-aca5-2455a09259cd)

- Cleans up factory reset and camera deletion modals

![image](https://github.com/user-attachments/assets/e6564732-d578-43da-bc83-729ec6fdbc5e)

![image](https://github.com/user-attachments/assets/9c5a1cba-f4fd-47ea-811c-abbabe5fa3a4)

- Removes matchCamerasOnlyByPath as it is no longer used and throws
errors in the console

![image](https://github.com/user-attachments/assets/77043993-26a2-4de4-8e98-702e7f285dc6)

- Limits the criteria to flag a camera mismatch in Camera Matching to
only what is necessary based on camera type and highlights differences
in table properties (testing on this is appreciated)

![image](https://github.com/user-attachments/assets/cfbd96c1-09dd-414a-8177-693fc054b26f)

- Only displays both saved vs. current info in camera matching if there
is a difference between the two

![image](https://github.com/user-attachments/assets/6223ffc8-4cff-464f-8b54-720c3222a5d5)

- Some general code cleanup (reduced unnecessary padding/margin/row-col
statements, style="display:flex;" -> class="d-flex", etc.
- Moves Compact Mode button to the bottom away from all the menu items
(cleaner imo, open to thoughts)
- Establishes a general spacing format for cards and pages and applies
this to existing cards and pages to create a consistent look and feel to
the UI (e.g. keeping things in line and less erratic spacing/placement
of UI elements)

![image](https://github.com/user-attachments/assets/1ab0ca4b-303e-436d-97b3-da72d46c4fcb)

![image](https://github.com/user-attachments/assets/82ba9e53-f854-4309-bc00-7b5d0bad58b7)

![image](https://github.com/user-attachments/assets/18aa6ca4-e6fa-4125-8a0a-e6a007a0337d)

![image](https://github.com/user-attachments/assets/77043993-26a2-4de4-8e98-702e7f285dc6)


- Delete protection for camera matching modules
- Anti-backend-spam for activate/deactivate/delete modules to hopefully
prevent any odd behavior from button spamming
- Enforces a common camera stream size on camera matching view (NEEDS
MORE TESTING)

![image](https://github.com/user-attachments/assets/9032783d-1edf-4c6e-ba7b-00e5f20280df)

https://private-user-images.githubusercontent.com/29715865/400783758-dc99c151-b8a7-4367-a173-74c2fc5b2666.mp4?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzYyNTc3NzEsIm5iZiI6MTczNjI1NzQ3MSwicGF0aCI6Ii8yOTcxNTg2NS80MDA3ODM3NTgtZGM5OWMxNTEtYjhhNy00MzY3LWExNzMtNzRjMmZjNWIyNjY2Lm1wND9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAxMDclMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMTA3VDEzNDQzMVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWMwOWM1MDc2ZTVlOWZhM2MxYjAwZjAyZTc2MTYyZTk1ZTVmOGFhZmVkMzlmODRlZTk1ODVlOTk2ZGQzZmM0Y2EmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.ovtRnObwbkEfljr9d5fqaory0nH91LWJSSkmrUUe_4Y
2025-01-07 08:45:39 -05:00
Cameron (3539)
fa2034d30b Unique path is not constant (#1681) 2025-01-06 00:00:55 -05:00
Craig Schardt
a84d681782 Fix exception thrown when isUp() is called on an unavailable network interface (#1679) 2025-01-04 00:45:57 -05:00
Cameron (3539)
ab844a77b8 Remove camera index in ui (#1677)
With the new camera matching, this is SUPER BAD! Convert to using camera
uuid.

---------

Co-authored-by: Matt <matthew.morley.ca@gmail.com>
2025-01-03 15:50:25 -08:00
Chris Gerth
6c7a174424 Adding timeSyncServer for Python (#1675) 2025-01-03 12:23:27 -06:00
Craig Schardt
474e4f07f8 Refined network management (#1672)
This PR implements several refinements to the way that NetworkManager
controls the network interface.

- The monitor detects and logs changes to the network address
- The monitor detects and logs changes to the connection and will
reinitialize the connection if needed
- Remove NetworkInterface.java class, which wasn't used anywhere
- Use java.net.NetworkInterface to get IP addresses for any interface
(device)
- Adds a metric for the current IP address (address on the currently
selected interface)
2025-01-03 08:29:18 -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
Chris Gerth
09a741f540 2025 Doc Cleanup (#1650) 2025-01-02 22:44:50 -05:00
Jade
a540d2dd3f [build] Update to stable WPILib (#1674) 2025-01-02 12:13:38 -05:00
Jade
3f8c406898 [github] Request review from docs team for docs PRs (#1668)
Signed-off-by: Jade Turner <spacey-sooty@proton.me>
2025-01-02 03:47:40 +08:00
Cameron (3539)
6065a3d70c Fix CSI camera exposure setting (#1665)
Adjusts the exposure setting of csi cameras to match that of USB
cameras. If you set a manual exposure it will drop out of auto exposure.
2025-01-01 14:21:54 -05:00
Cameron (3539)
34e9d5084c Add arducam model warning (#1669)
![image](https://github.com/user-attachments/assets/3cae0985-45f0-467e-867e-c000e87a6f55)
2025-01-01 14:18:44 -05:00
Cameron (3539)
a56101197a Add tooltip to calibration data table (#1670)
Help make it clearer for people to click on the table.

![image](https://github.com/user-attachments/assets/4d8fb2a1-a3c8-4391-8021-a0d9356aaeea)
2025-01-01 14:18:25 -05:00
Jade
2a82393c8e Fix googletest dependency (#1666)
This was rendered useless when googletest was added to the allwpilib
monorepo https://github.com/wpilibsuite/allwpilib/pull/6820

Signed-off-by: Jade Turner <spacey-sooty@proton.me>
2025-01-02 02:01:01 +08:00
oh-yes-0-fps
418eada0b5 Convert to user selected camera matching (#1556) 2025-01-01 03:04:20 -05:00
Jade
b2e70a7257 Remove photonvision docs repo (#1649) 2024-12-29 17:44:16 -05:00
Nolan Brown
b7a2636e97 [photon-lib] Fix sim tag ambiguity (#1653) 2024-12-29 17:43:55 -05:00
Matt
d0e5e169cc Fix Aruco leak + remove old tag families (#1661)
- Remove 16h5
- Fix leak in ArucoPoseEstimatorPipe
2024-12-27 20:14:30 -05:00
Matt
7e18424d11 Fix NPE changing camera quirks then calibrating (#1660)
Closes https://github.com/PhotonVision/photonvision/issues/1659
2024-12-27 19:44:40 -05:00
Jade
00d307439c Remove duplicated dependencies blocks (#1648) 2024-12-25 12:25:12 -05:00
Craig Schardt
5df189d306 Improve slider text input fields (#1654)
This PR changes the text input fields to allow a user to type in a value and press enter (or click away) before the UI registers the updated value. It makes text input behave in a more expected manner.  The spin buttons are no longer shown for the text box. Instead, there are up and down buttons on either side of the slider.

The only thing that I can't figure out is a way to make the up and down buttons continuously increment (decrement) the value if you click and hold. I'm not sure that this is required, but if someone wants to propose a solution, please add it to this PR.
2024-12-22 23:25:29 -06:00
Chris Gerth
bd1c5c0330 Fix bloaty gif (#1647)
change to mp4
2024-12-20 23:56:13 -06:00
Nolan Brown
77e75b9975 Cpp-examples gradle settings organization (#1646)
Not familiar with gradle but it keeps yelling at me for this
2024-12-20 23:55:02 -05:00
Craig Schardt
e506ac6b28 Fix release action glob exclusion (#1644)
In softprops/action-gh-release, when using an glob pattern to exclude files, all of the files to exclude must be specified on one line. Splitting them to multiple lines causes all files to match one of the two lines. 

To combine on one line, use `|` between the patterns.
2024-12-20 17:11:13 -06:00
Matt
88bc63cf82 Bump Athena image to 2025 (#1643) 2024-12-20 13:12:01 -08:00
Nolan Brown
a05542c06c [docs] Document VSCode tests and gradle tasks (#1641) 2024-12-20 09:27:29 -08: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
Jade
81076375b8 Bump to WPILib beta 3 and OpenCV 4.10 (#1638)
Signed-off-by: Jade Turner <spacey-sooty@proton.me>
Co-authored-by: Matt <matthew.morley.ca@gmail.com>
2024-12-19 20:54:48 -05:00
Matt
66f369f3a9 Remove selective builds (#1639)
Selective builds breaks my ability to require that checks pass before
merging. It's not worth the bite for very few docs-only PRs, given
github limitations on needing to skip INDIVIDUAL JOB STEPS on required
CI jobs.

Maybe we should move to gitlab 💀
2024-12-19 05:32:22 +00:00
Matt
7cba7b432d Add camera sim smoketest (#1637)
Paranoia test inspired by
https://github.com/PhotonVision/photonvision/issues/1635 .
2024-12-19 04:51:02 +00:00
Jade
dd98d96d7e Actually remove all RuntimeDetector usage (#1636)
Signed-off-by: Jade Turner <spacey-sooty@proton.me>
2024-12-19 04:47:29 +00:00
Jade
8ede892c14 Remove usage of RuntimeDetector (#1536)
Signed-off-by: Jade Turner <spacey-sooty@proton.me>
2024-12-17 17:11:05 +00:00
Christopher Mahoney
08c62ab8cd Java 17 (#1440)
![image](https://github.com/user-attachments/assets/d4e4226f-74b0-4ded-87b4-ac4bf2f1ac34)

JDK 11 References
https://github.com/search?q=org%3APhotonVision+jdk-11&type=code

JDK 17 References
https://github.com/search?q=org%3APhotonVision+jdk-17&type=code

TODO List (things we might need to update in other repos):
- []
ab5fa98d72/photonvision/src/modules/photonvision/start_chroot_script (L29)
- []
7f8d225445/stage2/01-sys-tweaks/00-packages (L34)
- []
ab5fa98d72/photonvision/src/modules/photonvision/install.sh (L11)
- []
a4e7ecb6e3/Makefile (L14)

Closes https://github.com/PhotonVision/photonvision/pull/1069

---------

Signed-off-by: Jade Turner <spacey-sooty@proton.me>
Co-authored-by: Jade <spacey-sooty@proton.me>
2024-12-17 17:01:19 +00:00
Matt
e8efef476b We have followers around the whole globe (#1622)
Co-authored-by: Vasista Vovveti <vasistavovveti@gmail.com>
2024-12-11 23:47:18 -05:00
Griffin Della Grotte
c6403a65d2 Add Rock 5C Release (#1617) 2024-12-11 06:47:16 +00: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
782929b006 Fix "Manage Device Networking" toggle being disabled incorrectly (#1620)
This fixes a bug introduced in #1592 that caused the Manage Device
Networking toggle to be disabled for systems where PhotonVision is
managing the network.

There is still a problem with the toggle defaulting to "off" and not
staying in the "on" position after settings are saved. I need help from
someone who understands the frontend to figure out why it keeps getting
set back to "off".

---------

Co-authored-by: Matt <matthew.morley.ca@gmail.com>
Co-authored-by: Cameron (3539) <theforgelover@gmail.com>
2024-12-07 04:30:41 +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
Matt
857a30d980 Pull image version from metadata file (#1599)
Closes #1554


![image](https://github.com/user-attachments/assets/fa51c0a3-a25e-4112-8ef2-990404c746d6)
2024-12-05 02:01:48 +00:00
Julius
a40e69cca0 Update docs to suggest JDK 17 (#1611)
#1609 
#1604
2024-12-04 03:27:10 +00:00
William Toth
e069a79a32 Check for exposure setting validity before accessing. (#1618)
If the exposure property for the generic USB camera settable was not
valid for one camera in the list, then the thread would crash/hang and
no cameras would show up in the list
2024-12-01 23:59:00 +00:00
Joseph Farkas
d9dfe15bfe Set loaded to false when JNI loading fails (#1614)
#1613
2024-12-01 16:19:31 +00:00
James Ward
1dbd2e5990 [python] Correct time units (#1605) 2024-11-28 16:12:52 +00:00
Matt
7e9da4133d (Mostly) allow reloading during calibration (#1593) 2024-11-26 03:25:50 +00:00
Gold856
163b5c9c81 Remove unused JNI artifacts (#1603)
Also removes unnecessary `_M_` prefix from artifacts.
2024-11-23 16:54:00 +00:00
Max Midgley
c6a3638a2f More obvious industrial SD card recommendation (#1601)
It wasn't hard to not notice or skip over the recommendation, or just
not take it seriously. So I added some banners to direct people to read
the quick start guide, and a banner to heavily suggest using an
industrial SD card, since they're just the best thing available right
now.
2024-11-23 07:39:42 +00:00
Jordan McMichael
44f78cb03e [Examples] Limit minimum battery voltage in sim to 0.1V (#1600)
Occasionally, the sim projects are capable of simulating current draw of
over 600A, which triggers a condition in
`BatterySim::calculateDefaultBatteryLoadedVoltage` that limits the
minimum measured battery voltage to 0V (to prevent it from going
negative).

When battery voltage measures 0, this causes NaN values to propagate
through the drivetrain model, making sim inoperable. Specifically, [this
is the
line](https://github.com/PhotonVision/photonvision/blob/master/photonlib-java-examples/aimandrange/src/main/java/frc/robot/subsystems/drivetrain/SwerveDriveSim.java#L452)
that causes the initial NaN values in simulation.

This PR is posed as a patch to ensure that simulation doesn't break.
2024-11-22 00:21:27 +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
Gold856
08b4bd1f03 Update to WPILib beta 2 (#1588)
Resolves #1547.
2024-11-21 04:42:30 +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
Matt
adb18fe711 Refactor program configuration broadcast hashmap spaghetti (#1592)
WAS: we used raw hash-maps to encode program state
S/B: we use Jackson to do this encoding for us for free. We have
Objects, and we should use them to represent structured data.

---------

Co-authored-by: Craig Schardt <crschardt@fastem.com>
2024-11-19 05:22:33 +00:00
Matt Morley
7d1e748b0e Enable merge groups 2024-11-18 21:15:40 -08: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
Dualfuel671
417e1a65b6 Simple proof reading (#1591)
Just correcting some keystroke errors.

---------

Co-authored-by: Craig Schardt <crschardt@fastem.com>
2024-11-18 17:54:24 -06:00
Cameron (3539)
5762167186 Test way too many calibration points (#1585)
![image](https://github.com/user-attachments/assets/508674fe-1d5e-41bf-a115-23bcf1638da0)

Limit seems to be at -least- 700,000 corners in my testing. That's
enough for anyone, surely.

---------

Co-authored-by: Matt <matthew.morley.ca@gmail.com>
2024-11-18 02:10:40 -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
Gold856
005363c5cd Add web resource folder back to gitignore (#1583) 2024-11-17 00:24:21 -05:00
Matt
478723ca2c Skip Vision System Sim Tests on Windows (#1581) 2024-11-16 20:09:41 -08:00
Matt
05dcfa2a13 Remove time source override (#1582) 2024-11-16 20:09:33 -08:00
Gold856
eff95c09f1 Clean up build (#1572)
Fixes #1564. Also copies vendordep JSONs to the examples as advised by
Thad. Removes unused shared/javacpp/setupBuild.gradle. Also removes
unnecessary `chmod +x gradlew` from CI workflows.
2024-11-16 21:30:34 -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
Craig Schardt
93242edc86 Fix rate limiting in sphinx link checker (#1579)
Fixes rate-limit errors in the sphinx linkchecker on GitHub links caused
by a missing token.

```
-rate limited-   https://github.com/PhotonVision/photonvision/commits/master/ | sleeping...
-rate limited-   https://github.com/PhotonVision/photonvision/commits/master/ | sleeping...
(docs/advanced-installation/prerelease-software: line    9) broken    https://github.com/PhotonVision/photonvision/commits/master/ - 429 Client Error: Too Many Requests for url: https://github.com/PhotonVision/photonvision/commits/master/
```
2024-11-16 20:24:27 -06:00
Craig Schardt
eb395414ab Explain how to install older version of PhotonVision on Romi (#1577)
Provide instructions for installing the PhotonVision version that is
compatible with WPILibPi 2023.4.2, which is the newest version available
for the Romi.

The older text is hidden in a comment so that it can be restored when
there is a newer version of WPILibPi that is compatible with newer
versions of PhotonVision.
2024-11-16 17:16:10 -06:00
Lucien Morey
04191efc51 sphinxify java docs for python code (#1575) 2024-11-15 18:01:33 -08:00
Cameron (3539)
9bbf49bc6b [docs] Create quick-start guide (#1528)
Add a quick-start guide to help answer more questions with fewer words.
---------

Co-authored-by: Matt M <matthew.morley.ca@gmail.com>
2024-11-14 22:56:02 -05: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
Cameron (3539)
4dc4ae88de Update libcamera version (#1566)
This uses the version of libcamera-gl-driver that was built using our
image. This assumes
the correct update path of the pi image version to libcamera to
photonvision.
2024-11-14 11:26:28 -05:00
Lucien Morey
c50c657193 Add Python test harness for openCVHelp class (#1557) 2024-11-14 11:10:08 -05:00
Matt
c04e13ef93 Fix roborio duplicate .so's on deploy (#1571) 2024-11-14 01:52:23 -05:00
Jade
5f3dc152c3 [photon-targeting] Remove dependency on wpilibc (#1544)
Closes https://github.com/PhotonVision/photonvision/pull/1543/files

Signed-off-by: Jade Turner <spacey-sooty@proton.me>
2024-11-14 00:25:32 -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
Gold856
c7ed37789e [photon-targeting] Fix JNI loading (#1563) 2024-11-13 10:37:51 -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
Craig Schardt
31ec9baa95 Include kernel logs when downloading logs (#1551)
Instead of writing the kernel logs to the photonvision logs, this will
download them in the same zip file as the photonvision logs. Only includes dmesg logs from the current boot, which is fine since we should capture most of them in our logs now.
2024-11-12 00:41:22 -05:00
Drew Williams
1fc93bd05d [photonli?b C++] Fix rotation3d constructor (#1553)
Fixes #1552 -- mixed up rpy and a rotation vector 

After changes:


![image](https://github.com/user-attachments/assets/0f58c2be-fc00-494c-af76-408c1ec438f9)
2024-11-11 11:06:00 -05:00
Matt
5bee683661 Add gh cli note (#1549) 2024-11-10 16:02:26 -08:00
Lucien Morey
b3d74e56a0 Add python simulation (#1532) 2024-11-10 14:16:02 -08:00
Stephen Just
b5d48a6503 Automatically detect and report hardware model for most SBCs (#1540)
ARM-based machines populate the device model into Device Tree. We can
use this information to automatically detect and report the hardware
model for most Single Board Computers (SBCs). Vendors who want to
override this can still do so via the value in the configuration
database.
2024-11-10 15:49:29 -06:00
Matt
2ea4da0f1e Publish vendor JSON as released artifact (#1525) 2024-11-10 09:56:47 -08:00
Gold856
152b4391b8 Remove unnecessary symbol exclusions (#1542) 2024-11-09 22:09:14 -08:00
Jade
4b2787a8b2 [ci] Update actions (#1546) 2024-11-09 22:08:34 -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
Matt
14f7155a23 [TSP] Move Bind() to Start (#1538)
Fixes UB with static init. Turns out starting threads in static init doesn't work on windows.
2024-11-09 17:35:38 -05: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
Jade
4cf1c7eee4 [ci] Fix unamed action steps (#1537) 2024-11-08 10:39:34 -05:00
Gold856
04ec99f17a Add license to jars (#1530)
Fixes GPL violation, the license has been missing since 2024.
This also puts licenses in as many JARs and native library archives as possible (for good measure.)
2024-11-08 09:10:14 +08:00
Lucien Morey
150561abf2 Add missing var to dataclass (#1534) 2024-11-07 18:31:21 -05:00
Craig Schardt
58a0597c86 Make install.sh run the version from photon-image-modifier. (#1531)
We've moved the install script to photon-image-modifier. This updates
the install script in photonvision to just download and run the
install.sh from photon-image-modifier.
2024-11-06 23:00:11 -06:00
Matt
a842581785 Fix windows NPEs around exposure+klogs (#1529) 2024-11-06 21:51:31 -05:00
Matt
8dcf0b31a2 Create FileLogger JNI (#1517) 2024-11-06 20:16:36 -05:00
Kouyang07
a99a8e750b Fixed Python code block being in C++ block (#1527) 2024-11-06 12:41:13 -05:00
William Toth
a0b22cd8a3 Update docs to specify that WPILib JDK is required on Windows (#1522) 2024-11-04 23:27:49 -05:00
Cameron (3539)
5d55d215ec Another config matching bug (#1518)
This is quite an odd issue/fix. 

So this is what happened... Photonvision booted with the camera
connected and the camera was working...
After a short time the camera stopped working (for some reason maybe
static, maybe temp, maybe wiring, idk).
During this time pv showed

Jul 04 06:25:18 BackLeft java[643]: [2024-07-04 06:25:18] [CSCore -
PvCSCoreLogger] [ERROR] CS: ERROR 40: ioctl VIDIOC_QBUF failed at
UsbCameraImpl.cpp:723: Invalid argument (UsbUtil.cpp:156)
Jul 04 06:25:18 BackLeft java[643]: [2024-07-04 06:25:18] [CSCore -
PvCSCoreLogger] [WARN] CS: WARNING 30: BackLeft: could not queue buffer
0 (UsbCameraImpl.cpp:724)

I went over and played with the wire. The camera fully disconnected but
it ended up "reconnecting"
When the camera was "reconnected" photonvision detected a "new camera"
except this time with no otherpaths (aka no usb path, or by id path).
That resulted in pv creating a new camera configuration for a camera
with no otherpaths
Cscore then started to report errors that look like it attempted to
connect to the same camera twice

This fixes it by filtering out USB cameras that have no otherpath on
linux.
2024-11-04 21:50:18 -05:00
Craig Schardt
625dacb020 Add QuadThresholdParameters to AprilTag config (#1519)
This works around a change made to the default QuadThresholdParameters in the WPILib AprilTagDetector for 2025.
https://github.com/wpilibsuite/allwpilib/pull/6847
2024-11-03 21:53:53 -06: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
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
Jade
5e1a93950e Fix photon-targetting being a seperate project (#1504) 2024-10-31 22:23:52 -07:00
Jade
380546cee0 Remove nonsensical settings.gradles (#1506) 2024-10-31 22:23:12 -07:00
Cameron (3539)
d7a7610917 Fix videomode is null (#1513)
There is a weird edge case at least with arducam/broken arducams/used
arducams where cscore will see it when pv starts but not be able to
connect to it. If we always read out the "current" video mode instead of
null when it is disconnected things will work. If the camera is
disconnected while we try to change the video mode when we get the
current video mode it will tell us what we wanted to set it to. Then
when the camera reconnects it will be in that video mode.
2024-10-31 23:13:36 -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
Matt
3d18ded3f6 Link to wpilib javadocs in ours (#1509)
![image](https://github.com/user-attachments/assets/d197b637-bf52-4a03-bf55-32a45fff8b06)
2024-10-29 17:11:53 -07:00
Jade
daa5842fb5 Remove explicit NativeUtils specification (#1495) 2024-10-28 09:18:12 -07:00
Emmy Chow
6f52267c26 Install script improvements (#1456) 2024-10-27 15:07:28 -07:00
Craig Schardt
acbae88d34 Reduce log spam if network monitor fails (#1494)
This prevents spamming of the logs by the network interface device
monitor by:

- checking to make sure the device file exists before starting the
monitoring task
- only logging once if it throws an exception, but keep trying in case
the exception is transient
2024-10-27 16:33:14 -05:00
42
986c7020c3 docs: update link to PhotonVision running examples (#1493) 2024-10-26 15:15:34 -07:00
42
eb7a56abaf docs: fix incorrect link to PhotonVision compiling instructions (#1492) 2024-10-26 14:37:02 -07:00
Matt
d04c4b8231 Re-set config save default state to true (#1489)
Previously, no config updates were ever saved out. At all. Oops.
2024-10-25 23:41:48 -04:00
Matt
f8e25ced89 Add aliases, allow v2024.3.1 setting import (#1487)
Was easy enough to add annotations. Ongoing work to remove these hacks post 2025 is tracked in https://github.com/PhotonVision/photonvision/pull/1487
2024-10-25 23:04:08 -04:00
Matt
f906295c39 Create "Hide calibration corners" switch, default to mrcal on if possible (#1462) 2024-10-25 10:05:03 -07:00
Matt
aee432127a Add AWB slider/toggle (#1477)
Also reworks OV9782 defaults. Probably doesn't work on windows. We should hide these sliders probably. 

Co-authored-by: Cameron (3539) <theforgelover@gmail.com>
2024-10-25 00:27:40 -07:00
Matt
385059c233 Big scary buttons (#1471) 2024-10-24 20:48:02 -07:00
Cameron (3539)
9b61ed156c Fix VisionSourceManagerTest typo (#1486) 2024-10-22 22:23:29 -04:00
Cameron (3539)
8eaa6904dd Equal only by usb paths (#1481)
This bug would only appear when there are cameras with the same naming.
Old config matching would also match using the by-id this was
problematic. When one camera is disconnected it would assign the by-id
path to the other camera with the
same name. When the camera is replugged in it would not be reassigned
the by-id path and would fail the camerainfo equals check.
2024-10-21 10:37:00 -04:00
Matt
7da2ec1948 Fix PhotonCamera typestring checks (#1480)
Previously NT would quietly drop readQueue changes.
2024-10-20 22:21:24 -07:00
Cameron (3539)
7224561b76 Add slider debounce (#1479)
Sliders for exposure and brightness would spam messages on the backend.
This used to cause crashes and can cause it to get quite laggy /
delayed. This will add a 20ms debounce which won't send the value to the
backend until the value hasn't changed for 20ms.

---------

Co-authored-by: Matt <matthew.morley.ca@gmail.com>
2024-10-21 00:48:01 -04:00
Craig Schardt
4c84c87cf4 Bump Raspberry Pi images to v2025.0.0-beta-6 (#1483)
Fixes #1482
2024-10-20 22:59:25 -05:00
Craig Schardt
8ff0d93c1f Improve network management (#1478)
This PR changes the way that photonvision interacts with nmcli to control networking on the coprocessor. Instead of modifying an existing connection, Photonvision adds new connections for DHCP and Static IP configurations. It then activiates the proper one at startup and any time that the network configuration is changed.


It also now uses the interface name and not the connection name and checks that the interface is available before making any changes. If the saved interface is not found, it updates the stored interface name and applies the network settings to the current interface. This should minimize the failure to control the network if the network interface wasn't available when PhotonVision first booted.

One other benefit of not altering the default configuration is that, if PhotonVision fails to run for any reason, the device can be accessed using the original networking configuration.

The code has been tested on an OrangePi5 and and a Raspberry Pi 4.

Addresses: #1261
2024-10-20 22:23:50 -05:00
Cameron (3539)
b38de6b506 Calibration Rotation! (#1464)
Rotate camera calibration coefficients based on camera rotation. Probably. Seems to work. Maybe.

---------

Co-authored-by: Matt <matthew.morley.ca@gmail.com>
2024-10-19 01:23:23 -04:00
Cameron (3539)
388b3fa2ef Default 36h11 (#1470) 2024-10-14 22:33:03 -04:00
Cameron (3539)
028b6ea62f Fix reflective null points (#1469) 2024-10-14 20:31:19 -04:00
Cameron (3539)
c961f1e22e Fix apriltag detection draw bug (#1467)
We accidentally copied more settings then we wanted. This adds an
annotation that we can mark variables with that will prevent them from
being copied when we switch pipeline types.
2024-10-14 20:30:27 -04:00
Cameron (3539)
189da52a77 Fix aruco draw (#1468)
Someone hard-coded the 16h5 model. Additionally, the April tag pipeline
redistorts the points before drawing them, so let's do that as well.
2024-10-14 20:15:08 -04:00
Cameron (3539)
48fc88c5e9 ChArUco: adjust detector params, hide unused (#1463) 2024-10-13 16:42:53 -04:00
Matt
30ee91379e Copy common fields when changing pipeline type (#1461)
Preserve common AdvancedPipelineSettings fields when switching pipeline types. This includes camera resolution, exposure settings, and stuff
2024-10-13 14:52:13 -04:00
Matt
353a8eaaec Add FMS info to snapshot names (#1460)
Supersedes #464

Co-authored-by: Ofir Siboni <050ofir@gmail.com>
2024-10-13 12:47:57 -04:00
Cameron (3539)
09b1bb9e22 Fix client log view (#1459)
Someone forgot to add the timestamp.
2024-10-13 02:13:21 -04:00
Matt
26f3a9977b Create AprilTag pipeline by default (#1458) 2024-10-13 01:38:25 -04:00
Cameron (3539)
0766d0e802 Fix large calibration datasets crashes (#1453)
The target list in networktables is limited to 127 items. When you
capture more than 127 calibration images it breaks this limit and errors
out and dies. Do not publish calibration targets to nt. And also move cal images into their own folder
2024-10-13 01:29:17 -04:00
Cameron (3539)
d9b6199cf0 Dont send SolvePNPEnabled in drivermode. (#1454)
There are no settings for solvePNPEnabled while in driver mode but the
UI tries to set it. Let us not do that.
Fixes #1377

Co-authored-by: Chris Gerth <gerth2@users.noreply.github.com>
2024-10-10 23:27:16 -05:00
Chris Gerth
91da7af171 latest is correct is not correct (#1455)
Ubuntu 24 borked for most of our CI. something to do with glibc


https://discord.com/channels/725836368059826228/725846784131203222/1294138369177157832

it always should have been at a fixed version. Now it is.
2024-10-10 23:13:58 -05:00
Cameron (3539)
471c90e8fa UI Message Passing (#1448)
Bring the UI setting changes in thread with the camera.
2024-10-08 23:06:43 -04:00
Cameron (3539)
142e22ff24 Object detection OOM crash (#1451)
Don't return before we release the object.
2024-10-08 22:01:51 -04:00
Cameron (3539)
c4b273e737 Reduce pipeline use-after-free errors (#1447) 2024-10-07 11:35:18 -04:00
Stephen Just
cd9dd07282 Camera view updated to better respond to state (#1437) 2024-10-05 22:26:14 -07:00
George Horsey
3225c079d3 Update calibration.md OpenCV Docs Link (#1445)
Link had ">" at the end of the URL causing a 404 error.
2024-09-30 23:40:41 -04:00
Craig Schardt
95d55dc977 Add-OrangePi5max-image (#1444)
Completes #1420
2024-09-30 22:21:44 -05:00
Jade
95236e5045 [docs] Fix usage of getTagPose (#1442) 2024-09-29 11:43:02 -04:00
Jade
30e930f051 [docs] Fix invalid max error bits recommendation (#1443) 2024-09-29 11:42:19 -04:00
Jade
68adfe6034 [docs] Remove gerth2 links (#1441)
Resolves https://github.com/PhotonVision/photonvision/issues/1418
2024-09-29 09:55:36 -04:00
Christopher Mahoney
abe95dfaa0 Update poseest.md (#1439)
This space is the root cause of failures in #1437.

RE: #1430
2024-09-29 06:55:46 -05:00
Chris Gerth
354f11a6d6 Fix broken links (#1430) 2024-09-24 18:19:49 -05:00
Banks T
b7cab0431d See3Cam_24CUG Quirks (#1302)
Co-authored-by: Matt <matthew.morley.ca@gmail.com>
Co-authored-by: Chris Gerth <chrisgerth010592@gmail.com>
2024-09-24 18:18:59 -05:00
Chris Gerth
a8daff3ed4 Revised 9782 defaults (#1431)
revised order to prevent some randomness around init
2024-09-24 00:02:16 -05:00
Matt
a0c85fc95f Create photon-targeting-JNI framework (#1428)
Initial framework for adding JNI libraries. Auto generated JNI headers and sticks native libraries into the JAR (and adds to class path for testing)
2024-09-23 22:44:09 -04:00
Matt
f33218c49c Add message UUID and type names to hash and message defintion (#1409) 2024-09-22 22:27:13 -04:00
Stephen Just
360298cc24 Fix error being printed to console on Chrome when navigating UI (#1429)
Chrome prints an error to the console when you have `<img src="null" />`

The path `//:0` can be used for an empty image and Chrome will not raise
an error.
2024-09-21 16:11:58 -04:00
Christopher Mahoney
27cb69c094 Support selecting Object Detection models (#1359)
This PR is for part 1 of #1354. It focuses on adding a model selection
interface for models that exist in `photonvision_config/models/`. Upon
completion we can ship more than 1 model and users could upload their
own through `ssh` without deleting the shipped model. This PR also adds
the abstractions need to support more DNN backends (say OpenCV, or RPI
AI Kit)

Up next is adding a CRUD interface for managing models through the UI.
2024-09-21 16:08:00 -04:00
Craig Schardt
24fb6af5f4 Fix setting gain to max on cameras that don't have a gain quirk (#1424) 2024-09-15 23:40:27 -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
Chris Gerth
9e6a066561 Examples Clean-Up (#1408) 2024-09-15 00:10:02 -04:00
Christopher Mahoney
596c87519c fix: reflection bug in onDataChangeEvent (#1416) 2024-09-12 14:08:57 -04:00
Drew Williams
06f0f7d66f Fixes windows not allowing auto exposure prop for the ov2311 (#1407) 2024-09-03 22:17:10 -04:00
Devon Doyle
c38b50911d [photon-client] Log Viewer Improvements (#1385)
Fixes the following issues with the client log viewer:
- Inconsistent and excessive spacing between log entries
- Lack of responsiveness to window size or scaling

Adds the following features to the log viewer:
- Auto-scroll if scrolled to the bottom
- Ability to clear logs on button click
- Search function to filter logs
- Displays the time the frontend captured a log and displays that timestamp in hh::mm::ss in the log viewer
- Allows logs to be filtered to be after a certain time
- General styling refinements to increase usability

---------

Co-authored-by: Sriman Achanta <68172138+srimanachanta@users.noreply.github.com>
2024-08-31 18:22:07 -04:00
Matt
169595e56e Auto-generate packet dataclasses with Jinja (#1374) 2024-08-31 13:44:19 -04:00
Mohammad Durrani
c19d54c633 Removed CalibDB (#1396) 2024-08-31 12:31:49 -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
Jade
50ea32c82d Fix getTarget docs (#1404) 2024-08-29 01:20:03 -04:00
Stephen Just
8c09cd2cb3 Populate CameraSettingsStore with placeholder value if no cameras are present (#1401) 2024-08-25 08:10:45 -04:00
Stephen Just
c33fd8362d [photon-client] Bump node to V18 (#1402)
* Bumps minimum NodeJS requirement to v18 (already used as part of
official builds)
* Prerequisite for latest VueJS
2024-08-24 22:58:33 -04:00
Cameron (3539)
2e4be684be Update RPI Image 7/4/24 (#1373)
Bump libcamera version to support new pi image.
2024-08-22 21:10:03 -04:00
Cameron (3539)
ed6cf0f5dc Document Charuco (#1398)
You know... I made those charuco changes now I need to document how it
works... basic stuff.

---------

Co-authored-by: Matt <matthew.morley.ca@gmail.com>
2024-08-19 20:35:02 -04:00
Mohammad Durrani
4643f86438 Switch from RST to MyST Markdown (#1395) 2024-08-18 14:05:23 -04:00
vic123
0493ef9133 Document how to install PhotonLib of specific version (#1392) 2024-08-18 00:37:45 -04:00
Craig Schardt
c5c2a7a6f9 Add OrangePi5b image to generated images (#1394) 2024-08-17 14:20:19 -04:00
Chris Gerth
f1d1d325e0 Move to using Absolute Exposure Range (#1352)
Uses logic in
https://github.com/PhotonVision/photon-libcamera-gl-driver/pull/16 to
push the ov9281 down to its true minimum exposure.

Updates UI to list the exposure settings in ~~microseconds.~~ Native
units - not everyone works in microseconds.

Does its darndest to actually try to set the exposure in
~~microseconds.~~ Native Units. To do this...

Lifecam is funky when doing this - [cscore limits the exposure settings
to certain quantized
values](https://github.com/wpilibsuite/allwpilib/blob/main/cscore/src/main/native/linux/UsbCameraImpl.cpp#L129).
Add a new camera quirk to allow that.

~~Updated camera quirks to re-evaluate every camera load (rather than
recalling from settings - this shouldn't be necessary)~~ This should be
rolled back, needed for arducam type selection.

Updated camera quirk matching logic to make PID/VID optional, and
basename optional (and only match trailing characters). This enables
mirroring CSCore's logic for identifying lifecams by name.

Updated the USBCamera to primarily use cscore's exposed property names.

Since camera manufacturers use a potpourri of names for the same
thing....

For nice-to-have settings: new soft-set logic to try all possible names,
but gracefully pass if the property isn't there.
For required settings: Search a list for the first setting that's
supported, fail if none are supported.

More logging of camera properties to help debug.

Note: most of this work is because cscore doesn't directly expose a
massaged exposure-setting-absolute API (and, given what we've seen,
probably _shouldn't_, this struggle is not for the faint of heart).

---------

Co-authored-by: Matt <matthew.morley.ca@gmail.com>
2024-08-17 10:02:59 -05:00
Craig Schardt
dbe566cb55 Update install.sh for OPi5 Ubuntu 24.04 (#1390)
This updates the install script to work correctly on Ubuntu 24.04
versions of the Orange Pi 5 images.

Changes include:
- installing libatomic1
- disabling networkd-wait-online if using Network Manager
- using systemctl instead of service to detect if photonvision is
running
- detecting if this is a RK3588 cpu and enabling all cores
2024-08-13 10:54:26 -04:00
Matt
c3302045d9 Add rsync & sphinx-autobuild docs (#1391) 2024-08-12 11:01:04 -04:00
Jade
ac1fc2a46b Add API docs to sidebar (#1383) 2024-08-04 21:58:54 -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
Craig Schardt
37e9d40762 Use new OrangePi5 images and add OrangePi5 Pro (#1388) 2024-08-03 21:57:35 -04:00
Matt
974a926e75 Run wpiformat (#1379) 2024-08-02 11:57:34 -04:00
Cameron (3539)
d1e7fd4db9 Revert "Use pnpm instead of npm" (#1382)
Reverts PhotonVision/photonvision#1375

Causes white screen UI Bug, "the way we currently strap everything with
vue2 and vuetify has a lot of footguns in it, and using a newer package
manager where each subdependency gets its own version of node is causing
incorrect dependency resolution which also means we can't fix this
without either updating node or patching those dependencies id say just
revert the PR for now until I or someone else can do the vue3 update"
2024-07-31 12:45:10 -04:00
MADMAN-Modding
10f74bb623 Fixed spelling error (#1376) 2024-07-24 16:38:49 -04:00
Sriman Achanta
3c58b05af7 Use pnpm instead of npm (#1375)
Pnpm is like npm except instead of keeping multiple copies of
dependencies, it shares a single copy for multiple dependencies
significantly reducing build time and the space needed to hold all the
dependencies. Read [here](https://pnpm.io/motivation) for more info.

This changes our CI to use pnpm and allows developers to choose to use
pnpm instead of npm. Also, pnpm has a built-in node version manager so
devs no longer need to use nvm to work on photonvision. All npm
functionality (including photon-server gradle tasks) still functions
using npm so this isn't breaking. We should make a docs change to
suggest to use pnpm.
2024-07-24 00:45:19 -04:00
Matt
9ad9b8288a Update docs on docs about docs (#1360) 2024-07-04 17:15:51 -04:00
Cameron (3539)
fab75918da Fix OV9782 typos (#1358)
There were a couple of typos in the last OV9782 fix, this addresses
those. Additionally, remove Matt's comment that he forgot.
2024-07-01 22:14:22 -04:00
Gautam
173b6d9ca8 Adds support for OV9782's quirks (#1284)
The OV9782 camera has a specific exposure range, so a camera quirk for
it needs to exist. The default white balance is also pretty bad, so it
must be adjusted.

Closes #1204

---------

Co-authored-by: Matt <matthew.morley.ca@gmail.com>
Co-authored-by: Cameron (3539) <theforgelover@gmail.com>
2024-07-01 18:54:20 -04:00
Matt
e7e59ed2d4 Rename .readthedocs to match RTD 2024-06-30 20:47:13 -07:00
Matt
dcc7ddc19b Move docs in-source (#1357) 2024-06-30 16:10:12 -04:00
Matt
0cdd9a74d0 Bump wpilib to 2025.0.0-alpha-1 and break non-FRC JDKs (#1356)
Windows users will have to add
`"-Dorg.gradle.java.home=C:\Users\Public\wpilib\2024\jdk"` to gradle
invocations, ie `./gradlew run
"-Dorg.gradle.java.home=C:\Users\Public\wpilib\2024\jdk"`, due to MSVC
ABI breakages and other stupidity
2024-06-30 02:08:58 -04:00
Cameron (3539)
8c45fef62a Support more charuco boards (#1348)
Add support for the old opencv charuco board like calibio. 

Add support for other tag families while calibrating.

Fix calibration issue index out of range with charuco missing points.
2024-06-20 21:29:00 -04:00
Cameron (3539)
1d9810505a fix CSI camera null quirks error (#1349)
temp fix for this issue with csi cameras
2024-06-19 19:09:52 -04:00
Matt
8f0cc0ab8b Revert "Warn when getBestCameraToTarget returns 0, 0, 0 (#1334)" (#1351)
This reverts commit 6ff7b3e143. See #1351 for context
2024-06-17 22:38:16 -04:00
Cameron (3539)
0105df9ad4 Bump libcamera driver version (#1346)
* Update build.gradle
2024-06-12 18:06:25 -04:00
Matt
292c7a10d4 Only publish to maven on main fork (#1345) 2024-06-11 16:31:05 -04:00
Matt
230e73749f Only download necessary files in release step (#1344) 2024-06-11 09:36:34 -05:00
Matt
655909cc84 Create combine job and offline vendordep ZIP (#1343)
* Create combine job

* Update build.yml

* Bump max workers in photonlib

* Oops

* actually kill entirely

* Maybe fix test

* Don't run tests

* Update OpenCVTest.java

* Update build.yml

* Use upload-artifact@v4

* Update build.yml

* Update build.yml
2024-06-10 20:37:01 -05:00
Matt
5289948b83 Add photon.pb.h/PhotonVersion to cpp headers zip & create combined sources zip (#1335)
Combined sources zip is useful for robotpy to build both targeting & lib in the same build
2024-06-09 17:18:57 -04:00
Cameron (3539)
7b19a951ca Camera Lost Stream (#1341)
* Fix no stream on camera unplug.

* Spotless remove datarate

* Make Static Frames Class

* lint and format
2024-06-06 20:46:46 -05:00
Cameron (3539)
db531f1b6a Fix libcamera not found bug (#1326)
* Update build.yml
2024-06-02 16:16:43 -04:00
Jade
6ff7b3e143 Warn when getBestCameraToTarget returns 0, 0, 0 (#1334)
Resolves https://github.com/PhotonVision/photonvision/issues/915
2024-06-01 13:28:00 -04:00
Jade
e34b114669 Change default AprilTag family to 36h11 (#1333)
Change default AprilTag family to 36h11

Resolves https://github.com/PhotonVision/photonvision/issues/1226
2024-05-30 20:30:40 -04:00
Matt
f792b46eb7 Fix mac released jar naming (#1332) 2024-05-29 20:13:24 -04:00
Matt
19b4802094 Allow opencv8 distortion model in PhotonCamera (#1317)
We previously assumed only OpenCV5 but mrcal uses opencv8
2024-05-29 17:28:35 -04:00
Matt
fcca858a37 Update maven URL to reposilite (#1330)
Also bumps to new builds of artifacts (NFC)
2024-05-29 12:29:08 -05:00
Matt
9eae7a4431 Disable transitive deps for rknn-jni (#1329) 2024-05-26 18:43:06 -05:00
Matt
0eeedf49fc Publish generated proto sources (#1328) 2024-05-26 14:02:37 -05:00
Matt
98633e9150 Bump wpilib to latest dev (#1327) 2024-05-26 14:02:07 -05:00
Matt
ed08e2a78f Move PhotonVersion to C++ file (#949)
This was supposed to speed up incremental compilation, but not sure it actually does. It's better form tm tho and fixes a robotpy-wrapper weirdness
2024-05-24 23:22:31 -04:00
amquake
12cb082f1b Update README.md (#1321) 2024-05-19 20:37:13 -04:00
Drew Williams
74a051d721 [PhotonLib C++] Fix SetVersionCheckEnabled to actually disable version checking (#1323)
* change verifyversion to use member variable

* Revert "change verifyversion to use member variable"

This reverts commit 4439839c8f.

* Removed inline specifier for versioncheck variable

---------

Co-authored-by: Drew Williams <DrewW@iARx.com>
2024-05-19 20:36:44 -04:00
Craftzman7
9e58f5ed02 Disable Arm32 Builds (#1325)
Disables Arm32 builds and removes mention of the build option in the README.
2024-05-19 20:35:40 -04:00
Matt
713fad6f6b Allow file uploads of any size and better report active cameras in PhotonCamera error print (#1298)
Previously reported itself which was confusing. New print:

```
Error at org.photonvision.PhotonCamera.verifyVersion(PhotonCamera.java:378): Found the following PhotonVision cameras active on NetworkTables:
 ==> HD_Pro_Webcam_C920
 ==> Arducam_OV9281_USB_Camera
```
2024-05-10 14:58:18 -04: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
Programmers3539
70c2cdebe0 Charuco Support (#1312)
Add charuco calibration to photonvision. Currently does not support generating custom charuco boards. This does not support https://calib.io/pages/camera-calibration-pattern-generator. Currently only supports the 4X4_50 family. Also removes all dotboard calibration. Fixes using the lowest possible fps while doing calibration (now uses the highest fps available for each resolution).
2024-05-10 13:12:13 -04:00
Matt
560f379109 Bump libcamera to fix picam v1, remove duplicate opencv (#1263) 2024-05-10 11:09:01 -05:00
Matt
00c2a25730 Undistort corner pitch/yaw using opencv (#1250)
* Undistort pitch/yaw

* Actually implement lol

* Update TargetCalculations.java

* fix yawpitch test units

* format

---------

Co-authored-by: amquake <noleetarrr@gmail.com>
2024-05-02 21:17:28 -04:00
Drew Williams
6535710fc4 Change sim to use 36h11 tags when doing multitag (#1314) 2024-04-29 16:19:03 -04:00
Matt
c9a696225d Kill deprecated things (#1311) 2024-04-27 11:32:36 -05:00
Devon Doyle
010688006a [Client] Fix issue with clearing multitag buffer (#1299)
* fix improper state reference

* add parentheses for clarity

* fix buffer array reactivity + loop optimization
2024-03-22 20:19:51 -04:00
Matt
2d8b1ec66d Properly handle empty frames from cscore (#1296) 2024-03-21 23:23:56 -04:00
Devon Doyle
15da06b24c Sticky calibration camera display card (#1294)
* Stick camera card in calibration view to top

* Spacing
2024-03-21 15:39:07 -04:00
Devon Doyle
97d2050a99 Fix mjpg stream accumulation (#1293)
Fixes bug where switching tabs/etc causes buildup of connected mjpg streams in network, eventually slowing down streams and causing stream failure until refresh. Accomplishes this by directly setting the source of stream elements to null before unmount, allowing chrome/edge to close the connection.

Fixes #1106
2024-03-20 22:53:15 -04:00
Matt
c89acea5a6 Run updated wpiformat (#1291) 2024-03-18 20:54:06 -04:00
Matt
fa5d58147a Recreate user pipeline on type change (#1290)
* Recreate user pipeline on type change

* Fix typo

---------

Co-authored-by: shueja <32416547+shueja@users.noreply.github.com>
2024-03-18 20:50:32 -04:00
Matt
e74afb9688 Release letterboxed frame (#1289) 2024-03-18 17:20:14 -07:00
Matt
5dc70e4d3f Run resize in CPU and more aggressively release rknn resources (#1287)
With the latest dev opi image, i saw this stack trace when object detection stopped working (threads hanging forever on detect(). The stack pointed me to somewhere inside the RGA. Based on this i moved resize into CPU (as our [native code already is lazy](6934abb26c/src/main/native/cpp/yolo_common.cpp (L227))), and was not able to see more crashes

[message.txt](https://github.com/PhotonVision/photonvision/files/14630158/message.txt)

Includes also a quick hack to add a shutdown hook that releases pipelines at exit.
2024-03-18 16:36:14 -04:00
Matt
5597f5acd9 Set default pipeline idx in PipelineManager constructor (#1286)
Addresses #1285
2024-03-18 13:21:41 -04:00
Matt
fae3116951 Bump to 2024.3.2 (#1283) 2024-03-17 23:00:22 -05:00
Gautam
def37b92ba Add proper exposure range for OV2311 (#1282) 2024-03-16 20:28:52 -04:00
Phill Tran
5b878fe3a3 Disable camera orientation option when camera is calibrated (#1277)
* Disable camera orientation option when camera is calibrated.

* Flip logic on if camera is calibrated when disabling camera orientation rotation

* Add comment on why orientation is disabled when camera is calibrated

* Add v banner warning regarding rotating calibrated camera bug

* Run lint

---------

Co-authored-by: Matt <matthew.morley.ca@gmail.com>
2024-03-15 10:39:04 -04:00
Matt
d9c2a382f1 Update build.yml (#1276) 2024-03-14 00:32:08 -05:00
Matt
e125632960 Free native resources in apriltag pipelines (#1272)
Addresses memory leak when switching between apriltag/aruco pipelines
2024-03-14 01:22:32 -04:00
Matt
d8f82bf9ee Opencv cal: CALIB_USE_LU and use camera focal length guess (#1268) 2024-03-09 08:31:54 -05:00
Matt
587ac478f4 Bump mrcal to include solver fixes (#1265) 2024-03-06 10:51:49 -05:00
Matt
bad676f67c Pipe cscore logs through photonvision (#1260)
This means we can see even more logs about mjpeg server status as well
2024-03-04 23:27:39 -05:00
Matt
71128d1569 Create smoketest mode (#1264)
Create test mode that exists after confirming libraries load OK
2024-03-04 23:24:23 -05:00
Matt
7cec141341 Fix CSI camera matching (#1258)
* previously CSI cameras would always have a new config made and would never match
2024-02-27 09:07:42 -05:00
Matt
ec66645667 Update build.yml (#1249) 2024-02-20 16:28:50 -05:00
Vasista Vovveti
39aaa34520 update wpilib to 2024.3.1 (#1246) 2024-02-20 15:08:52 -05:00
Vasista Vovveti
4a3200d0c0 Run apt update and install sqlite3 (#1247) 2024-02-19 21:37:55 -05:00
Matt
01dc7ea5ce Properly check camera info equality and handle zero cameras (#1245)
- Fix CameraInfo equality check (which prevents the same camera on a new usb port from being enumerated by us)
- Fix warning prints
- Make matchCamerasOnlyByPath apply to Windows
- Add unit tests
2024-02-19 12:34:57 -05:00
Matt
2a9502be3d Add matching by base-name only (fused off by only by path) (#1238) 2024-02-18 21:00:14 -05:00
amquake
39216db143 [photonlib] Invert simulated target yaw (#1243) 2024-02-18 20:59:54 -05:00
Matt
428f926ac2 Actually properly match cameras by name fr this time (#1237)
Our current code matches cameras in this order (which I think is objectively wrong and stupid)

- by-id (/dev/v4l/by-id/product-string)
- by path (/dev/videoN)
- product string/name, but ascii only
- asks cscore to reconnect to cameras using `path`, which on linux is actually /dev/videoN. This isn't guaranteed to stick to a camera if you replug them weirdly at runtime.

This is silly and does not consider the actual physical usb port. I propose instead, in this order:

- By physical usb port path and base name
- by physical usb port path and USB VID/PID
- By base name only (with a toggle switch to disable this, and create a new VisionModule instead)
- Give cscore /dev/video/by-path on Linux systems, pinning Photon USBCameras to a particular usb port once created.

This changes lots of things so stay paranoid!
2024-02-16 16:05:47 -05:00
Matt
4efeb3d412 Load libwinpthread-1.dll before libgcc_s_seh-1 (#1228) 2024-02-16 16:05:16 -05:00
Matt
6a2d83e19b Upload docs to VPS via SFTP (#1235)
Still in testing, might break our docs for now
2024-02-12 19:57:23 -05:00
Matt
1c0d92641f Check empty mean errors in calibration card (#1229)
Fixes calibration card disappearing if calibdb calibration was used
2024-02-12 15:55:31 -05:00
DeltaDizzy
9653c46bdb fix cpp and java photoncamera names (#1230) 2024-02-11 04:27:25 -05:00
Chris Gerth
3738e7821b fix latency calculation (#1227) 2024-02-09 18:45:38 -06: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
Chris Gerth
7666f152bb Fix chessboard gen for unique square sizes (#1217) 2024-02-05 09:48:39 -05:00
Craig Schardt
45a39f6609 Remove duplicate video modes (#1221)
(Fixes #1219)
2024-02-04 22:42:01 -05:00
967 changed files with 81038 additions and 15358 deletions

4
.github/CODEOWNERS vendored
View File

@@ -1,2 +1,6 @@
# These owners will be the default owners for everything in the repo.
* @PhotonVision/program-devs
docs/* @PhotonVision/doc-maintainers
photonlib-java-examples/* @PhotonVision/doc-maintainers
photonlib-cpp-examples/* @PhotonVision/doc-maintainers
photonlib-python-examples/* @PhotonVision/doc-maintainers

View File

@@ -1,12 +1,18 @@
name: Build
on:
# Run on pushes to main and pushed tags, and on pull requests against main, but ignore the docs folder
push:
branches: [ master ]
branches: [ main ]
tags:
- 'v*'
pull_request:
branches: [ master ]
branches: [ main ]
merge_group:
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
cancel-in-progress: true
jobs:
build-client:
@@ -30,8 +36,20 @@ jobs:
name: built-client
path: photon-client/dist/
build-examples:
name: "Build Examples"
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
include:
- os: windows-2022
architecture: x64
- os: macos-14
architecture: aarch64
- os: ubuntu-22.04
name: "Photonlib - Build Examples - ${{ matrix.os }}"
runs-on: ${{ matrix.os }}
steps:
- name: Checkout code
uses: actions/checkout@v4
@@ -44,24 +62,17 @@ jobs:
with:
java-version: 17
distribution: temurin
- name: Install RoboRIO Toolchain
run: ./gradlew installRoboRioToolchain
# Need to publish to maven local first, so that C++ sim can pick it up
# Still haven't figured out how to make the vendordep file be copied before trying to build examples
- name: Publish photonlib to maven local
run: |
chmod +x gradlew
./gradlew publishtomavenlocal -x check
run: ./gradlew photon-targeting:publishtomavenlocal photon-lib:publishtomavenlocal -x check
- name: Build Java examples
working-directory: photonlib-java-examples
run: |
chmod +x gradlew
./gradlew copyPhotonlib -x check
./gradlew build -x check --max-workers 2
run: ./gradlew build
- name: Build C++ examples
working-directory: photonlib-cpp-examples
run: |
chmod +x gradlew
./gradlew copyPhotonlib -x check
./gradlew build -x check --max-workers 2
run: ./gradlew build
build-gradle:
name: "Gradle Build"
runs-on: ubuntu-22.04
@@ -74,26 +85,24 @@ jobs:
- name: Fetch tags
run: git fetch --tags --force
- name: Install Java 17
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
java-version: 17
distribution: temurin
- name: Install mrcal deps
run: sudo apt-get update && sudo apt-get install -y libcholmod3 liblapack3 libsuitesparseconfig5
- name: Gradle Build
run: |
chmod +x gradlew
./gradlew build -x check --max-workers 2
run: ./gradlew photon-targeting:build photon-core:build photon-server:build -x check
- name: Gradle Tests
run: ./gradlew testHeadless -i --max-workers 1 --stacktrace
run: ./gradlew testHeadless -i --stacktrace
- name: Gradle Coverage
run: ./gradlew jacocoTestReport --max-workers 1
run: ./gradlew jacocoTestReport
- name: Publish Coverage Report
uses: codecov/codecov-action@v3
uses: codecov/codecov-action@v4
with:
file: ./photon-server/build/reports/jacoco/test/jacocoTestReport.xml
- name: Publish Core Coverage Report
uses: codecov/codecov-action@v3
uses: codecov/codecov-action@v4
with:
file: ./photon-core/build/reports/jacoco/test/jacocoTestReport.xml
build-offline-docs:
@@ -101,27 +110,60 @@ jobs:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
with:
repository: 'PhotonVision/photonvision-docs.git'
ref: master
- uses: actions/setup-python@v5
with:
python-version: '3.9'
python-version: '3.11'
- name: Install graphviz
run: |
sudo apt-get update
sudo apt-get -y install graphviz
- name: Install dependencies
working-directory: docs
run: |
python -m pip install --upgrade pip
pip install sphinx sphinx_rtd_theme sphinx-tabs sphinxext-opengraph doc8
pip install -r requirements.txt
- name: Build the docs
working-directory: docs
run: |
make html
- uses: actions/upload-artifact@master
- uses: actions/upload-artifact@v4
with:
name: built-docs
path: build/html
path: docs/build/html
build-photonlib-vendorjson:
name: "Build Vendor JSON"
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install Java 17
uses: actions/setup-java@v4
with:
java-version: 17
distribution: temurin
# grab all tags
- run: git fetch --tags --force
# Generate the JSON and give it the ""standard""" name maven gives it
- run: |
./gradlew photon-lib:generateVendorJson
export VERSION=$(git describe --tags --match=v*)
mv photon-lib/build/generated/vendordeps/photonlib.json photon-lib/build/generated/vendordeps/photonlib-$(git describe --tags --match=v*).json
# Upload it here so it shows up in releases
- uses: actions/upload-artifact@v4
with:
name: photonlib-vendor-json
path: photon-lib/build/generated/vendordeps/photonlib-*.json
build-photonlib-host:
env:
MACOSX_DEPLOYMENT_TARGET: 12
MACOSX_DEPLOYMENT_TARGET: 13
strategy:
fail-fast: false
matrix:
@@ -129,9 +171,9 @@ jobs:
- os: windows-2022
artifact-name: Win64
architecture: x64
- os: macos-12
- os: macos-14
artifact-name: macOS
architecture: x64
architecture: aarch64
- os: ubuntu-22.04
artifact-name: Linux
@@ -146,26 +188,36 @@ jobs:
with:
java-version: 17
distribution: temurin
architecture: ${{ matrix.architecture }}
- run: git fetch --tags --force
- run: |
chmod +x gradlew
./gradlew photon-lib:build --max-workers 1
- run: ./gradlew photon-targeting:build photon-lib:build -i
name: Build with Gradle
- run: ./gradlew photon-lib:publish photon-targeting:publish
name: Publish
env:
ARTIFACTORY_API_KEY: ${{ secrets.ARTIFACTORY_API_KEY }}
if: github.event_name == 'push'
if: github.event_name == 'push' && github.repository_owner == 'photonvision'
# Copy artifacts to build/outputs/maven
- run: ./gradlew photon-lib:publish photon-targeting:publish -PcopyOfflineArtifacts
- uses: actions/upload-artifact@v4
with:
name: maven-${{ matrix.artifact-name }}
path: build/outputs
build-photonlib-docker:
strategy:
fail-fast: false
matrix:
include:
- container: wpilib/roborio-cross-ubuntu:2024-22.04
- container: wpilib/roborio-cross-ubuntu:2025-24.04
artifact-name: Athena
build-options: "-Ponlylinuxathena"
- container: wpilib/raspbian-cross-ubuntu:bullseye-22.04
artifact-name: Raspbian
build-options: "-Ponlylinuxarm32"
- container: wpilib/aarch64-cross-ubuntu:bullseye-22.04
artifact-name: Aarch64
build-options: "-Ponlylinuxarm64"
runs-on: ubuntu-22.04
container: ${{ matrix.container }}
@@ -178,16 +230,45 @@ jobs:
run: |
git config --global --add safe.directory /__w/photonvision/photonvision
- name: Build PhotonLib
run: |
chmod +x gradlew
./gradlew photon-lib:build --max-workers 1
# We don't need to run tests, since we specify only non-native platforms
run: ./gradlew photon-targeting:build photon-lib:build ${{ matrix.build-options }} -i -x test
- name: Publish
run: |
chmod +x gradlew
./gradlew photon-lib:publish photon-targeting:publish
run: ./gradlew photon-lib:publish photon-targeting:publish ${{ matrix.build-options }}
env:
ARTIFACTORY_API_KEY: ${{ secrets.ARTIFACTORY_API_KEY }}
if: github.event_name == 'push'
if: github.event_name == 'push' && github.repository_owner == 'photonvision'
# Copy artifacts to build/outputs/maven
- run: ./gradlew photon-lib:publish photon-targeting:publish -PcopyOfflineArtifacts ${{ matrix.build-options }}
- uses: actions/upload-artifact@v4
with:
name: maven-${{ matrix.artifact-name }}
path: build/outputs
combine:
name: Combine
needs: [build-photonlib-docker, build-photonlib-host]
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- run: git fetch --tags --force
# download all maven-* artifacts to outputs/
- uses: actions/download-artifact@v4
with:
merge-multiple: true
path: output
pattern: maven-*
- run: find .
- run: zip -r photonlib-$(git describe --tags --match=v*).zip .
name: ZIP stuff up
working-directory: output
- run: ls output
- uses: actions/upload-artifact@v4
with:
name: photonlib-offline
path: output/*.zip
build-package:
needs: [build-client, build-gradle, build-offline-docs]
@@ -198,24 +279,20 @@ jobs:
- os: windows-latest
artifact-name: Win64
architecture: x64
arch-override: none
arch-override: winx64
- os: macos-latest
artifact-name: macOS
architecture: x64
arch-override: none
- os: ubuntu-latest
artifact-name: Linux
architecture: x64
arch-override: none
arch-override: macx64
- os: macos-latest
artifact-name: macOSArm
architecture: x64
arch-override: macarm64
- os: ubuntu-latest
artifact-name: LinuxArm32
- os: ubuntu-22.04
artifact-name: Linux
architecture: x64
arch-override: linuxarm32
- os: ubuntu-latest
arch-override: linuxx64
- os: ubuntu-22.04
artifact-name: LinuxArm64
architecture: x64
arch-override: linuxarm64
@@ -232,6 +309,10 @@ jobs:
with:
java-version: 17
distribution: temurin
architecture: ${{ matrix.architecture }}
- name: Install Arm64 Toolchain
run: ./gradlew installArm64Toolchain
if: ${{ (matrix.artifact-name) == 'LinuxArm64' }}
- run: |
rm -rf photon-server/src/main/resources/web/*
mkdir -p photon-server/src/main/resources/web/docs
@@ -248,18 +329,95 @@ jobs:
with:
name: built-docs
path: photon-server/src/main/resources/web/docs
- run: |
chmod +x gradlew
./gradlew photon-server:shadowJar --max-workers 2 -PArchOverride=${{ matrix.arch-override }}
- run: ./gradlew photon-targeting:jar photon-server:shadowJar -PArchOverride=${{ matrix.arch-override }}
if: ${{ (matrix.arch-override != 'none') }}
- run: |
chmod +x gradlew
./gradlew photon-server:shadowJar --max-workers 2
- run: ./gradlew photon-server:shadowJar
if: ${{ (matrix.arch-override == 'none') }}
- uses: actions/upload-artifact@v4
with:
name: jar-${{ matrix.artifact-name }}
path: photon-server/build/libs
- uses: actions/upload-artifact@v4
with:
name: photon-targeting_jar-${{ matrix.artifact-name }}
path: photon-targeting/build/libs
run-smoketest-native:
needs: [build-package]
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-22.04
artifact-name: jar-Linux
extraOpts: -Djdk.lang.Process.launchMechanism=vfork
- os: windows-latest
artifact-name: jar-Win64
extraOpts: ""
- os: macos-latest
artifact-name: jar-macOS
architecture: x64
runs-on: ${{ matrix.os }}
steps:
- name: Install Java 17
uses: actions/setup-java@v4
with:
java-version: 17
distribution: temurin
- uses: actions/download-artifact@v4
with:
name: ${{ matrix.artifact-name }}
# On linux, install mrcal packages
- run: |
sudo apt-get update
sudo apt-get install --yes libcholmod3 liblapack3 libsuitesparseconfig5
if: ${{ (matrix.os) == 'ubuntu-22.04' }}
# and actually run the jar
- run: java -jar ${{ matrix.extraOpts }} *.jar --smoketest
if: ${{ (matrix.os) != 'windows-latest' }}
- run: ls *.jar | %{ Write-Host "Running $($_.Name)"; Start-Process "java" -ArgumentList "-jar `"$($_.FullName)`" --smoketest" -NoNewWindow -Wait; break }
if: ${{ (matrix.os) == 'windows-latest' }}
run-smoketest-chroot:
needs: [build-package]
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-22.04
artifact-name: LinuxArm64
image_suffix: RaspberryPi
image_url: https://github.com/PhotonVision/photon-image-modifier/releases/download/v2025.0.3/photonvision_raspi.img.xz
cpu: cortex-a7
image_additional_mb: 0
extraOpts: -Djdk.lang.Process.launchMechanism=vfork
runs-on: ${{ matrix.os }}
name: smoketest-${{ matrix.image_suffix }}
steps:
- uses: actions/download-artifact@v4
with:
name: jar-${{ matrix.artifact-name }}
- uses: pguyot/arm-runner-action@v2
name: Run photon smoketest
id: generate_image
with:
base_image: ${{ matrix.image_url }}
image_additional_mb: ${{ matrix.image_additional_mb }}
optimize_image: yes
cpu: ${{ matrix.cpu }}
# We do _not_ wanna copy photon into the image. Bind mount instead
bind_mount_repository: true
# our image better have java installed already
commands: |
java -jar ${{ matrix.extraOpts }} *.jar --smoketest
build-image:
needs: [build-package]
@@ -269,36 +427,66 @@ jobs:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
- os: ubuntu-22.04
artifact-name: LinuxArm64
image_suffix: RaspberryPi
image_url: https://github.com/PhotonVision/photon-image-modifier/releases/download/v2024.0.4/photonvision_raspi.img.xz
image_url: https://github.com/PhotonVision/photon-image-modifier/releases/download/v2025.0.3/photonvision_raspi.img.xz
cpu: cortex-a7
image_additional_mb: 0
- os: ubuntu-latest
- os: ubuntu-22.04
artifact-name: LinuxArm64
image_suffix: limelight2
image_url: https://github.com/PhotonVision/photon-image-modifier/releases/download/v2024.0.4/photonvision_limelight.img.xz
image_url: https://github.com/PhotonVision/photon-image-modifier/releases/download/v2025.0.3/photonvision_limelight.img.xz
cpu: cortex-a7
image_additional_mb: 0
- os: ubuntu-latest
- os: ubuntu-22.04
artifact-name: LinuxArm64
image_suffix: limelight3
image_url: https://github.com/PhotonVision/photon-image-modifier/releases/download/v2024.0.5/photonvision_limelight3.img.xz
image_url: https://github.com/PhotonVision/photon-image-modifier/releases/download/v2025.0.3/photonvision_limelight3.img.xz
cpu: cortex-a7
image_additional_mb: 0
- os: ubuntu-latest
- os: ubuntu-22.04
artifact-name: LinuxArm64
image_suffix: limelight3G
image_url: https://github.com/PhotonVision/photon-image-modifier/releases/download/v2025.0.3/photonvision_limelight3g.img.xz
cpu: cortex-a7
image_additional_mb: 0
- os: ubuntu-22.04
artifact-name: LinuxArm64
image_suffix: orangepi5
image_url: https://github.com/PhotonVision/photon-image-modifier/releases/download/v2024.0.6/photonvision_opi5.img.xz
image_url: https://github.com/PhotonVision/photon-image-modifier/releases/download/v2025.0.3/photonvision_opi5.img.xz
cpu: cortex-a8
image_additional_mb: 4096
- os: ubuntu-latest
image_additional_mb: 1024
- os: ubuntu-22.04
artifact-name: LinuxArm64
image_suffix: orangepi5b
image_url: https://github.com/PhotonVision/photon-image-modifier/releases/download/v2025.0.3/photonvision_opi5b.img.xz
cpu: cortex-a8
image_additional_mb: 1024
- os: ubuntu-22.04
artifact-name: LinuxArm64
image_suffix: orangepi5plus
image_url: https://github.com/PhotonVision/photon-image-modifier/releases/download/v2024.0.6/photonvision_opi5plus.img.xz
image_url: https://github.com/PhotonVision/photon-image-modifier/releases/download/v2025.0.3/photonvision_opi5plus.img.xz
cpu: cortex-a8
image_additional_mb: 4096
image_additional_mb: 1024
- os: ubuntu-22.04
artifact-name: LinuxArm64
image_suffix: orangepi5pro
image_url: https://github.com/PhotonVision/photon-image-modifier/releases/download/v2025.0.3/photonvision_opi5pro.img.xz
cpu: cortex-a8
image_additional_mb: 1024
- os: ubuntu-22.04
artifact-name: LinuxArm64
image_suffix: orangepi5max
image_url: https://github.com/PhotonVision/photon-image-modifier/releases/download/v2025.0.3/photonvision_opi5max.img.xz
cpu: cortex-a8
image_additional_mb: 1024
- os: ubuntu-22.04
artifact-name: LinuxArm64
image_suffix: rock5c
image_url: https://github.com/PhotonVision/photon-image-modifier/releases/download/v2025.0.3/photonvision_rock5c.img.xz
cpu: cortex-a8
image_additional_mb: 1024
runs-on: ${{ matrix.os }}
name: "Build image - ${{ matrix.image_url }}"
@@ -311,7 +499,7 @@ jobs:
- uses: actions/download-artifact@v4
with:
name: jar-${{ matrix.artifact-name }}
- uses: pguyot/arm-runner-action@v2
- uses: pguyot/arm-runner-action@HEAD
name: Generate image
id: generate_image
with:
@@ -336,12 +524,30 @@ jobs:
name: image-${{ matrix.image_suffix }}
path: photonvision*.xz
release:
needs: [build-package, build-image]
needs: [build-package, build-image, combine]
runs-on: ubuntu-22.04
steps:
# Download literally every single artifact. This also downloads client and docs,
# but the filtering below won't pick these up (I hope)
# Download all fat JARs
- uses: actions/download-artifact@v4
with:
merge-multiple: true
pattern: jar-*
# Download offline photonlib
- uses: actions/download-artifact@v4
with:
merge-multiple: true
pattern: photonlib-offline
# Download vendor json
- uses: actions/download-artifact@v4
with:
merge-multiple: true
pattern: photonlib-vendor-json
# Download all images
- uses: actions/download-artifact@v4
with:
merge-multiple: true
pattern: image-*
- run: find
# Push to dev release
- uses: pyTooling/Actions/releaser@r0
@@ -353,14 +559,40 @@ jobs:
**/*.xz
**/*.jar
**/photonlib*.json
**/photonlib*.zip
if: github.event_name == 'push'
# Upload all jars and xz archives
- uses: softprops/action-gh-release@v1
# Split into two uploads to work around max size limits in action-gh-releases
# https://github.com/softprops/action-gh-release/issues/353
- uses: softprops/action-gh-release@v2.0.9
with:
files: |
**/*.xz
**/*.jar
**/photonlib*.json
**/@(*orangepi5*|*rock5*).xz
if: startsWith(github.ref, 'refs/tags/v')
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- uses: softprops/action-gh-release@v2.0.9
with:
files: |
**/!(*orangepi5*|*rock5*).xz
**/*.jar
**/photonlib*.json
**/photonlib*.zip
if: startsWith(github.ref, 'refs/tags/v')
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
dispatch:
name: dispatch
needs: [build-photonlib-vendorjson, release]
runs-on: ubuntu-22.04
steps:
- uses: peter-evans/repository-dispatch@v3
if: |
github.repository == 'PhotonVision/photonvision' &&
startsWith(github.ref, 'refs/tags/v')
with:
token: ${{ secrets.VENDOR_JSON_REPO_PUSH_TOKEN }}
repository: PhotonVision/vendor-json-repo
event-type: tag
client-payload: '{"run_id": "${{ github.run_id }}", "package_version": "${{ github.ref_name }}"}'

17
.github/workflows/cut-new-tag.yml vendored Normal file
View File

@@ -0,0 +1,17 @@
name: Cut a new tag
on:
workflow_dispatch:
inputs:
tag_name:
type: string
description: The full name of the new tag to push to the latest commit to main
jobs:
push_tag:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: git tag ${{ github.event.inputs.tag_name }}
- run: git push origin ${{ github.event.inputs.tag_name }}

View File

@@ -1,12 +1,14 @@
name: Lint and Format
on:
# Run on pushes to main and pushed tags, and on pull requests against main, but ignore the docs folder
push:
branches: [ master ]
branches: [ main ]
tags:
- 'v*'
pull_request:
branches: [ master ]
branches: [ main ]
merge_group:
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
@@ -17,18 +19,18 @@ jobs:
name: "wpiformat"
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Fetch all history and metadata
run: |
git fetch --prune --unshallow
git checkout -b pr
git branch -f master origin/master
git branch -f main origin/main
- name: Set up Python 3.8
uses: actions/setup-python@v4
with:
python-version: 3.8
python-version: 3.11
- name: Install wpiformat
run: pip3 install wpiformat
run: pip3 install wpiformat==2024.45
- name: Run
run: wpiformat
- name: Check output
@@ -36,7 +38,7 @@ jobs:
- name: Generate diff
run: git diff HEAD > wpiformat-fixes.patch
if: ${{ failure() }}
- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
with:
name: wpiformat fixes
path: wpiformat-fixes.patch
@@ -45,16 +47,15 @@ jobs:
name: "Java Formatting"
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-java@v3
- uses: actions/setup-java@v4
with:
java-version: 17
distribution: temurin
- run: |
chmod +x gradlew
./gradlew spotlessCheck
- run: ./gradlew spotlessCheck
name: Run spotless
client-lint-format:
name: "PhotonClient Lint and Formatting"
@@ -63,9 +64,9 @@ jobs:
working-directory: photon-client
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: 18
- name: Install Dependencies
@@ -78,11 +79,11 @@ jobs:
name: "Check server index.html not changed"
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Fetch all history and metadata
run: |
git fetch --prune --unshallow
git checkout -b pr
git branch -f master origin/master
git branch -f main origin/main
- name: Check index.html not changed
run: git --no-pager diff --exit-code origin/master photon-server/src/main/resources/web/index.html
run: git --no-pager diff --exit-code origin/main photon-server/src/main/resources/web/index.html

View File

@@ -1,12 +1,18 @@
name: Documentation
name: Photon Code Documentation
on:
# Run on pushes to main and pushed tags, and on pull requests against main, but ignore the docs folder
push:
# For now, run on all commits to master
branches: [ master ]
# and also all tags starting with v
branches: [ main ]
tags:
- 'v*'
pull_request:
branches: [ main ]
merge_group:
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
cancel-in-progress: true
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
@@ -14,10 +20,6 @@ permissions:
pages: write
id-token: write
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
build-client:
name: "PhotonClient Build"
@@ -50,7 +52,7 @@ jobs:
- name: Fetch tags
run: git fetch --tags --force
- name: Install Java 17
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
java-version: 17
distribution: temurin
@@ -58,20 +60,16 @@ jobs:
- name: Build javadocs/doxygen
run: |
chmod +x gradlew
./gradlew docs:generateJavaDocs docs:doxygen
./gradlew photon-docs:generateJavaDocs photon-docs:doxygen
- uses: actions/upload-artifact@v4
with:
name: built-docs
path: docs/build/docs
path: photon-docs/build/docs
release:
needs: [build-client, run_docs]
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-22.04
steps:
@@ -79,14 +77,13 @@ jobs:
- uses: actions/download-artifact@v4
- run: find .
- name: Setup Pages
uses: actions/configure-pages@v4
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
- name: copy file via ssh password
if: github.ref == 'refs/heads/main'
uses: appleboy/scp-action@v0.1.7
with:
# Upload entire repository
path: '.'
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
host: ${{ secrets.WEBMASTER_SSH_HOST }}
username: ${{ secrets.WEBMASTER_SSH_USERNAME }}
password: ${{ secrets.WEBMASTER_SSH_KEY }}
port: ${{ secrets.WEBMASTER_SSH_PORT }}
source: "*"
target: /var/www/html/photonvision-docs/

53
.github/workflows/photonvision-docs.yml vendored Normal file
View File

@@ -0,0 +1,53 @@
name: PhotonVision Sphinx Documentation Checks
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
merge_group:
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
cancel-in-progress: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
jobs:
build:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
with:
python-version: '3.11'
- name: Install and upgrade pip
run: python -m pip install --upgrade pip
- name: Install graphviz
run: |
sudo apt-get update
sudo apt-get -y install graphviz
- name: Install Python dependencies
working-directory: docs
run: |
pip install sphinx sphinx_rtd_theme sphinx-tabs sphinxext-opengraph doc8
pip install -r requirements.txt
- name: Check links
working-directory: docs
run: make linkcheck
continue-on-error: true
- name: Check lint
working-directory: docs
run: make lint
- name: Compile HTML
working-directory: docs
run: make html

View File

@@ -5,15 +5,20 @@ permissions:
on:
push:
branches: [ master ]
branches: [ main ]
tags:
- 'v*'
pull_request:
branches: [ master ]
branches: [ main ]
merge_group:
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
cancel-in-progress: true
jobs:
buildAndDeploy:
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
steps:
- name: Checkout code
@@ -29,7 +34,7 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel pytest
pip install setuptools wheel pytest mypy
- name: Build wheel
working-directory: ./photon-lib/py
@@ -42,6 +47,13 @@ jobs:
pip install --no-cache-dir dist/*.whl
pytest
- name: Run mypy type checking
uses: liskin/gh-problem-matcher-wrap@v3
with:
linters: mypy
run: |
mypy --show-column-numbers --config-file photon-lib/py/pyproject.toml photon-lib
- name: Upload artifacts
uses: actions/upload-artifact@master

24
.gitignore vendored
View File

@@ -131,27 +131,12 @@ New client/photon-client/*
*.jfr
.DS_Store
# *.iml
photon-server/build
photon-server/photon-vision
photon-server/src/main/resources/web
photon-server/src/main/java/org/photonvision/PhotonVersion.java
photon-server/src/main/generated/native/include/org_photonvision_raspi_PicamJNI.h
*.bin
.gradle
.gradle/*
photonvision_config
build/spotlessJava
build/*
build
photon-lib/src/main/java/org/photonvision/PhotonVersion.java
photon-lib/bin/main/images/*
/photonlib-java-examples/bin/
photon-lib/src/generate/native/include/PhotonVersion.h
.gitattributes
lib/*
photon-server/lib/libapriltag.so
photon-server/bin/main/nativelibraries/apriltag/*
photon-server/src/main/resources/nativelibraries/apriltag/*
bin*/
build*/
photonlib-java-examples/*/vendordeps/*
photonlib-cpp-examples/*/vendordeps/*
@@ -161,6 +146,7 @@ photonlib-cpp-examples/*/vendordeps/*
photonlib-cpp-examples/*/networktables.json.bck
photonlib-java-examples/*/networktables.json.bck
*.sqlite
photon-server/src/main/resources/web/index.html
photon-server/src/main/resources/web/*
venv
.venv/*
.venv

30
.readthedocs.yaml Normal file
View File

@@ -0,0 +1,30 @@
version: 2
sphinx:
builder: html
configuration: docs/source/conf.py
fail_on_warning: true
build:
os: ubuntu-22.04
tools:
python: "3.11"
apt_packages:
- graphviz
jobs:
post_checkout:
# Cancel building pull requests when there aren't changed in the docs directory or YAML file.
# You can add any other files or directories that you'd like here as well,
# like your docs requirements file, or other files that will change your docs build.
#
# If there are no changes (git diff exits with 0) we force the command to return with 183.
# This is a special exit code on Read the Docs that will cancel the build immediately.
- |
if [ "$READTHEDOCS_VERSION_TYPE" = "external" ] && git diff --quiet origin/master -- docs/ .readthedocs.yaml;
then
exit 183;
fi
python:
install:
- requirements: docs/requirements.txt

View File

@@ -20,6 +20,8 @@ modifiableFileExclude {
\.ico$
\.rknn$
gradlew
photon-lib/py/photonlibpy/generated/
photon-targeting/src/generated/
}
includeProject {

101
README.md
View File

@@ -1,10 +1,10 @@
# Photon Vision
# PhotonVision
[![CI](https://github.com/PhotonVision/photonvision/workflows/CI/badge.svg)](https://github.com/PhotonVision/photonvision/actions?query=workflow%3ACI) [![codecov](https://codecov.io/gh/PhotonVision/photonvision/branch/master/graph/badge.svg)](https://codecov.io/gh/PhotonVision/photonvision) [![Discord](https://img.shields.io/discord/725836368059826228?color=%23738ADB&label=Join%20our%20Discord&logo=discord&logoColor=white)](https://discord.gg/wYxTwym)
[![CI](https://github.com/PhotonVision/photonvision/workflows/CI/badge.svg)](https://github.com/PhotonVision/photonvision/actions?query=workflow%3ACI) [![codecov](https://codecov.io/gh/PhotonVision/photonvision/branch/main/graph/badge.svg)](https://codecov.io/gh/PhotonVision/photonvision) [![Discord](https://img.shields.io/discord/725836368059826228?color=%23738ADB&label=Join%20our%20Discord&logo=discord&logoColor=white)](https://discord.gg/wYxTwym)
PhotonVision is the free, fast, and easy-to-use computer vision solution for the *FIRST* Robotics Competition. You can read an overview of our features [on our website](https://photonvision.org). You can find our comprehensive documentation [here](https://docs.photonvision.org).
A copy of the latest Raspberry Pi image is available [here](https://github.com/PhotonVision/photon-pi-gen/releases). A copy of the latest standalone JAR is available [here](https://github.com/PhotonVision/photonvision/releases). If you are a Gloworm user you can find the latest Gloworm image [here](https://github.com/gloworm-vision/pi-gen/releases).
The latest release of platform-specific jars and images is found [here](https://github.com/PhotonVision/photonvision/releases).
If you are interested in contributing code or documentation to the project, please [read our getting started page for contributors](https://docs.photonvision.org/en/latest/docs/contributing/index.html) and **[join the Discord](https://discord.gg/wYxTwym) to introduce yourself!** We hope to provide a welcoming community to anyone who is interested in helping.
@@ -14,54 +14,40 @@ If you are interested in contributing code or documentation to the project, plea
<img src="https://contrib.rocks/image?repo=PhotonVision/photonvision" />
</a>
## Documentation
- Our main documentation page: [docs.photonvision.org](https://docs.photonvision.org)
- Photon UI demo: [http://photonvision.global/](http://photonvision.global/) (or [manual link](https://photonvision.github.io/photonvision/built-client/))
- Javadocs: [javadocs.photonvision.org](https://javadocs.photonvision.org) (or [manual link](https://photonvision.github.io/photonvision/built-docs/javadoc/))
- C++ Doxygen [cppdocs.photonvision.org](https://cppdocs.photonvision.org) (or [manual link](https://photonvision.github.io/photonvision/built-docs/doxygen/html/))
## Building
Gradle is used for all C++ and Java code, and NPM is used for the web UI. Instructions to compile PhotonVision yourself can be found [in our docs](https://docs.photonvision.org/en/latest/docs/contributing/building-photon.html#compiling-instructions).
You can run one of the many built in examples straight from the command line, too! They contain a fully featured robot project, and some include simulation support. The projects can be found inside the [`photonlib-java-examples`](photonlib-java-examples) and [`photonlib-cpp-examples`](photonlib-cpp-examples) subdirectories, respectively. Instructions for running these examples directly from the repo are found [in the docs](https://docs.photonvision.org/en/latest/docs/contributing/building-photon.html#running-examples).
## Gradle Arguments
Note that these are case sensitive!
* `-PArchOverride=foobar`: builds for a target system other than your current architecture. Valid overrides are:
* linuxathena
* linuxarm32
* `-PArchOverride=foobar`: builds for a target system other than your current architecture. [Valid overrides](https://github.com/wpilibsuite/wpilib-tool-plugin/blob/main/src/main/java/edu/wpi/first/tools/NativePlatforms.java) are:
* winx32
* winx64
* winarm64
* macx64
* macarm64
* linuxx64
* linuxarm64
* arm32
* arm64
* x86-64
* x86
- `-PtgtIp`: Specifies where `./gradlew deploy` should try to copy the fat JAR to
* linuxathena
- `-PtgtIP`: Specifies where `./gradlew deploy` should try to copy the fat JAR to
- `-Pprofile`: enables JVM profiling
## Building
Gradle is used for all C++ and Java code, and NPM is used for the web UI. Instructions to compile PhotonVision yourself can be found [in our docs](https://docs.photonvision.org/en/latest/docs/contributing/photonvision/build-instructions.html?highlight=npm%20install#compiling-instructions).
You can run one of the many built in examples straight from the command line, too! They contain a fully featured robot project, and some include simulation support. The projects can be found inside the `photonlib-java-examples` and `photonlib-cpp-examples` subdirectories, respectively. The projects currently available include:
- photonlib-java-examples:
- aimandrange:simulateJava
- aimattarget:simulateJava
- getinrange:simulateJava
- simaimandrange:simulateJava
- simposeest:simulateJava
- photonlib-cpp-examples:
- aimandrange:simulateNative
- getinrange:simulateNative
To run them, use the commands listed below. Photonlib must first be published to your local maven repository, then the `copyPhotonlib` task will copy the generated vendordep json file into each example. After that, the simulateJava/simulateNative task can be used like a normal robot project. Robot simulation with attached debugger is technically possible by using simulateExternalJava and modifying the launch script it exports, though unsupported.
```
~/photonvision$ ./gradlew publishToMavenLocal
~/photonvision$ cd photonlib-java-examples
~/photonvision/photonlib-java-examples$ ./gradlew copyPhotonlib
~/photonvision/photonlib-java-examples$ ./gradlew <example-name>:simulateJava
~/photonvision$ cd photonlib-cpp-examples
~/photonvision/photonlib-cpp-examples$ ./gradlew copyPhotonlib
~/photonvision/photonlib-cpp-examples$ ./gradlew <example-name>:simulateNative
```
If you're cross-compiling, you'll need the wpilib toolchain installed. This can be done via Gradle: for example `./gradlew installArm64Toolchain` or `./gradlew installRoboRioToolchain`
## Out-of-Source Dependencies
PhotonVision uses the following additonal out-of-source repositories for building code.
PhotonVision uses the following additional out-of-source repositories for building code.
- Base system images for Raspberry Pi & Orange Pi: https://github.com/PhotonVision/photon-image-modifier
- C++ driver for Raspberry Pi CSI cameras: https://github.com/PhotonVision/photon-libcamera-gl-driver
@@ -69,12 +55,19 @@ PhotonVision uses the following additonal out-of-source repositories for buildin
- Custom build of OpenCV with GStreamer/Protobuf/other custom flags: https://github.com/PhotonVision/thirdparty-opencv
- JNI code for aruco-nano: https://github.com/PhotonVision/aruconano-jni
## Additional packages
For now, using mrcal requires installing these additional packages on Linux systems:
```
sudo apt install libcholmod3 liblapack3 libsuitesparseconfig5
```
## Acknowledgments
PhotonVision was forked from [Chameleon Vision](https://github.com/Chameleon-Vision/chameleon-vision/). Thank you to everyone who worked on the original project.
* [WPILib](https://github.com/wpilibsuite) - Specifically [cscore](https://github.com/wpilibsuite/allwpilib/tree/master/cscore), [CameraServer](https://github.com/wpilibsuite/allwpilib/tree/master/cameraserver), [NTCore](https://github.com/wpilibsuite/allwpilib/tree/master/ntcore), and [OpenCV](https://github.com/wpilibsuite/thirdparty-opencv).
* [WPILib](https://github.com/wpilibsuite) - Specifically [cscore](https://github.com/wpilibsuite/allwpilib/tree/main/cscore), [CameraServer](https://github.com/wpilibsuite/allwpilib/tree/main/cameraserver), [NTCore](https://github.com/wpilibsuite/allwpilib/tree/main/ntcore), and [OpenCV](https://github.com/wpilibsuite/thirdparty-opencv).
* [Apache Commons](https://commons.apache.org/) - Specifically [Commons Math](https://commons.apache.org/proper/commons-math/), and [Commons Lang](https://commons.apache.org/proper/commons-lang/)
@@ -85,25 +78,9 @@ PhotonVision was forked from [Chameleon Vision](https://github.com/Chameleon-Vis
* [FasterXML](https://github.com/FasterXML) - Specifically [jackson](https://github.com/FasterXML/jackson)
## License
PhotonVision is licensed under the [GNU General Public License](https://www.gnu.org/licenses/gpl-3.0.html)
PhotonVision is licensed under the [GNU General Public License](https://www.gnu.org/licenses/gpl-3.0.html).
## Meeting Notes
Our meeting notes can be found in the wiki section of this repository.
* [2020 Meeting Notes](https://github.com/PhotonVision/photonvision/wiki/2020-Meeting-Notes)
* [2021 Meeting Notes](https://github.com/PhotonVision/photonvision/wiki/2021-Meeting-Notes)
## Additional packages
For now, using mrcal requires installing these additional packages on Linux systems:
```
sudo apt install libcholmod3 liblapack3 libsuitesparseconfig5
```
## Documentation
- Our main documentation page: [docs.photonvision.org](https://docs.photonvision.org)
- Photon UI demo: [demo.photonvision.org](https://demo.photonvision.org) (or [manual link](https://photonvision.github.io/photonvision/built-client/))
- Javadocs: [javadocs.photonvision.org](https://javadocs.photonvision.org) (or [manual link](https://photonvision.github.io/photonvision/built-docs/javadoc/))
- C++ Doxygen [cppdocs.photonvision.org](https://cppdocs.photonvision.org) (or [manual link](https://photonvision.github.io/photonvision/built-docs/doxygen/html/))
Our [meeting notes](https://github.com/PhotonVision/photonvision/wiki/PhotonVision-Meeting-Notes) can be found in the wiki section of this repository.

View File

@@ -1,38 +1,48 @@
import edu.wpi.first.toolchain.*
plugins {
id "cpp"
id "com.diffplug.spotless" version "6.24.0"
id "edu.wpi.first.NativeUtils" version "2024.6.1" apply false
id "edu.wpi.first.wpilib.repositories.WPILibRepositoriesPlugin" version "2020.2"
id "edu.wpi.first.GradleRIO" version "2024.2.1"
id "edu.wpi.first.GradleRIO" version "2025.2.1"
id 'edu.wpi.first.WpilibTools' version '1.3.0'
id 'com.google.protobuf' version '0.9.4' apply false
id 'com.google.protobuf' version '0.9.3' apply false
id 'edu.wpi.first.GradleJni' version '1.1.0'
id "org.ysb33r.doxygen" version "1.0.4" apply false
id 'com.gradleup.shadow' version '8.3.4' apply false
id "com.github.node-gradle.node" version "7.0.1" apply false
id "org.hidetake.ssh" version "2.11.2" apply false
}
allprojects {
repositories {
mavenCentral()
mavenLocal()
maven { url = "https://maven.photonvision.org/repository/internal/" }
maven { url = "https://maven.photonvision.org/repository/snapshots/" }
maven { url = "https://maven.photonvision.org/releases" }
maven { url = "https://maven.photonvision.org/snapshots" }
maven { url = "https://jogamp.org/deployment/maven/" }
}
wpilibRepositories.addAllReleaseRepositories(it)
wpilibRepositories.addAllDevelopmentRepositories(it)
}
ext.localMavenURL = file("$project.buildDir/outputs/maven")
ext.allOutputsFolder = file("$project.buildDir/outputs")
// Configure the version number.
apply from: "versioningHelper.gradle"
ext {
wpilibVersion = "2024.2.1"
wpilibVersion = "2025.2.1"
wpimathVersion = wpilibVersion
openCVversion = "4.8.0-2"
joglVersion = "2.4.0-rc-20200307"
openCVYear = "2025"
openCVversion = "4.10.0-3"
joglVersion = "2.4.0"
javalinVersion = "5.6.2"
photonGlDriverLibVersion = "dev-v2023.1.0-9-g75fc678"
rknnVersion = "dev-v2024.0.0-64-gc0836a6"
frcYear = "2024"
mrcalVersion = "dev-v2024.0.0-7-gc976aaa";
libcameraDriverVersion = "v2025.0.3"
rknnVersion = "v2025.0.0"
frcYear = "2025"
mrcalVersion = "v2025.0.0";
pubVersion = versionString
@@ -50,13 +60,17 @@ ext {
println("Building for platform " + jniPlatform + " wpilib: " + wpilibNativeName)
println("Using Wpilib: " + wpilibVersion)
println("Using OpenCV: " + openCVversion)
photonMavenURL = 'https://maven.photonvision.org/' + (isDev ? 'snapshots' : 'releases');
println("Publishing Photonlib to " + photonMavenURL)
}
spotless {
java {
target fileTree('.') {
include '**/*.java'
exclude '**/build/**', '**/build-*/**', "photon-core\\src\\main\\java\\org\\photonvision\\PhotonVersion.java", "photon-lib\\src\\main\\java\\org\\photonvision\\PhotonVersion.java"
exclude '**/build/**', '**/build-*/**', '**/src/generated/**'
}
toggleOffOn()
googleJavaFormat()
@@ -76,16 +90,6 @@ spotless {
trimTrailingWhitespace()
endWithNewline()
}
format 'xml', {
target fileTree('.') {
include '**/*.xml'
exclude '**/build/**', '**/build-*/**', "**/.idea/**"
}
eclipseWtp('xml')
trimTrailingWhitespace()
indentWithSpaces(2)
endWithNewline()
}
format 'misc', {
target fileTree('.') {
include '**/*.md', '**/.gitignore'
@@ -98,9 +102,23 @@ spotless {
}
wrapper {
gradleVersion '8.4'
gradleVersion '8.11'
}
ext.getCurrentArch = {
return NativePlatforms.desktop
}
subprojects {
tasks.withType(JavaCompile) {
options.compilerArgs.add '-XDstringConcat=inline'
options.encoding = 'UTF-8'
}
// Enables UTF-8 support in Javadoc
tasks.withType(Javadoc) {
options.addStringOption("charset", "utf-8")
options.addStringOption("docencoding", "utf-8")
options.addStringOption("encoding", "utf-8")
}
}

View File

@@ -1,12 +1,12 @@
import argparse
import base64
from dataclasses import dataclass
import json
import os
from typing import Union
from dataclasses import dataclass
import cv2
import numpy as np
import mrcal
import numpy as np
from wpimath.geometry import Quaternion as _Quat
@@ -162,9 +162,9 @@ def __convert_cal_to_mrcal_cameramodel(
"indices_point_camintrinsics_camextrinsics": None,
"lensmodel": model,
"imagersizes": np.array([imagersize], dtype=np.int32),
"calobject_warp": np.array(cal.calobjectWarp)
if len(cal.calobjectWarp) > 0
else None,
"calobject_warp": (
np.array(cal.calobjectWarp) if len(cal.calobjectWarp) > 0 else None
),
# We always do all the things
"do_optimize_intrinsics_core": True,
"do_optimize_intrinsics_distortions": True,

9
docs/.gitignore vendored Normal file
View File

@@ -0,0 +1,9 @@
build/*
.DS_Store
.vscode/*
.idea/*
source/_build
source/docs/_build
venv/*
.venv/*

16
docs/.styleguide Normal file
View File

@@ -0,0 +1,16 @@
modifiableFileExclude {
\.jpg$
\.jpeg$
\.png$
\.gif$
\.so$
\.pdf$
\.mp4$
\.dll$
\.webp$
\.ico$
\.rknn$
\.svg$
gradlew
}

395
docs/LICENSE Normal file
View File

@@ -0,0 +1,395 @@
Attribution 4.0 International
=======================================================================
Creative Commons Corporation ("Creative Commons") is not a law firm and
does not provide legal services or legal advice. Distribution of
Creative Commons public licenses does not create a lawyer-client or
other relationship. Creative Commons makes its licenses and related
information available on an "as-is" basis. Creative Commons gives no
warranties regarding its licenses, any material licensed under their
terms and conditions, or any related information. Creative Commons
disclaims all liability for damages resulting from their use to the
fullest extent possible.
Using Creative Commons Public Licenses
Creative Commons public licenses provide a standard set of terms and
conditions that creators and other rights holders may use to share
original works of authorship and other material subject to copyright
and certain other rights specified in the public license below. The
following considerations are for informational purposes only, are not
exhaustive, and do not form part of our licenses.
Considerations for licensors: Our public licenses are
intended for use by those authorized to give the public
permission to use material in ways otherwise restricted by
copyright and certain other rights. Our licenses are
irrevocable. Licensors should read and understand the terms
and conditions of the license they choose before applying it.
Licensors should also secure all rights necessary before
applying our licenses so that the public can reuse the
material as expected. Licensors should clearly mark any
material not subject to the license. This includes other CC-
licensed material, or material used under an exception or
limitation to copyright. More considerations for licensors:
wiki.creativecommons.org/Considerations_for_licensors
Considerations for the public: By using one of our public
licenses, a licensor grants the public permission to use the
licensed material under specified terms and conditions. If
the licensor's permission is not necessary for any reason--for
example, because of any applicable exception or limitation to
copyright--then that use is not regulated by the license. Our
licenses grant only permissions under copyright and certain
other rights that a licensor has authority to grant. Use of
the licensed material may still be restricted for other
reasons, including because others have copyright or other
rights in the material. A licensor may make special requests,
such as asking that all changes be marked or described.
Although not required by our licenses, you are encouraged to
respect those requests where reasonable. More_considerations
for the public:
wiki.creativecommons.org/Considerations_for_licensees
=======================================================================
Creative Commons Attribution 4.0 International Public License
By exercising the Licensed Rights (defined below), You accept and agree
to be bound by the terms and conditions of this Creative Commons
Attribution 4.0 International Public License ("Public License"). To the
extent this Public License may be interpreted as a contract, You are
granted the Licensed Rights in consideration of Your acceptance of
these terms and conditions, and the Licensor grants You such rights in
consideration of benefits the Licensor receives from making the
Licensed Material available under these terms and conditions.
Section 1 -- Definitions.
a. Adapted Material means material subject to Copyright and Similar
Rights that is derived from or based upon the Licensed Material
and in which the Licensed Material is translated, altered,
arranged, transformed, or otherwise modified in a manner requiring
permission under the Copyright and Similar Rights held by the
Licensor. For purposes of this Public License, where the Licensed
Material is a musical work, performance, or sound recording,
Adapted Material is always produced where the Licensed Material is
synched in timed relation with a moving image.
b. Adapter's License means the license You apply to Your Copyright
and Similar Rights in Your contributions to Adapted Material in
accordance with the terms and conditions of this Public License.
c. Copyright and Similar Rights means copyright and/or similar rights
closely related to copyright including, without limitation,
performance, broadcast, sound recording, and Sui Generis Database
Rights, without regard to how the rights are labeled or
categorized. For purposes of this Public License, the rights
specified in Section 2(b)(1)-(2) are not Copyright and Similar
Rights.
d. Effective Technological Measures means those measures that, in the
absence of proper authority, may not be circumvented under laws
fulfilling obligations under Article 11 of the WIPO Copyright
Treaty adopted on December 20, 1996, and/or similar international
agreements.
e. Exceptions and Limitations means fair use, fair dealing, and/or
any other exception or limitation to Copyright and Similar Rights
that applies to Your use of the Licensed Material.
f. Licensed Material means the artistic or literary work, database,
or other material to which the Licensor applied this Public
License.
g. Licensed Rights means the rights granted to You subject to the
terms and conditions of this Public License, which are limited to
all Copyright and Similar Rights that apply to Your use of the
Licensed Material and that the Licensor has authority to license.
h. Licensor means the individual(s) or entity(ies) granting rights
under this Public License.
i. Share means to provide material to the public by any means or
process that requires permission under the Licensed Rights, such
as reproduction, public display, public performance, distribution,
dissemination, communication, or importation, and to make material
available to the public including in ways that members of the
public may access the material from a place and at a time
individually chosen by them.
j. Sui Generis Database Rights means rights other than copyright
resulting from Directive 96/9/EC of the European Parliament and of
the Council of 11 March 1996 on the legal protection of databases,
as amended and/or succeeded, as well as other essentially
equivalent rights anywhere in the world.
k. You means the individual or entity exercising the Licensed Rights
under this Public License. Your has a corresponding meaning.
Section 2 -- Scope.
a. License grant.
1. Subject to the terms and conditions of this Public License,
the Licensor hereby grants You a worldwide, royalty-free,
non-sublicensable, non-exclusive, irrevocable license to
exercise the Licensed Rights in the Licensed Material to:
a. reproduce and Share the Licensed Material, in whole or
in part; and
b. produce, reproduce, and Share Adapted Material.
2. Exceptions and Limitations. For the avoidance of doubt, where
Exceptions and Limitations apply to Your use, this Public
License does not apply, and You do not need to comply with
its terms and conditions.
3. Term. The term of this Public License is specified in Section
6(a).
4. Media and formats; technical modifications allowed. The
Licensor authorizes You to exercise the Licensed Rights in
all media and formats whether now known or hereafter created,
and to make technical modifications necessary to do so. The
Licensor waives and/or agrees not to assert any right or
authority to forbid You from making technical modifications
necessary to exercise the Licensed Rights, including
technical modifications necessary to circumvent Effective
Technological Measures. For purposes of this Public License,
simply making modifications authorized by this Section 2(a)
(4) never produces Adapted Material.
5. Downstream recipients.
a. Offer from the Licensor -- Licensed Material. Every
recipient of the Licensed Material automatically
receives an offer from the Licensor to exercise the
Licensed Rights under the terms and conditions of this
Public License.
b. No downstream restrictions. You may not offer or impose
any additional or different terms or conditions on, or
apply any Effective Technological Measures to, the
Licensed Material if doing so restricts exercise of the
Licensed Rights by any recipient of the Licensed
Material.
6. No endorsement. Nothing in this Public License constitutes or
may be construed as permission to assert or imply that You
are, or that Your use of the Licensed Material is, connected
with, or sponsored, endorsed, or granted official status by,
the Licensor or others designated to receive attribution as
provided in Section 3(a)(1)(A)(i).
b. Other rights.
1. Moral rights, such as the right of integrity, are not
licensed under this Public License, nor are publicity,
privacy, and/or other similar personality rights; however, to
the extent possible, the Licensor waives and/or agrees not to
assert any such rights held by the Licensor to the limited
extent necessary to allow You to exercise the Licensed
Rights, but not otherwise.
2. Patent and trademark rights are not licensed under this
Public License.
3. To the extent possible, the Licensor waives any right to
collect royalties from You for the exercise of the Licensed
Rights, whether directly or through a collecting society
under any voluntary or waivable statutory or compulsory
licensing scheme. In all other cases the Licensor expressly
reserves any right to collect such royalties.
Section 3 -- License Conditions.
Your exercise of the Licensed Rights is expressly made subject to the
following conditions.
a. Attribution.
1. If You Share the Licensed Material (including in modified
form), You must:
a. retain the following if it is supplied by the Licensor
with the Licensed Material:
i. identification of the creator(s) of the Licensed
Material and any others designated to receive
attribution, in any reasonable manner requested by
the Licensor (including by pseudonym if
designated);
ii. a copyright notice;
iii. a notice that refers to this Public License;
iv. a notice that refers to the disclaimer of
warranties;
v. a URI or hyperlink to the Licensed Material to the
extent reasonably practicable;
b. indicate if You modified the Licensed Material and
retain an indication of any previous modifications; and
c. indicate the Licensed Material is licensed under this
Public License, and include the text of, or the URI or
hyperlink to, this Public License.
2. You may satisfy the conditions in Section 3(a)(1) in any
reasonable manner based on the medium, means, and context in
which You Share the Licensed Material. For example, it may be
reasonable to satisfy the conditions by providing a URI or
hyperlink to a resource that includes the required
information.
3. If requested by the Licensor, You must remove any of the
information required by Section 3(a)(1)(A) to the extent
reasonably practicable.
4. If You Share Adapted Material You produce, the Adapter's
License You apply must not prevent recipients of the Adapted
Material from complying with this Public License.
Section 4 -- Sui Generis Database Rights.
Where the Licensed Rights include Sui Generis Database Rights that
apply to Your use of the Licensed Material:
a. for the avoidance of doubt, Section 2(a)(1) grants You the right
to extract, reuse, reproduce, and Share all or a substantial
portion of the contents of the database;
b. if You include all or a substantial portion of the database
contents in a database in which You have Sui Generis Database
Rights, then the database in which You have Sui Generis Database
Rights (but not its individual contents) is Adapted Material; and
c. You must comply with the conditions in Section 3(a) if You Share
all or a substantial portion of the contents of the database.
For the avoidance of doubt, this Section 4 supplements and does not
replace Your obligations under this Public License where the Licensed
Rights include other Copyright and Similar Rights.
Section 5 -- Disclaimer of Warranties and Limitation of Liability.
a. UNLESS OTHERWISE SEPARATELY UNDERTAKEN BY THE LICENSOR, TO THE
EXTENT POSSIBLE, THE LICENSOR OFFERS THE LICENSED MATERIAL AS-IS
AND AS-AVAILABLE, AND MAKES NO REPRESENTATIONS OR WARRANTIES OF
ANY KIND CONCERNING THE LICENSED MATERIAL, WHETHER EXPRESS,
IMPLIED, STATUTORY, OR OTHER. THIS INCLUDES, WITHOUT LIMITATION,
WARRANTIES OF TITLE, MERCHANTABILITY, FITNESS FOR A PARTICULAR
PURPOSE, NON-INFRINGEMENT, ABSENCE OF LATENT OR OTHER DEFECTS,
ACCURACY, OR THE PRESENCE OR ABSENCE OF ERRORS, WHETHER OR NOT
KNOWN OR DISCOVERABLE. WHERE DISCLAIMERS OF WARRANTIES ARE NOT
ALLOWED IN FULL OR IN PART, THIS DISCLAIMER MAY NOT APPLY TO YOU.
b. TO THE EXTENT POSSIBLE, IN NO EVENT WILL THE LICENSOR BE LIABLE
TO YOU ON ANY LEGAL THEORY (INCLUDING, WITHOUT LIMITATION,
NEGLIGENCE) OR OTHERWISE FOR ANY DIRECT, SPECIAL, INDIRECT,
INCIDENTAL, CONSEQUENTIAL, PUNITIVE, EXEMPLARY, OR OTHER LOSSES,
COSTS, EXPENSES, OR DAMAGES ARISING OUT OF THIS PUBLIC LICENSE OR
USE OF THE LICENSED MATERIAL, EVEN IF THE LICENSOR HAS BEEN
ADVISED OF THE POSSIBILITY OF SUCH LOSSES, COSTS, EXPENSES, OR
DAMAGES. WHERE A LIMITATION OF LIABILITY IS NOT ALLOWED IN FULL OR
IN PART, THIS LIMITATION MAY NOT APPLY TO YOU.
c. The disclaimer of warranties and limitation of liability provided
above shall be interpreted in a manner that, to the extent
possible, most closely approximates an absolute disclaimer and
waiver of all liability.
Section 6 -- Term and Termination.
a. This Public License applies for the term of the Copyright and
Similar Rights licensed here. However, if You fail to comply with
this Public License, then Your rights under this Public License
terminate automatically.
b. Where Your right to use the Licensed Material has terminated under
Section 6(a), it reinstates:
1. automatically as of the date the violation is cured, provided
it is cured within 30 days of Your discovery of the
violation; or
2. upon express reinstatement by the Licensor.
For the avoidance of doubt, this Section 6(b) does not affect any
right the Licensor may have to seek remedies for Your violations
of this Public License.
c. For the avoidance of doubt, the Licensor may also offer the
Licensed Material under separate terms or conditions or stop
distributing the Licensed Material at any time; however, doing so
will not terminate this Public License.
d. Sections 1, 5, 6, 7, and 8 survive termination of this Public
License.
Section 7 -- Other Terms and Conditions.
a. The Licensor shall not be bound by any additional or different
terms or conditions communicated by You unless expressly agreed.
b. Any arrangements, understandings, or agreements regarding the
Licensed Material not stated herein are separate from and
independent of the terms and conditions of this Public License.
Section 8 -- Interpretation.
a. For the avoidance of doubt, this Public License does not, and
shall not be interpreted to, reduce, limit, restrict, or impose
conditions on any use of the Licensed Material that could lawfully
be made without permission under this Public License.
b. To the extent possible, if any provision of this Public License is
deemed unenforceable, it shall be automatically reformed to the
minimum extent necessary to make it enforceable. If the provision
cannot be reformed, it shall be severed from this Public License
without affecting the enforceability of the remaining terms and
conditions.
c. No term or condition of this Public License will be waived and no
failure to comply consented to unless expressly agreed to by the
Licensor.
d. Nothing in this Public License constitutes or may be interpreted
as a limitation upon, or waiver of, any privileges and immunities
that apply to the Licensor or You, including from the legal
processes of any jurisdiction or authority.
=======================================================================
Creative Commons is not a party to its public
licenses. Notwithstanding, Creative Commons may elect to apply one of
its public licenses to material it publishes and in those instances
will be considered the “Licensor.” The text of the Creative Commons
public licenses is dedicated to the public domain under the CC0 Public
Domain Dedication. Except for the limited purpose of indicating that
material is shared under a Creative Commons public license or as
otherwise permitted by the Creative Commons policies published at
creativecommons.org/policies, Creative Commons does not authorize the
use of the trademark "Creative Commons" or any other trademark or logo
of Creative Commons without its prior written consent including,
without limitation, in connection with any unauthorized modifications
to any of its public licenses or any other arrangements,
understandings, or agreements concerning use of licensed material. For
the avoidance of doubt, this paragraph does not form part of the
public licenses.
Creative Commons may be contacted at creativecommons.org.

24
docs/Makefile Normal file
View File

@@ -0,0 +1,24 @@
# Minimal makefile for Sphinx documentation
#
# You can set these variables from the command line.
SPHINXOPTS = -W --keep-going
SPHINXBUILD = sphinx-build
SOURCEDIR = source
LINTER = doc8
LINTEROPTS = --ignore D001 # D001 is linelength
BUILDDIR = build
# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
lint:
@$(LINTER) $(LINTEROPTS) $(SOURCEDIR)
.PHONY: help Makefile
# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

9
docs/README.MD Normal file
View File

@@ -0,0 +1,9 @@
# PhotonVision ReadTheDocs
[![Documentation Status](https://readthedocs.org/projects/photonvision-docs/badge/?version=latest)](https://docs.photonvision.org/en/latest/?badge=latest)
PhotonVision is a free open-source vision processing software for FRC teams.
This repository is the source code for our ReadTheDocs documentation, which can be found [here](https://docs.photonvision.org).
[Contribution and formatting guidelines for this project](https://docs.photonvision.org/en/latest/docs/contributing/index.html)

36
docs/make.bat Normal file
View File

@@ -0,0 +1,36 @@
@ECHO OFF
pushd %~dp0
REM Command file for Sphinx documentation
if "%SPHINXBUILD%" == "" (
set SPHINXBUILD=sphinx-build
)
set SOURCEDIR=source
set BUILDDIR=build
set SPHINXOPTS=-W --keep-going
if "%1" == "" goto help
%SPHINXBUILD% >NUL 2>NUL
if errorlevel 9009 (
echo.
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
echo.installed, then set the SPHINXBUILD environment variable to point
echo.to the full path of the 'sphinx-build' executable. Alternatively you
echo.may add the Sphinx directory to PATH.
echo.
echo.If you don't have Sphinx installed, grab it from
echo.http://sphinx-doc.org/
exit /b 1
)
%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS%
goto end
:help
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS%
:end
popd

44
docs/requirements.txt Normal file
View File

@@ -0,0 +1,44 @@
alabaster==0.7.13
Babel==2.13.1
beautifulsoup4==4.12.2
certifi==2023.11.17
charset-normalizer==3.3.2
colorama==0.4.6
doc8==0.11.2
docopt==0.6.2
docutils==0.18.1
furo==2023.9.10
idna==3.4
imagesize==1.4.1
Jinja2==3.0.3
MarkupSafe==2.1.3
packaging==23.2
pbr==6.0.0
pipreqs==0.4.13
Pygments==2.17.1
requests==2.31.0
restructuredtext-lint==1.4.0
six==1.16.0
snowballstemmer==2.2.0
soupsieve==2.5
Sphinx==7.2.6
sphinx-basic-ng==1.0.0b2
sphinx-notfound-page==1.0.0
sphinx-rtd-theme==1.3.0
sphinx-tabs==3.4.4
sphinx_design==0.5.0
sphinxcontrib-applehelp==1.0.7
sphinxcontrib-devhelp==1.0.5
sphinxcontrib-ghcontributors==0.2.3
sphinxcontrib-htmlhelp==2.0.4
sphinxcontrib-jquery==4.1
sphinxcontrib-jsmath==1.0.1
sphinxcontrib-qthelp==1.0.6
sphinxcontrib-serializinghtml==1.1.9
sphinxext-opengraph==0.9.0
sphinxext-remoteliteralinclude==0.4.0
stevedore==5.1.0
urllib3==2.1.0
yarg==0.1.9
sphinx-autobuild==2024.4.16
myst_parser==3.0.1

7
docs/source/404.md Normal file
View File

@@ -0,0 +1,7 @@
---
orphan: true
---
# Requested Page Not Found
This page you were looking for was not found. If you think this is a mistake, [file an issue on our GitHub.](https://github.com/PhotonVision/photonvision-docs/issues)

20
docs/source/Makefile Normal file
View File

@@ -0,0 +1,20 @@
# Minimal makefile for Sphinx documentation
#
# You can set these variables from the command line, and also
# from the environment for the first two.
SPHINXOPTS ?=
SPHINXBUILD ?= sphinx-build
SOURCEDIR = source
BUILDDIR = build
# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
.PHONY: help Makefile
# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 56 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 56 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,17 @@
/*!
* Font Awesome 4.7.0 by @davegandy - http://fontawesome.io - @fontawesome
* License - http://fontawesome.io/license (Font: SIL OFL 1.1, CSS: MIT License)
*/
@font-face {
font-family: FontAwesome;
src: url(fonts/fontawesome-webfont.eot?674f50d287a8c48dc19ba404d20fe713);
src: url(fonts/fontawesome-webfont.eot?674f50d287a8c48dc19ba404d20fe713?#iefix&v=4.7.0) format("embedded-opentype"), url(fonts/fontawesome-webfont.woff2?af7ae505a9eed503f8b8e6982036873e) format("woff2"), url(fonts/fontawesome-webfont.woff?fee66e712a8a08eef5805a46892932ad) format("woff"), url(fonts/fontawesome-webfont.ttf?b06871f281fee6b241d60582ae9369b9) format("truetype"), url(fonts/fontawesome-webfont.svg?912ec66d7572ff821749319396470bde#fontawesomeregular) format("svg");
font-weight: 400;
font-style:normal
}
.code-block-caption>.headerlink, dl dt>.headerlink, h1>.headerlink, h2>.headerlink, h3>.headerlink, h4>.headerlink, h5>.headerlink, h6>.headerlink, p.caption>.headerlink, table>caption>.headerlink {
font-family: FontAwesome;
font-size: 0.75em;
}

View File

@@ -0,0 +1,74 @@
{# Import the theme's layout. #}
{% extends '!layout.html' %}
{%- block extrahead %}
<script>
if (localStorage.getItem("colorTheme") === "dark") {
document.documentElement.setAttribute('data-theme', 'dark');
} else if (localStorage.getItem("colorTheme") === "light") {
document.documentElement.setAttribute('data-theme', 'light');
} else {
var userPrefersDark = window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches;
if (userPrefersDark) {
document.documentElement.setAttribute('data-theme', 'dark');
} else {
document.documentElement.setAttribute('data-theme', 'light');
}
}
</script>
{# Call the parent block #}
{{ super() }}
{% endblock %}
{%- block extrafooter %}
{# Add custom things to the head HTML tag #}
<div class="dark-mode-toggle-container">
<strong class="light-label md-icon">&#xE430</strong>
<div class="dark-mode-toggle">
<input type="checkbox" id="switch" name="theme"/><label class="toggle" for="switch">Toggle</label>
</div>
<strong class="dark-label md-icon">&#xE42D</strong>
</div>
<script>
var checkbox = document.querySelector('input[name=theme]');
var element = document.documentElement.getAttribute('data-theme');
if (element == 'dark') {
// Auto check the checkbox if the set theme is "dark".
checkbox.checked = true;
}
checkbox.addEventListener('change', function() {
if (this.checked) {
document.documentElement.setAttribute('data-theme', 'dark');
localStorage.setItem("colorTheme", "dark");
} else {
document.documentElement.setAttribute('data-theme', 'light');
localStorage.setItem("colorTheme", "light");
}
});
window.matchMedia('(prefers-color-scheme: dark)')
.addEventListener('change', event => {
if (event.matches) {
document.documentElement.setAttribute('data-theme', 'dark');
localStorage.setItem("colorTheme", "dark");
checkbox.checked = true;
} else {
document.documentElement.setAttribute('data-theme', 'light');
localStorage.setItem("colorTheme", "light");
checkbox.checked = false;
}
});
</script>
{# Call the parent block #}
{{ super() }}
{%- endblock %}

Binary file not shown.

After

Width:  |  Height:  |  Size: 56 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 56 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 46 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

153
docs/source/conf.py Normal file
View File

@@ -0,0 +1,153 @@
# Configuration file for the Sphinx documentation builder.
#
# This file only contains a selection of the most common options. For a full
# list see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html
# -- Path setup --------------------------------------------------------------
# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#
import os
# import sys
# sys.path.insert(0, os.path.abspath('.'))
# -- Project information -----------------------------------------------------
project = "PhotonVision"
copyright = "2024, PhotonVision"
author = "Banks Troutman, Matt Morley"
# -- General configuration ---------------------------------------------------
# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
"sphinx_rtd_theme",
"sphinx.ext.autosectionlabel",
"sphinx.ext.todo",
"sphinx_tabs.tabs",
"notfound.extension",
"sphinxext.remoteliteralinclude",
"sphinxext.opengraph",
"sphinxcontrib.ghcontributors",
"sphinx_design",
"myst_parser",
"sphinx.ext.mathjax",
"sphinx.ext.graphviz",
]
# Configure OpenGraph support
ogp_site_url = "https://docs.photonvision.org/en/latest/"
ogp_site_name = "PhotonVision Documentation"
ogp_image = "https://raw.githubusercontent.com/PhotonVision/photonvision-docs/main/source/assets/RectLogo.png"
# Add any paths that contain templates here, relative to this directory.
templates_path = ["_templates"]
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This pattern also affects html_static_path and html_extra_path.
exclude_patterns = []
# Enable hover content on glossary term
hoverxref_roles = ["term"]
# Autosection labels prefix document path and filename
autosectionlabel_prefix_document = True
# -- Options for HTML output -------------------------------------------------
html_title = "PhotonVision Docs"
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
html_theme = "furo"
html_favicon = "assets/RoundLogo.png"
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ["_static"]
source_suffix = [".rst", ".md"]
def setup(app):
app.add_css_file("css/pv-icons.css")
pygments_style = "sphinx"
html_theme_options = {
"sidebar_hide_name": True,
"light_logo": "assets/PhotonVision-Header-onWhite.png",
"dark_logo": "assets/PhotonVision-Header-noBG.png",
"light_css_variables": {
"font-stack": "-apple-system, BlinkMacSystemFont, avenir next, avenir, segoe ui, helvetica neue, helvetica, Ubuntu, roboto, noto, arial, sans-serif;",
"admonition-font-size": "1rem",
"admonition-title-font-size": "1rem",
"color-background-primary": "#ffffff",
"color-background-secondary": "#f7f7f7",
"color-background-hover": "#efeff400",
"color-background-hover--transparent": "#efeff400",
"color-brand-primary": "#006492",
"color-brand-content": "#006492",
"color-foreground-primary": "#2d2d2d",
"color-foreground-secondary": "#39a4d5",
"color-foreground-muted": "#2d2d2d",
"color-foreground-border": "#ffffff",
"color-background-border": "ffffff",
"color-api-overall": "#101010",
},
"dark_css_variables": {
"color-background-primary": "#242c37",
"color-background-secondary": "#006492",
"color-background-hover": "#efeff400",
"color-background-hover--transparent": "#efeff400",
"color-brand-primary": "#ffd843",
"color-brand-secondary": "#39a4d5",
"color-brand-content": "#ffd843",
"color-foreground-primary": "#ffffff",
"color-foreground-secondary": "#ffffff",
"color-foreground-muted": "#ffffff",
"color-foreground-border": "transparent",
"color-background-border": "transparent",
"color-api-overall": "#101010",
"color-inline-code-background": "#0d0d0d",
},
"footer_icons": [
{
"name": "GitHub",
"url": "https://github.com/photonvision/photonvision",
"html": """
<svg stroke="currentColor" fill="currentColor" stroke-width="0" viewBox="0 0 16 16">
<path fill-rule="evenodd" d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0 0 16 8c0-4.42-3.58-8-8-8z"></path>
</svg>
""",
"class": "",
},
],
}
suppress_warnings = ["epub.unknown_project_files"]
sphinx_tabs_valid_builders = ["epub", "linkcheck"]
# -- Options for linkcheck -------------------------------------------------
# Excluded links for linkcheck
# These should be periodically checked by hand to ensure that they are still functional
linkcheck_ignore = [R"https://www.raspberrypi.com/software/", R"http://10\..+"]
token = os.environ.get("GITHUB_TOKEN", None)
if token:
linkcheck_auth = [(R"https://github.com/.+", token)]
# MyST configuration (https://myst-parser.readthedocs.io/en/latest/configuration.html)
myst_enable_extensions = ["colon_fence"]

View File

@@ -0,0 +1,33 @@
# Best Practices For Competition
## Before Competition
- Ensure you have spares of the relevant electronics if you can afford it (switch, coprocessor, cameras, etc.).
- Stay on the latest version of PhotonVision until you have tested your full robot system to be functional.
- Some time before the competition, lock down the version you are using and do not upgrade unless you encounter a critical bug.
- Have a copy of the installation image for the version you are using on your programming laptop, in case re-imaging (without internet) is needed.
- Extensively test at your home setup. Practice tuning from scratch under different lighting conditions.
- Use SmartDashboard / Shuffleboard to view your camera streams during practice.
- Confirm you have followed all the recommendations under the Networking section in installation (network switch and static IP).
- Only use high quality ethernet cables that have been rigorously tested.
- Set up RIO USB port forwarding using the guide in the Networking section in installation.
## During the Competition
- Use the field calibration time given at the start of the event:
- Bring your robot to the field at the allotted time.
- Make sure the field has match-accurate lighting conditions active.
- Turn on your robot and pull up the dashboard on your driver station.
- Point your robot at the targets and ensure you get a consistent tracking (you hold one targets consistently, the ceiling lights aren't detected, etc.).
- If you have problems with your pipeline, go to the pipeline tuning section and retune the pipeline using the guide there.
- Move the robot close, far, angled, and around the field to ensure no extra targets are found.
- Monitor camera feeds during a practice match to ensure everything is working correctly.
- After field calibration, use the "Export Settings" button in the "Settings" page to create a backup.
- Do this for each coprocessor on your robot that runs PhotonVision, and name your exports with meaningful names.
- This will contain camera information/calibration, pipeline information, network settings, etc.
- In the event of software/hardware failures (IE lost SD Card, broken device), you can then use the "Import Settings" button and select "All Settings" to restore your settings.
- This effectively works as a snapshot of your PhotonVision data that can be restored at any point.
- Before every match:
- Check the ethernet and USB connectors are seated fully.
- Close streaming dashboards when you don't need them to reduce bandwidth.
- Stream at as low of a resolution as possible while still detecting AprilTags to stay within field bandwidth limits.

View File

@@ -0,0 +1,53 @@
# Filesystem Directory
PhotonVision stores and loads settings in the {code}`photonvision_config` directory, in the same folder as the PhotonVision JAR is stored. On supported hardware, this is in the {code}`/opt/photonvision` directory. The contents of this directory can be exported as a zip archive from the settings page of the interface, under "export settings". This export will contain everything detailed below. These settings can later be uploaded using "import settings", to restore configurations from previous backups.
## Directory Structure
The directory structure is outlined below.
```{image} images/configDir.png
:alt: Config directory structure
:width: 600
```
- calibImgs
- Images saved from the last run of the calibration routine
- cameras
- Contains a subfolder for each camera. This folder contains the following files:
- pipelines folder, which contains a {code}`json` file for each user-created pipeline.
- config.json, which contains all camera-specific configuration. This includes FOV, pitch, current pipeline index, and calibration data
- drivermode.json, which contains settings for the driver mode pipeline
- imgSaves
- Contains images saved with the input/output save commands.
- logs
- Contains timestamped logs in the format {code}`photonvision-YYYY-MM-D_HH-MM-SS.log`. These timestamps will likely be significantly behind the real time. Coprocessors on the robot have no way to get current time.
- hardwareSettings.json
- Contains hardware settings. Currently this includes only the LED brightness.
- networkSettings.json
- Contains network settings, including team number (or remote network tables address), static/dynamic settings, and hostname.
## Importing and Exporting Settings
The entire settings directory can be exported as a ZIP archive from the settings page.
```{raw} html
<video width="85%" controls>
<source src="../../_static/assets/import-export-settings.mp4" type="video/mp4">
Your browser does not support the video tag.
</video>
```
A variety of files can be imported back into PhotonVision:
- ZIP Archive ({code}`.zip`)
- Useful for restoring a full configuration from a different PhotonVision instance.
- Single Config File
- Currently-supported Files
- {code}`hardwareConfig.json`
- {code}`hardwareSettings.json`
- {code}`networkSettings.json`
- Useful for simple hardware or network configuration tasks without overwriting all settings.

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

View File

@@ -0,0 +1,70 @@
# NetworkTables API
## About
:::{warning}
PhotonVision interfaces with PhotonLib, our vendor dependency, using NetworkTables. If you are running PhotonVision on a robot (ie. with a RoboRIO), you should **turn the NetworkTables server switch (in the settings tab) off** in order to get PhotonLib to work. Also ensure that you set your team number. The NetworkTables server should only be enabled if you know what you're doing!
:::
## API
:::{warning}
NetworkTables is not a supported setup/viable option when using PhotonVision as we only send one target at a time (this is problematic when using AprilTags, which will return data from multiple tags at once). We recommend using PhotonLib.
:::
The tables below contain the the name of the key for each entry that PhotonVision sends over the network and a short description of the key. The entries should be extracted from a subtable with your camera's nickname (visible in the PhotonVision UI) under the main `photonvision` table.
### Getting Target Information
| Key | Type | Description |
| --------------- | ---------- | ------------------------------------------------------------------------ |
| `rawBytes` | `byte[]` | A byte-packed string that contains target info from the same timestamp. |
| `latencyMillis` | `double` | The latency of the pipeline in milliseconds. |
| `hasTarget` | `boolean` | Whether the pipeline is detecting targets or not. |
| `targetPitch` | `double` | The pitch of the target in degrees (positive up). |
| `targetYaw` | `double` | The yaw of the target in degrees (positive right). |
| `targetArea` | `double` | The area (percent of bounding box in screen) as a percent (0-100). |
| `targetSkew` | `double` | The skew of the target in degrees (counter-clockwise positive). |
| `targetPose` | `double[]` | The pose of the target relative to the robot (x, y, z, qw, qx, qy, qz) |
| `targetPixelsX` | `double` | The target crosshair location horizontally, in pixels (origin top-right) |
| `targetPixelsY` | `double` | The target crosshair location vertically, in pixels (origin top-right) |
### Changing Settings
| Key | Type | Description |
| --------------- | --------- | --------------------------- |
| `pipelineIndex` | `int` | Changes the pipeline index. |
| `driverMode` | `boolean` | Toggles driver mode. |
### Saving Images
PhotonVision can save images to file on command. The image is saved when PhotonVision detects the command went from `false` to `true`.
PhotonVision will automatically set these back to `false` after 500ms.
Be careful saving images rapidly - it will slow vision processing performance and take up disk space very quickly.
Images are returned as part of the .zip package from the "Export" operation in the Settings tab.
| Key | Type | Description |
| ------------------ | --------- | ------------------------------------------------- |
| `inputSaveImgCmd` | `boolean` | Triggers saving the current input image to file. |
| `outputSaveImgCmd` | `boolean` | Triggers saving the current output image to file. |
:::{warning}
If you manage to make calls to these commands faster than 500ms (between calls), additional photos will not be captured.
:::
### Global Entries
These entries are global, meaning that they should be called on the main `photonvision` table.
| Key | Type | Description |
| --------- | ----- | -------------------------------------------------------- |
| `ledMode` | `int` | Sets the LED Mode (-1: default, 0: off, 1: on, 2: blink) |
:::{warning}
Setting the LED mode to -1 (default) when `multiple` cameras are connected may result in unexpected behavior. {ref}`This is a known limitation of PhotonVision. <docs/troubleshooting/common-errors:LED Control>`
Single camera operation should work without issue.
:::

Binary file not shown.

After

Width:  |  Height:  |  Size: 81 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 139 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 122 KiB

View File

@@ -0,0 +1,18 @@
# Advanced Installation
This page will help you install PhotonVision on non-supported coprocessor.
## Step 1: Software Install
This section will walk you through how to install PhotonVision on your coprocessor. Your coprocessor is the device that has the camera and you are using to detect targets (ex. if you are using a Limelight / Raspberry Pi, that is your coprocessor and you should follow those instructions).
:::{warning}
You only need to install PhotonVision on the coprocessor/device that is being used to detect targets, you do NOT need to install it on the device you use to view the webdashboard. All you need to view the webdashboard is for a device to be on the same network as your vision coprocessor and an internet browser.
:::
```{toctree}
:maxdepth: 3
sw_install/index
prerelease-software
```

View File

@@ -0,0 +1,23 @@
# Installing Pre-Release Versions
Pre-release/development version of PhotonVision can be tested by installing/downloading artifacts from Github Actions (see below), which are built automatically on commits to open pull requests and to PhotonVision's `main` branch, or by {ref}`compiling PhotonVision locally <docs/contributing/building-photon:Build Instructions>`.
:::{warning}
If testing a pre-release version of PhotonVision with a robot, PhotonLib must be updated to match the version downloaded! If not, packet schema definitions may not match and unexpected things will occur. To update PhotonLib, refer to {ref}`installing specific version of PhotonLib<docs/programming/photonlib/adding-vendordep:Install Specific Version - Java/C++>`.
:::
GitHub Actions builds pre-release version of PhotonVision automatically on PRs and on each commit merged to main. To test a particular commit to main, navigate to the [PhotonVision commit list](https://github.com/PhotonVision/photonvision/commits/main/) and click on the check mark (below). Scroll to "Build / Build fat JAR - PLATFORM", click details, and then summary. From here, JAR and image files can be downloaded to be flashed or uploaded using "Offline Update".
```{image} images/gh_actions_1.png
:alt: Github Actions Badge
```
```{image} images/gh_actions_2.png
:alt: Github Actions artifact list
```
Built JAR files (but not image files) can also be downloaded from PRs before they are merged. Navigate to the PR in GitHub, and select Checks at the top. Click on "Build" to display the same artifact list as above.
```{image} images/gh_actions_3.png
:alt: Github Actions artifacts from PR
```

View File

@@ -0,0 +1,56 @@
# Advanced Command Line Usage
PhotonVision exposes some command line options which may be useful for customizing execution on Debian-based installations.
## Running a JAR File
Assuming `java` has been installed, and the appropriate environment variables have been set upon installation (a package manager like `apt` should automatically set these), you can use `java -jar` to run a JAR file. If you downloaded the latest stable JAR of PhotonVision from the [GitHub releases page](https://github.com/PhotonVision/photonvision/releases), you can run the following to start the program:
```bash
java -jar /path/to/photonvision/photonvision.jar
```
## Updating a JAR File
When you need to update your JAR file, run the following:
```bash
wget https://git.io/JqkQ9 -O update.sh
sudo chmod +x update.sh
sudo ./update.sh
sudo reboot now
```
## Creating a `systemd` Service
You can also create a systemd service that will automatically run on startup. To do so, first navigate to `/lib/systemd/system`. Create a file called `photonvision.service` (or name it whatever you want) using `touch photonvision.service`. Then open this file in the editor of your choice and paste the following text:
```
[Unit]
Description=Service that runs PhotonVision
[Service]
WorkingDirectory=/path/to/photonvision
# Optional: run photonvision at "nice" -10, which is higher priority than standard
# Nice=-10
ExecStart=/usr/bin/java -jar /path/to/photonvision/photonvision.jar
[Install]
WantedBy=multi-user.target
```
Then copy the `.service` file to `/etc/systemd/system/` using `cp photonvision.service /etc/systemd/system/photonvision.service`. Then modify the file to have `644` permissions using `chmod 644 /etc/systemd/system/photonvision.service`.
:::{note}
Many ARM processors have a big.LITTLE architecture where some of the CPU cores are more powerful than others. On this type of architecture, you may get more consistent performance by limiting which cores PhotonVision can use. To do this, add the parameter `AllowedCPUs` to the systemd service file in the `[Service]` section.
For instance, for an Orange Pi 5, cores 4 through 7 are the fast ones, and you can target those cores with the line `AllowedCPUs=4-7`.
:::
## Installing the `systemd` Service
To install the service, simply run `systemctl enable photonvision.service`.
:::{note}
It is recommended to reload configurations by running `systemctl daemon-reload`.
:::

View File

@@ -0,0 +1,9 @@
{
"deviceName" : "Limelight 2+",
"supportURL" : "https://limelightvision.io",
"ledPins" : [ 13, 18 ],
"ledsCanDim" : true,
"ledPWMRange" : [ 0, 100 ],
"ledPWMFrequency" : 30000,
"vendorFOV" : 75.76079874010732
}

View File

@@ -0,0 +1,7 @@
{
"deviceName" : "Limelight 2",
"supportURL" : "https://limelightvision.io",
"ledPins" : [ 17, 18 ],
"ledsCanDim" : false,
"vendorFOV" : 75.76079874010732
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 115 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

View File

@@ -0,0 +1,21 @@
# Software Installation
## Desktop Environments
```{toctree}
:maxdepth: 1
windows-pc
linux-pc
mac-os
```
## Other
```{toctree}
:maxdepth: 1
other-coprocessors
advanced-cmd
romi
```

View File

@@ -0,0 +1,47 @@
# Linux PC Installation
PhotonVision may be run on a Debian-based Linux Desktop PC for basic testing and evaluation.
:::{note}
You do not need to install PhotonVision on a Windows PC in order to access the webdashboard (assuming you are using an external coprocessor like a Raspberry Pi).
:::
## Installing Java
PhotonVision requires a JDK installed and on the system path. JDK 17 is needed (different versions will not work). If you don't have JDK 17 already, run the following to install it:
```
$ sudo apt-get install openjdk-17-jdk
```
:::{warning}
Using a JDK other than JDK17 will cause issues when running PhotonVision and is not supported.
:::
## Downloading the Latest Stable Release of PhotonVision
Go to the [GitHub releases page](https://github.com/PhotonVision/photonvision/releases) and download the relevant .jar file for your coprocessor.
:::{note}
If your coprocessor has a 64 bit ARM based CPU architecture (OrangePi, Raspberry Pi, etc.), download the LinuxArm64.jar file.
If your coprocessor has an 64 bit x86 based CPU architecture (Mini PC, laptop, etc.), download the Linuxx64.jar file.
:::
:::{warning}
Be careful to pick the latest stable release. "Draft" or "Pre-Release" versions are not stable and often have bugs.
:::
## Running PhotonVision
To run PhotonVision, open a terminal window of your choice and run the following command:
```
$ java -jar /path/to/photonvision/photonvision-xxx.jar
```
If your computer has a compatible webcam connected, PhotonVision should startup without any error messages. If there are error messages, your webcam isn't supported or another issue has occurred. If it is the latter, please open an issue on the [PhotonVision issues page](https://github.com/PhotonVision/photonvision/issues).
## Accessing the PhotonVision Interface
Once the Java backend is up and running, you can access the main vision interface by navigating to `localhost:5800` inside your browser.

View File

@@ -0,0 +1,53 @@
# Mac OS Installation
:::{warning}
Due to current [cscore](https://github.com/wpilibsuite/allwpilib/tree/main/cscore) restrictions, the PhotonVision server backend may have issues running macOS.
:::
:::{note}
You do not need to install PhotonVision on a Mac in order to access the webdashboard (assuming you are using an external coprocessor like a Raspberry Pi).
:::
VERY Limited macOS support is available.
## Installing Java
PhotonVision requires a JDK installed and on the system path. JDK 17 is needed (different versions will not work). You may already have this if you have installed WPILib 2025+. If not, [download and install it from here](https://adoptium.net/temurin/releases?version=17).
:::{warning}
Using a JDK other than JDK17 will cause issues when running PhotonVision and is not supported.
:::
## Downloading the Latest Stable Release of PhotonVision
Go to the [GitHub releases page](https://github.com/PhotonVision/photonvision/releases) and download the relevant .jar file for your coprocessor.
:::{note}
If you have an M1/M2 Mac, download the macarm64.jar file.
If you have an Intel based Mac, download the macx64.jar file.
:::
:::{warning}
Be careful to pick the latest stable release. "Draft" or "Pre-Release" versions are not stable and often have bugs.
:::
## Running PhotonVision
To run PhotonVision, open a terminal window of your choice and run the following command:
```
$ java -jar /path/to/photonvision/photonvision-xxx.jar
```
:::{warning}
Due to current [cscore](https://github.com/wpilibsuite/allwpilib/tree/main/cscore) restrictions, the PhotonVision using test mode is all that is known to work currently.
:::
## Accessing the PhotonVision Interface
Once the Java backend is up and running, you can access the main vision interface by navigating to `localhost:5800` inside your browser.
:::{warning}
Due to current [cscore](https://github.com/wpilibsuite/allwpilib/tree/main/cscore) restrictions, it is unlikely any streams will open from real webcams.
:::

View File

@@ -0,0 +1,39 @@
# Other Debian-Based Co-Processor Installation
:::{warning}
Working with unsupported coprocessors requires some level of "know how" of your system. The install script has only been tested on Debian/Raspberry Pi OS Buster and Ubuntu Bionic. If any issues arise with your specific OS, please open an issue on our [issues page](https://github.com/PhotonVision/photonvision/issues).
:::
:::{note}
We'd love to have your input! If you get PhotonVision working on another coprocessor, consider documenting your steps and submitting a [docs issue](https://github.com/PhotonVision/photonvision-docs/issues)., [pull request](https://github.com/PhotonVision/photonvision-docs/pulls) , or [ping us on Discord](https://discord.com/invite/wYxTwym). For example, Limelight and Romi install instructions came about because someone spent the time to figure it out, and did a writeup.
:::
## Installing PhotonVision
We provide an [install script](https://git.io/JJrEP) for other Debian-based systems (with `apt`) that will automatically install PhotonVision and make sure that it runs on startup.
```bash
$ wget https://git.io/JJrEP -O install.sh
$ sudo chmod +x install.sh
$ sudo ./install.sh
$ sudo reboot now
```
:::{note}
Your co-processor will require an Internet connection for this process to work correctly.
:::
For installation on any other co-processors, we recommend reading the {ref}`advanced command line documentation <docs/advanced-installation/sw_install/advanced-cmd:Advanced Command Line Usage>`.
## Updating PhotonVision
PhotonVision can be updated by downloading the latest jar file, copying it onto the processor, and restarting the service.
For example, from another computer, run the following commands. Substitute the correct username for "\[user\]" ( Provided images use username "pi")
```bash
$ scp [jar name].jar [user]@photonvision.local:~/
$ ssh [user]@photonvision.local
$ sudo mv [jar name].jar /opt/photonvision/photonvision.jar
$ sudo systemctl restart photonvision.service
```

View File

@@ -0,0 +1,43 @@
# Romi Installation
The [Romi](https://docs.wpilib.org/en/latest/docs/romi-robot/index.html) is a small robot that can be controlled with the WPILib software. The main controller is a Raspberry Pi that must be imaged with [WPILibPi](https://docs.wpilib.org/en/latest/docs/romi-robot/imaging-romi.html) .
## Installation
The WPILibPi image includes FRCVision, which reserves USB cameras; to use PhotonVision, we need to edit the `/home/pi/runCamera` script to disable it. First we will need to make the file system writeable; the easiest way to do this is to go to `10.0.0.2` and choose "Writable" at the top.
SSH into the Raspberry Pi (using Windows command line, or a tool like [Putty](https://www.chiark.greenend.org.uk/~sgtatham/putty/) ) at the Romi's default address `10.0.0.2`. The default user is `pi`, and the password is `raspberry`.
:::.. The following paragraph can be restored when WPILibPi becomes compatible with the current version of PhotonVision.
:::.. Follow the process for installing PhotonVision on {ref}`"Other Debian-Based Co-Processor Installation" <docs/advanced-installation/sw_install/other-coprocessors:Other Debian-Based Co-Processor Installation>`. As it mentions, this will require an internet connection so connecting the Raspberry Pi to an internet-connected router via an Ethernet cable will be the easiest solution. The pi must remain writable while you are following these steps!
:::..Temporary instructions explaining how to install the older version of PhotonVision on a Romi. Remove when no longer needed.
:::{attention}
The version of WPILibPi for the Romi is 2023.2.1, which is not compatible with the current version of PhotonVision. **If you are using WPILibPi 2023.2.1 on your Romi, you must install PhotonVision v2023.4.2 or earlier!**
To install a compatible version of PhotonVision, enter these commands in the SSH terminal connected to the Raspberry Pi. This will download and run the install script, which will intall PhotonVision on your Raspberry Pi and configure it to run at startup.
```bash
$ wget https://git.io/JJrEP -O install.sh
$ sudo chmod +x install.sh
$ sudo ./install.sh -v 2023.4.2
```
The install script requires an internet connection, so connecting the Raspberry Pi to an internet-connected router via an Ethernet cable will be the easiest solution. The pi must remain writable while you are following these steps!
:::
:::..End of temporary instructions.
Next, from the SSH terminal, run `sudo nano /home/pi/runCamera` then arrow down to the start of the exec line and press "Enter" to add a new line. Then add `#` before the exec command to comment it out. Then, arrow up to the new line and type `sleep 10000`. Hit "Ctrl + O" and then "Enter" to save the file. Finally press "Ctrl + X" to exit nano. Now, reboot the Romi by typing `sudo reboot now`.
```{image} images/nano.png
```
After the Romi reboots, you should be able to open the PhotonVision UI at: [`http://10.0.0.2:5800/`](http://10.0.0.2:5800/). From here, you can adjust settings and configure {ref}`Pipelines <docs/pipelines/index:Pipelines>`.
:::{warning}
In order for settings, logs, etc. to be saved / take effect, ensure that PhotonVision is in writable mode.
:::
:::{attention}
When using an older version of PhotonVision, the user interface and features may be different than what appears in the online documentation. The [Documentation](http://10.0.0.2:5800/#/docs) link in the User Interface will open a bundled version of the documentation that matches the PhotonVision version running on your coprocessor.
:::

View File

@@ -0,0 +1,45 @@
# Windows PC Installation
PhotonVision may be run on a Windows Desktop PC for basic testing and evaluation.
:::{note}
You do not need to install PhotonVision on a Windows PC in order to access the webdashboard (assuming you are using an external coprocessor like a Raspberry Pi).
:::
## Install Bonjour
Bonjour provides more stable networking when using Windows PCs. Install [Bonjour here](https://support.apple.com/downloads/DL999/en_US/BonjourPSSetup.exe) before continuing to ensure a stable experience while using PhotonVision.
## Installing Java
PhotonVision requires a JDK installed and on the system path. **JDK 17 is needed. Windows Users must use the JDK that ships with WPILib.** [Download and install it from here.](https://github.com/wpilibsuite/allwpilib/releases/tag/v2025.2.1) Either ensure the only Java on your PATH is the WPILIB Java or specify it to gradle with `-Dorg.gradle.java.home=C:\Users\Public\wpilib\2025\jdk`:
```
> ./gradlew run "-Dorg.gradle.java.home=C:\Users\Public\wpilib\2025\jdk"
```
:::{warning}
Using a JDK other than WPILIB's JDK17 will cause issues when running PhotonVision and is not supported.
:::
## Downloading the Latest Stable Release of PhotonVision
Go to the [GitHub releases page](https://github.com/PhotonVision/photonvision/releases) and download the winx64.jar file.
## Running PhotonVision
To run PhotonVision, open a terminal window of your choice and run the following command:
```
> java -jar C:\path\to\photonvision\NAME OF JAR FILE GOES HERE.jar
```
If your computer has a compatible webcam connected, PhotonVision should startup without any error messages. If there are error messages, your webcam isn't supported or another issue has occurred. If it is the latter, please open an issue on the [PhotonVision issues page](https://github.com/PhotonVision/photonvision/issues).
:::{warning}
Using an integrated laptop camera may cause issues when trying to run PhotonVision. If you are unable to run PhotonVision on a laptop with an integrated camera, try disabling the camera's driver in Windows Device Manager.
:::
## Accessing the PhotonVision Interface
Once the Java backend is up and running, you can access the main vision interface by navigating to `localhost:5800` inside your browser.

View File

@@ -0,0 +1,56 @@
# 2D AprilTag Tuning / Tracking
## Tracking AprilTags
Before you get started tracking AprilTags, ensure that you have followed the previous sections on installation, wiring and networking. Next, open the Web UI, go to the top right card, and switch to the "AprilTag" or "Aruco" type. You should see a screen similar to the one below.
```{image} images/apriltag.png
:align: center
```
You are now able to detect and track AprilTags in 2D (yaw, pitch, roll, etc.). In order to get 3D data from your AprilTags, please see {ref}`here. <docs/apriltag-pipelines/3D-tracking:3D Tracking>`
## Tuning AprilTags
AprilTag pipelines come with reasonable defaults to get you up and running with tracking. However, in order to optimize your performance and accuracy, you must tune your AprilTag pipeline using the settings below. Note that the settings below are different between the AprilTag and Aruco detectors but the concepts are the same.
```{image} images/apriltag-tune.png
:align: center
:scale: 45 %
```
### Target Family
Target families are defined by two numbers (before and after the h). The first number is the number of bits the tag is able to encode (which means more tags are available in the respective family) and the second is the hamming distance. Hamming distance describes the ability for error correction while identifying tag ids. A high hamming distance generally means that it will be easier for a tag to be identified even if there are errors. However, as hamming distance increases, the number of available tags decreases.
The 2025 FRC game will be using 36h11 tags, which can be found [here](https://github.com/AprilRobotics/apriltag-imgs/tree/main/tag36h11).
### Decimate
Decimation (also known as down-sampling) is the process of reducing the sampling frequency of a signal (in our case, the image). Increasing decimate will lead to an increased detection rate while decreasing detection distance. We recommend keeping this at the default value.
### Blur
This controls the sigma of Gaussian blur for tag detection. In clearer terms, increasing blur will make the image blurrier, decreasing it will make it closer to the original image. We strongly recommend that you keep blur to a minimum (0) due to it's high performance intensity unless you have an extremely noisy image.
### Threads
Threads refers to the threads within your coprocessor's CPU. The theoretical maximum is device dependent, but we recommend that users to stick to one less than the amount of CPU threads that your coprocessor has. Increasing threads will increase performance at the cost of increased CPU load, temperature increase, etc. It may take some experimentation to find the most optimal value for your system.
### Refine Edges
The edges of the each polygon are adjusted to "snap to" high color differences surrounding it. It is recommended to use this in tandem with decimate as it can increase the quality of the initial estimate.
### Pose Iterations
Pose iterations represents the amount of iterations done in order for the AprilTag algorithm to converge on its pose solution(s). A smaller number between 0-100 is recommended. A smaller amount of iterations cause a more noisy set of poses when looking at the tag straight on, while higher values much more consistently stick to a (potentially wrong) pair of poses. WPILib contains many useful filter classes in order to account for a noisy tag reading.
### Max Error Bits
Max error bits, also known as hamming distance, is the number of positions at which corresponding pieces of data / tag are different. Put more generally, this is the number of bits (think of these as squares in the tag) that need to be changed / corrected in the tag to correctly detect it. A higher value means that more tags will be detected while a lower value cuts out tags that could be "questionable" in terms of detection.
We recommend a value of 0 for the 16h5 and at most 3 for the 36h11 family.
### Decision Margin Cutoff
The decision margin cutoff is how much “margin” the detector has left before it rejects a tag; increasing this rejects poorer tags. We recommend you keep this value around a 30.

View File

@@ -0,0 +1,13 @@
# 3D Tracking
3D AprilTag tracking will allow you to track the real-world position and rotation of a tag relative to the camera's image sensor. This is useful for robot pose estimation and other applications like autonomous scoring. In order to use 3D tracking, you must first {ref}`calibrate your camera <docs/calibration/calibration:Calibrating Your Camera>`. Once you have, you need to enable 3D mode in the UI and you will now be able to get 3D pose information from the tag! For information on getting and using this information in your code, see {ref}`the programming reference. <docs/programming/index:Programming Reference>`.
## Ambiguity
Translating from 2D to 3D using data from the calibration and the four tag corners can lead to "pose ambiguity", where it appears that the AprilTag pose is flipping between two different poses. You can read more about this issue `here. <https://docs.wpilib.org/en/stable/docs/software/vision-processing/apriltag/apriltag-intro.html#d-to-3d-ambiguity>` Ambiguity is calculated as the ratio of reprojection errors between two pose solutions (if they exist), where reprojection error is the error corresponding to the image distance between where the apriltag's corners are detected vs where we expect to see them based on the tag's estimated camera relative pose.
There are a few steps you can take to resolve/mitigate this issue:
1. Mount cameras at oblique angles so it is less likely that the tag will be seen straight on.
2. Use the {ref}`MultiTag system <docs/apriltag-pipelines/multitag:MultiTag Localization>` in order to combine the corners from multiple tags to get a more accurate and unambiguous pose.
3. Reject all tag poses where the ambiguity ratio (available via PhotonLib) is greater than 0.2.

View File

@@ -0,0 +1,14 @@
# About AprilTags
```{image} images/pv-apriltag.png
:align: center
:scale: 20 %
```
AprilTags are a common type of visual fiducial marker. Visual fiducial markers are artificial landmarks added to a scene to allow "localization" (finding your current position) via images. In simpler terms, tags mark known points of reference that you can use to find your current location. They are similar to QR codes in which they encode information, however, they hold only a single number. By placing AprilTags in known locations around the field and detecting them using PhotonVision, you can easily get full field localization / pose estimation. Alternatively, you can use AprilTags the same way you used retroreflective tape, simply using them to turn to goal without any pose estimation.
A more technical explanation can be found in the [WPILib documentation](https://docs.wpilib.org/en/latest/docs/software/vision-processing/apriltag/apriltag-intro.html).
:::{note}
You can get FIRST's [official PDF of the targets used in 2025 here](https://firstfrc.blob.core.windows.net/frc2025/FieldAssets/Apriltag_Images_and_User_Guide.pdf).
:::

View File

@@ -0,0 +1,40 @@
# Coordinate Systems
## Field and Robot Coordinate Frame
PhotonVision follows the WPILib conventions for the robot and field coordinate systems, as defined [here](https://docs.wpilib.org/en/stable/docs/software/advanced-controls/geometry/coordinate-systems.html).
You define the camera to robot transform in the robot coordinate frame.
## Camera Coordinate Frame
OpenCV by default uses x-left/y-down/z-out for camera transforms. PhotonVision applies a base rotation to this transformation to make robot to tag transforms more in line with the WPILib coordinate system. The x, y, and z axes are also shown in red, green, and blue in the 3D mini-map and targeting overlay in the UI.
- The origin is the focal point of the camera lens
- The x-axis points out of the camera
- The y-axis points to the left
- The z-axis points upwards
```{image} images/camera-coord.png
:align: center
:scale: 45 %
```
```{image} images/multiple-tags.png
:align: center
:scale: 45 %
```
## AprilTag Coordinate Frame
The AprilTag coordinate system is defined as follows, relative to the center of the AprilTag itself, and when viewing the tag as a robot would. Again, PhotonVision changes this coordinate system to be more in line with WPILib. This means that a robot facing a tag head-on would see a robot-to-tag transform with a translation only in x, and a rotation of 180 degrees about z. The tag coordinate system is also shown with x/y/z in red/green/blue in the UI target overlay and mini-map.
- The origin is the center of the tag
- The x-axis is normal to the plane the tag is printed on, pointing outward from the visible side of the tag.
- The y-axis points to the right
- The z-axis points upwards
```{image} images/apriltag-coords.png
:align: center
:scale: 45 %
```

View File

@@ -0,0 +1,15 @@
# AprilTag Pipeline Types
PhotonVision offers two different AprilTag pipeline types based on different implementations of the underlying algorithm. Each one has its advantages / disadvantages, which are detailed below.
:::{note}
Note that both of these pipeline types detect AprilTag markers and are just two different algorithms for doing so.
:::
## AprilTag
The AprilTag pipeline type is based on the [AprilTag](https://april.eecs.umich.edu/software/apriltag.html) library from the University of Michigan and we recommend it for most use cases. It is (to our understanding) most accurate pipeline type, but is also ~2x slower than AruCo. This was the pipeline type used by teams in the 2023 season and is well tested.
## AruCo
The AruCo pipeline is based on the [AruCo](https://docs.opencv.org/4.8.0/d9/d6a/group__aruco.html) library implementation from OpenCV. It is ~2x higher fps and ~2x lower latency than the AprilTag pipeline type, but is less accurate. We recommend this pipeline type for teams that need to run at a higher framerate or have a lower powered device. This pipeline type was new for the 2024 season.

Binary file not shown.

After

Width:  |  Height:  |  Size: 55 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 51 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 99 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 74 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 105 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 427 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 451 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

View File

@@ -0,0 +1,10 @@
# AprilTag Detection
```{toctree}
about-apriltags
detector-types
2D-tracking-tuning
3D-tracking
multitag
coordinate-systems
```

View File

@@ -0,0 +1,65 @@
# MultiTag Localization
PhotonVision can combine AprilTag detections from multiple simultaneously observed AprilTags from a particular camera with information about where tags are expected to be located on the field to produce a better estimate of where the camera (and therefore robot) is located on the field. PhotonVision can calculate this multi-target result on your coprocessor, reducing CPU usage on your RoboRio. This result is sent over NetworkTables along with other detected targets as part of the `PhotonPipelineResult` provided by PhotonLib.
:::{warning}
MultiTag requires an accurate field layout JSON to be uploaded! Differences between this layout and the tags' physical location will drive error in the estimated pose output.
:::
## Enabling MultiTag
Ensure that your camera is calibrated and 3D mode is enabled. Navigate to the Output tab and enable "Do Multi-Target Estimation". This enables MultiTag to use the uploaded field layout JSON to calculate your camera's pose in the field. This 3D transform will be shown as an additional table in the "targets" tab, along with the IDs of AprilTags used to compute this transform.
```{image} images/multitag-ui.png
:alt: Multitarget enabled and running in the PhotonVision UI
:width: 600
```
:::{note}
By default, enabling multi-target will disable calculating camera-to-target transforms for each observed AprilTag target to increase performance; the X/Y/angle numbers shown in the target table of the UI are instead calculated using the tag's expected location (per the field layout JSON) and the field-to-camera transform calculated using MultiTag. If you additionally want the individual camera-to-target transform calculated using SolvePNP for each target, enable "Always Do Single-Target Estimation".
:::
This multi-target pose estimate can be accessed using PhotonLib. We suggest using {ref}`the PhotonPoseEstimator class <docs/programming/photonlib/robot-pose-estimator:AprilTags and PhotonPoseEstimator>` with the `MULTI_TAG_PNP_ON_COPROCESSOR` strategy to simplify code, but the transform can be directly accessed using `getMultiTagResult`/`MultiTagResult()` (Java/C++).
```{eval-rst}
.. tab-set-code::
.. code-block:: Java
var result = camera.getLatestResult();
if (result.getMultiTagResult().estimatedPose.isPresent) {
Transform3d fieldToCamera = result.getMultiTagResult().estimatedPose.best;
}
.. code-block:: C++
auto result = camera.GetLatestResult();
if (result.MultiTagResult().result.isPresent) {
frc::Transform3d fieldToCamera = result.MultiTagResult().result.best;
}
.. code-block:: Python
# Coming Soon!
```
:::{note}
The returned field to camera transform is a transform from the fixed field origin to the camera's coordinate system. This does not change based on alliance color, and by convention is on the BLUE ALLIANCE wall.
:::
## Updating the Field Layout
PhotonVision ships by default with the [2025 field layout JSON](https://github.com/wpilibsuite/allwpilib/blob/main/apriltag/src/main/native/resources/edu/wpi/first/apriltag/2025-reefscape.json). The layout can be inspected by navigating to the settings tab and scrolling down to the "AprilTag Field Layout" card, as shown below.
```{image} images/field-layout.png
:alt: The currently saved field layout in the Photon UI
:width: 600
```
An updated field layout can be uploaded by navigating to the "Device Control" card of the Settings tab and clicking "Import Settings". In the pop-up dialog, select the "AprilTag Layout" type and choose an updated layout JSON (in the same format as the WPILib field layout JSON linked above) using the paperclip icon, and select "Import Settings". The AprilTag layout in the "AprilTag Field Layout" card below should be updated to reflect the new layout.
:::{note}
Currently, there is no way to update this layout using PhotonLib, although this feature is under consideration.
:::

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 143 KiB

View File

@@ -0,0 +1,147 @@
# Calibrating Your Camera
:::{important}
In order to detect AprilTags and use 3D mode, your camera must be calibrated at the desired resolution! Inaccurate calibration will lead to poor performance.
:::
To calibrate a camera, images of a Charuco board (or chessboard) are taken. By comparing where the grid corners should be in object space (for example, a corner once every inch in an 8x6 grid) with where they appear in the camera image, we can find a least-squares estimate for intrinsic camera properties like focal lengths, center point, and distortion coefficients. For more on camera calibration, please review the [OpenCV documentation](https://docs.opencv.org/4.x/dc/dbb/tutorial_py_calibration.html).
:::{warning}
While any resolution can be calibrated, higher resolutions may be too performance-intensive for some coprocessors to handle. Therefore, we recommend experimenting to see what works best for your coprocessor.
:::
:::{note}
The calibration data collected during calibration is specific to each physical camera, as well as each individual resolution.
:::
## Calibration Tips
Accurate camera calibration is required in order to get accurate pose measurements when using AprilTags and 3D mode. The tips below should help ensure success:
01. Ensure your the images you take have the target in different positions and angles, with as big of a difference between angles as possible. It is important to make sure the target overlay still lines up with the board while doing this. Tilt no more than 45 degrees.
02. Use as big of a calibration target as your printer can print.
03. Ensure that your printed pattern has enough white border around it.
04. Ensure your camera stays in one position during the duration of the calibration.
05. Make sure you get all 12 images from varying distances and angles.
06. Take at least one image that covers the total image area, and generally ensure that you get even coverage of the lens with your image set.
07. Have good lighting, having a diffusely lit target would be best (light specifically shining on the target without shadows).
08. Ensure the calibration target is completely flat and does not bend or fold in any way. It should be mounted/taped down to something flat and then used for calibration, do not just hold it up.
09. Avoid having targets that are parallel to the lens of the camera / straight on towards the camera as much as possible. You want angles and variations within your calibration images.
Following the ideas above should help in getting an accurate calibration.
## Calibrating using PhotonVision
### 1. Navigate to the calibration section in the UI.
The Cameras tab of the UI houses PhotonVision's camera calibration tooling. It assists users with calibrating their cameras, as well as allows them to view previously calibrated resolutions. We support both charuco and chessboard calibrations.
### 2. Print out the calibration target.
In the Camera Calibration tab, we'll print out the calibration target using the "Download" button. This should be printed on 8.5x11 printer paper. This page shows using an 8x8 charuco board (or chessboard depending on the selected calibration type).
:::{warning}
Ensure that there is no scaling applied during printing (it should be at 100%) and that the PDF is printed as is on regular printer paper. Check the square size with calipers or an accurate measuring device after printing to ensure squares are sized properly, and enter the true size of the square in the UI text box. For optimal results, various resources are available online to calibrate your specific printer if needed.
:::
### 3. Select calibration resolution and fill in appropriate target data.
We'll next select a resolution to calibrate and populate our pattern spacing, marker size, and board size. The provided chessboard and charuco board are an 8x8 grid of 1 inch square. The provided charuco board uses the 4x4 dictionary with a marker size of 0.75 inches (this board does not need the old OpenCV pattern selector selected). Printers are not perfect, and you need to measure your calibration target and enter the correct marker size (size of the aruco marker) and pattern spacing (aka size of the black square) using calipers or similar. Finally, once our entered data is correct, we'll click "start calibration."
:::{warning} Old OpenCV Pattern selector. This should be used in the case that the calibration image is generated from a version of OpenCV before version 4.6.0. This would include targets created by calib.io. If this selector is not set correctly the calibration will be completely invalid. For more info view [this GitHub issue](https://github.com/opencv/opencv_contrib/issues/3291).
:::
### 4. Take at calibration images from various angles.
Now, we'll capture images of our board from various angles. It's important to check that the board overlay matches the board in your image. The further the overdrawn points are from the true position of the chessboard corners, the less accurate the final calibration will be. We'll want to capture enough images to cover the whole camera's FOV (with a minimum of 12). Once we've got our images, we'll click "Finish calibration" and wait for the calibration process to complete. If all goes well, the mean error and FOVs will be shown in the table on the right. The FOV should be close to the camera's specified FOV (usually found in a datasheet) usually within + or - 10 degrees. The mean error should also be low, usually less than 1 pixel.
```{raw} html
<video width="85%" controls>
<source src="../../_static/assets/calibration_small.mp4" type="video/mp4">
Your browser does not support the video tag.
</video>
```
## Accessing Calibration Images
Details about a particular calibration can be viewed by clicking on that resolution in the calibrations tab. This tab allows you to download raw calibration data, upload a previous calibration, and inspect details about calculated camera intrinsic.
```{image} images/cal-details.png
:alt: Captured calibration images
:width: 600
```
:::{note}
More info on what these parameters mean can be found in [OpenCV's docs](https://docs.opencv.org/4.8.0/d4/d94/tutorial_camera_calibration.html)
:::
- Fx/Fy: Estimated camera focal length, in mm
- Fx/Cy: Estimated camera optical center, in pixels. This should be at about the center of the image
- Distortion: OpenCV camera model distortion coefficients
- FOV: calculated using estimated focal length and image size. Useful for gut-checking calibration results
- Mean Err: Mean reprojection error, or distance between expected and observed chessboard cameras for the full calibration dataset
Below these outputs are the snapshots collected for calibration, along with a per-snapshot mean reprojection error. A snapshot with a larger reprojection error might indicate a bad snapshot, due to effects such as motion blur or misidentified chessboard corners.
Calibration images can also be extracted from the downloaded JSON file using [this Python script](https://raw.githubusercontent.com/PhotonVision/photonvision/main/devTools/calibrationUtils.py). This script will unpack calibration images, and also generate a VNL file for use [with mrcal](https://mrcal.secretsauce.net/).
```
python3 /path/to/calibrationUtils.py path/to/photon_calibration.json /path/to/output/folder
```
```{image} images/unpacked-json.png
:alt: Captured calibration images
:width: 600
```
## Investigating Calibration Data with mrcal
[mrcal](https://mrcal.secretsauce.net/tour.html) is a command-line tool for camera calibration and visualization. PhotonVision has the option to use the mrcal backend during camera calibration to estimate intrinsics. mrcal can also be used post-calibration to inspect snapshots and provide feedback. These steps will closely follow the [mrcal tour](https://mrcal.secretsauce.net/tour-initial-calibration.html) -- I'm aggregating commands and notes here, but the mrcal documentation is much more thorough.
Start by [Installing mrcal](https://mrcal.secretsauce.net/install.html). Note that while mrcal *calibration* using PhotonVision is supported on all platforms, but investigation right now only works on Linux. Some users have also reported luck using [WSL 2 on Windows](https://learn.microsoft.com/en-us/windows/wsl/tutorials/gui-apps) as well. You may also need to install `feedgnuplot`. On Ubuntu systems, these commands should be run from a standalone terminal and *not* the one [built into vscode](https://github.com/ros2/ros2/issues/1406).
Let's run `calibrationUtils.py` as described above, and then cd into the output folder. From here, you can follow the mrcal tour, just replacing the VNL filename and camera imager size as necessary. My camera calibration was at 1280x720, so I've set the XY limits to that below.
```
$ cd /path/to/output/folder
$ ls
matt@photonvision:~/Documents/Downloads/2024-01-02_lifecam_1280$ ls
corners.vnl img0.png img10.png img11.png img12.png img13.png img1.png
img2.png img3.png img4.png img5.png img6.png img7.png img8.png
img9.png cameramodel_0.cameramodel
$ < corners.vnl \
vnl-filter -p x,y | \
feedgnuplot --domain --square --set 'xrange [0:1280] noextend' --set 'yrange [720:0] noextend'
```
```{image} images/mrcal-coverage.svg
:alt: A diagram showing the locations of all detected chessboard corners.
```
As you can see, we didn't do a fantastic job of covering our whole camera sensor -- there's a big gap across the whole right side, for example. We also only have 14 calibration images. We've also got our "cameramodel" file, which can be used by mrcal to display additional debug info.
Let's inspect our reprojection error residuals. We expect their magnitudes and directions to be random -- if there's patterns in the colors shown, then our calibration probably doesn't fully explain our physical camera sensor.
```
$ mrcal-show-residuals --magnitudes --set 'cbrange [0:1.5]' ./camera-0.cameramodel
$ mrcal-show-residuals --directions --unset key ./camera-0.cameramodel
```
```{image} images/residual-magnitudes.svg
:alt: A diagram showing residual magnitudes
```
```{image} images/residual-directions.svg
:alt: A diagram showing residual directions
```
Clearly we don't have anywhere near enough data to draw any meaningful conclusions (yet). But for fun, let's dig into [camera uncertainty estimation](https://mrcal.secretsauce.net/tour-uncertainty.html). This diagram shows how expected projection error changes due to noise in calibration inputs. Lower projection error across a larger area of the sensor imply a better calibration that more fully covers the whole sensor. For my calibration data, you can tell the projection error isolines (lines of constant expected projection error) are skewed to the left, following my dataset (which was also skewed left).
```
$ mrcal-show-projection-uncertainty --unset key ./cameramodel_0.cameramodel
```
```{image} images/camera-uncertainty.svg
:alt: A diagram showing camera uncertainty
```

Binary file not shown.

After

Width:  |  Height:  |  Size: 462 KiB

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 341 KiB

File diff suppressed because it is too large Load Diff

After

Width:  |  Height:  |  Size: 600 KiB

File diff suppressed because it is too large Load Diff

After

Width:  |  Height:  |  Size: 519 KiB

File diff suppressed because it is too large Load Diff

After

Width:  |  Height:  |  Size: 522 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 163 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 92 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 87 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 334 KiB

View File

@@ -0,0 +1,33 @@
# Building the PhotonVision Documentation
To build the PhotonVision documentation, you will require [Git](https://git-scm.com) and [Python 3.6 or greater](https://www.python.org).
## Cloning the Documentation Repository
Documentation lives within the main PhotonVision repository within the `docs` sub-folder. If you are planning on contributing, it is recommended to create a fork of the [PhotonVision repository](https://github.com/PhotonVision/photonvision). To clone this fork, run the following command in a terminal window:
`git clone https://github.com/[your username]/photonvision`
## Installing Python Dependencies
You must install a set of Python dependencies in order to build the documentation. To do so, you can run the following command in the docs sub-folder:
`~/photonvision/docs$ python -m pip install -r requirements.txt`
## Building the Documentation
In order to build the documentation, you can run the following command in the docs sub-folder. This will automatically build docs every time a file changes, and serves them locally at `localhost:8000` by default.
`~/photonvision/docs$ sphinx-autobuild --open-browser source source/_build/html`
## Opening the Documentation
The built documentation is located at `docs/build/html/index.html` relative to the root project directory, or can be accessed via the local web server if using sphinx-autobuild.
## Docs Builds on Pull Requests
Pre-merge builds of docs can be found at: `https://photonvision-docs--PRNUMBER.org.readthedocs.build/en/PRNUMBER/index.html`. These docs are republished on every commit to a pull request made to PhotonVision/photonvision-docs. For example, PR 325 would have pre-merge documentation published to `https://photonvision-docs--325.org.readthedocs.build/en/325/index.html`. Additionally, the pull request will have a link directly to the pre-release build of the docs. This build only runs when there is a change to files in the docs sub-folder.
## Style Guide
PhotonVision follows the frc-docs style guide which can be found [here](https://docs.wpilib.org/en/stable/docs/contributing/style-guide.html). In order to run the linter locally (which builds on doc8 and checks for compliance with the style guide), follow the instructions [on GitHub](https://github.com/wpilibsuite/ohnoyoudidnt).

View File

@@ -0,0 +1,275 @@
# Build Instructions
This section contains the build instructions from the source code available at [our GitHub page](https://github.com/PhotonVision/photonvision).
## Development Setup
### Prerequisites
**Java Development Kit:**
This project requires Java Development Kit (JDK) 17 to be compiled. This is the same Java version that comes with WPILib for 2025+. **Windows Users must use the JDK that ships with WPILib.** For other platforms, you can follow the instructions to install JDK 17 for your platform [here](https://bell-sw.com/pages/downloads/#jdk-17-lts).
**Node JS:**
The UI is written in Node JS. To compile the UI, Node 18.20.4 to Node 20.0.0 is required. To install Node JS follow the instructions for your platform [on the official Node JS website](https://nodejs.org/en/download/). However, modify this line
```bash
nvm install 20
```
so that it instead reads
```javascript
nvm install 18.20.4
```
## Compiling Instructions
### Getting the Source Code
Get the source code from git:
```bash
git clone https://github.com/PhotonVision/photonvision
```
or alternatively download the source code from GitHub and extract the zip:
```{image} assets/git-download.png
:alt: Download source code from git
:width: 600
```
### Install Necessary Node JS Dependencies
In the photon-client directory:
```bash
npm install
```
### Build and Copy UI to Java Source
In the root directory:
```{eval-rst}
.. tab-set::
.. tab-item:: Linux
``./gradlew buildAndCopyUI``
.. tab-item:: macOS
``./gradlew buildAndCopyUI``
.. tab-item:: Windows (cmd)
``gradlew buildAndCopyUI``
```
### Build and Run PhotonVision
To compile and run the project, issue the following command in the root directory:
```{eval-rst}
.. tab-set::
.. tab-item:: Linux
``./gradlew run``
.. tab-item:: macOS
``./gradlew run``
.. tab-item:: Windows (cmd)
``gradlew run``
```
Running the following command under the root directory will build the jar under `photon-server/build/libs`:
```{eval-rst}
.. tab-set::
.. tab-item:: Linux
``./gradlew shadowJar``
.. tab-item:: macOS
``./gradlew shadowJar``
.. tab-item:: Windows (cmd)
``gradlew shadowJar``
```
### Build and Run PhotonVision on a Raspberry Pi Coprocessor
As a convenience, the build has a built-in `deploy` command which builds, deploys, and starts the current source code on a coprocessor.
An architecture override is required to specify the deploy target's architecture.
```{eval-rst}
.. tab-set::
.. tab-item:: Linux
``./gradlew clean``
``./gradlew deploy -PArchOverride=linuxarm64``
.. tab-item:: macOS
``./gradlew clean``
``./gradlew deploy -PArchOverride=linuxarm64``
.. tab-item:: Windows (cmd)
``gradlew clean``
``gradlew deploy -PArchOverride=linuxarm64``
```
The `deploy` command is tested against Raspberry Pi coprocessors. Other similar coprocessors may work too.
### Using PhotonLib Builds
The build process automatically generates a vendordep JSON of your local build at `photon-lib/build/generated/vendordeps/photonlib.json`.
The photonlib source can be published to your local maven repository after building:
```{eval-rst}
.. tab-set::
.. tab-item:: Linux
``./gradlew publishToMavenLocal``
.. tab-item:: macOS
``./gradlew publishToMavenLocal``
.. tab-item:: Windows (cmd)
``gradlew publishToMavenLocal``
```
After adding the generated vendordep to your project, add the following to your project's `build.gradle` under the `plugins {}` block.
```Java
repositories {
mavenLocal()
}
```
### VSCode Test Runner Extension
With the VSCode [Extension Pack for Java](https://marketplace.visualstudio.com/items?itemName=vscjava.vscode-java-pack), you can get the Test Runner for Java and Gradle for Java extensions. This lets you easily run specific tests through the IDE:
```{image} assets/vscode-runner-tests.png
:alt: An image showing how unit tests can be ran in VSCode through the Test Runner for Java extension.
```
To correctly run PhotonVision tests this way, you must [delegate the tests to Gradle](https://code.visualstudio.com/docs/java/java-build#_delegate-tests-to-gradle). Debugging tests like this will [**not** currently](https://github.com/microsoft/build-server-for-gradle/issues/119) collect outputs.
### Debugging PhotonVision Running Locally
Unit tests can instead be debugged through the ``test`` Gradle task for a specific subproject in VSCode, found in the Gradle tab:
```{image} assets/vscode-gradle-tests.png
:alt: An image showing how unit tests can be debugged in VSCode through the Gradle for Java extension.
```
However, this will run all tests in a subproject.
Similarly, a local instance of PhotonVision can be debugged in the same way using the Gradle ``run`` task. In both cases, additional arguments can be specified:
```{image} assets/vscode-gradle-args.png
:alt: An image showing how VSCode gradle tasks can specify additional arguments.
```
### Debugging PhotonVision Running on a CoProcessor
Set up a VSCode configuration in {code}`launch.json`
```
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "java",
"name": "Attach to CoProcessor",
"request": "attach",
"hostName": "photonvision.local",
"port": "5801",
"projectName": "photon-core"
},
]
}
```
Stop any existing instance of PhotonVision.
Launch the program with the following additional argument to the JVM: {code}`java -jar -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:5801 photonvision.jar`
Once the program says it is listening on port 5801, launch the debug configuration in VSCode.
The program will wait for the VSCode debugger to attach before proceeding.
### Running examples
You can run one of the many built in examples straight from the command line, too! They contain a fully featured robot project, and some include simulation support. The projects can be found inside the photonlib-*-examples subdirectories for each language.
#### Running C++/Java
PhotonLib must first be published to your local maven repository. This will also copy the generated vendordep json file into each example. After that, the simulateJava/simulateNative task can be used like a normal robot project. Robot simulation with attached debugger is technically possible by using simulateExternalJava and modifying the launch script it exports, though not yet supported.
```
~/photonvision$ ./gradlew publishToMavenLocal
~/photonvision$ cd photonlib-java-examples
~/photonvision/photonlib-java-examples$ ./gradlew <example-name>:simulateJava
~/photonvision$ cd photonlib-cpp-examples
~/photonvision/photonlib-cpp-examples$ ./gradlew <example-name>:simulateNative
```
#### Running Python
PhotonLibPy must first be built into a wheel.
```
> cd photon-lib/py
> buildAndTest.bat
```
Then, you must enable using the development wheels. robotpy will use pip behind the scenes, and this bat file tells pip about your development artifacts.
Note: This is best done in a virtual environment.
```
> enableUsingDevBuilds.bat
```
Then, run the examples:
```
> cd photonlib-python-examples
> run.bat <example name>
```
#### Downloading Pipeline Artifacts
Using the [GitHub CLI](https://cli.github.com/), we can download artifacts from pipelines by run ID and name:
```
~/photonvision$ gh run download 11759699679 -n jar-Linux
```

View File

@@ -0,0 +1,112 @@
# Camera Matching
Diagrams generated by the [PlantUML UML editor](https://www.plantuml.com/plantuml/). Copy the image URLs below and decode in the editor to make changes.
## Initial Setup
When PhotonVision first starts, settings are loaded from disk and [VisionSources](https://javadocs.photonvision.org/org/photonvision/vision/processes/VisionSource.html) are created for every serialized & active [Camera Configuration](https://javadocs.photonvision.org/org/photonvision/common/configuration/CameraConfiguration.html)
![](https://www.plantuml.com/plantuml/png/VP5FQnin4CNl-XI3JotK-DAJAI6fIw6GfOMbFkKoramSqTKVfF6MVFkETfKsei6trVpUldbwkYs2MIv-CeI29omCcn5d9XXPn8LpsG0MAErWaggTTGc3m6P05nRizQD7HrTS3336IxOC0mOySrwqS_5lIeT8bubxgVTNN9jRhpYCXvXNP8lLpokxsWvZNcwtlQaNsSDzH8B773sGAxzC7MvlDFSUxeXWKie4DeP7futelC8z73AZCDnPSJD35xKOh5F5DR31IU3d-1aiUive06PTlSRTm_V4eH4uFJ-4Aamn2xmxFMyJojDx0x2AjtNn-WSJ73_UltRyzC_o2mjRQH1IZecpE4t5WPOmX_5R7sPof_NyVvwghNbK-LVL1sbErTneFLqxNxF27pdEZZXNs8gjbJFrhHdYLxMredrx1Obm70QZvnUBtKxdJE2NnosxNVj3qIYO1GB_Rb3DEZAlQxKPowMuS7u8oIMUNE0F84-PaOgvvK0NF_q1)
## UI Workflow
A [background thread](https://javadocs.photonvision.org/org/photonvision/common/util/TimedTaskManager.html) will periodically query CSCore and Libcamera for what cameras we currently see connected. This list is provided to the web UI for display.
![](https://www.plantuml.com/plantuml/svg/POvDJyCm343l-HLMxnFt7j14uJ099AHkSCvSCopoCSLE-FjaxQW8kpbwpy_PYjgasJk3qJb2vHW4kZrxcc1lvGjURB0dIXrO0LLlpBakCFBP1eNkZQLkm1XpGchS8hvLXt68YMQ6WdLiyJCVqNfATZRSxwkLtka8XzriP3P6rM_kww4U7hac2oK8z0qJ5KOIKwJYvLOFJo5VUafm61zWYOjPwEPQ6M88X4fJuyoPzKD_IyEuMwrLk8rLhOrbxk4rooVWwbmvE1Rz9rbKBdJ7OHakInzy4hEbC6NlVW00)
![](images/matching_ui.png)
This UI allows users to "Activate" a camera that's never been seen before, or activate a CameraConfiguration we've seen before but was disabled. Allowing camera configurations to be saved but not loaded by default lets us support temporarily disabling/unplugging a camera without flooding log files.
Since our backend logic intentionally does not protect users from plugging camera B into the port that camera A was active on, the UI shall show a warning but vision processing will (attempt to) continue like normal.
### Activate New Camera
When a new camera (ie, one we can't match by-path to a deserialized CameraConfiguration) is activated, we'll create a spin up a new Vision Module for it
![](https://www.plantuml.com/plantuml/svg/VL7B3jCm4BpxArOzWKIK2wSALOKWf4gDG8fQBhquzggrY1_u4TI_PvCufGRKK-ATySpiU1yYzp7fWJdwAg4SDn4stx67qs43F41I9NHMGLa3dKrU8BJSy2lwcJa6_LzgQsKQ_g9g_K8rgvMCfckiNo0H1FsMy57rWclqV6OCw-b5e1o4iQIg7MNVmaSfeRz3CkfdGZ0am6YUmOuR5UyWRYX-X7M-XSOZZmX5_i2uY6ga-RG5uqE4K_S9SYAWORLRTjZ2LuSc8-HzCHFHMH_XJN-l78-tjmpomjNakDn02UVtnrKHZPnDckvGcZng-DU7kBCFCH-imk1PdDRzy2VoPumeuYhcl7L87UDKIj795q-CRzwEIgAVmDpaqNA9igoCINpgBDUhyvj42-UsPNHU9UgQvgIXvvSCTRtUe7UAt4Sm-2k395OWus9BiGM6eCprOfnoE2Y3xo3UF78Ps1wDJ7hu3G00)
### Deactivate Camera
Deactivating a camera will release the native resources it owns, and return the CameraConfiguration to the pool of currently disabled cameras we can re-enable later.
![](https://www.plantuml.com/plantuml/svg/ROxBJiCm44Nt_efHLtIH7yWYgWWB8gYeI0eRDXDdW97yABQd5N-FvV1G8bOUppdNrxkOC2InHftooPfFw19idcc4OxS1Z22yH4ySsJlelGHDi4U7RnIAUOxsNtNl9p4hrQxKjczzeC9qr7bSudiUDLeAM0ppSrDAk6foRmqtX3hn6HD16GXcvSMDdo2EFuJ0vOtATexO77aawxDdo_TKNbLLCvVNq1eV_vwuwbxXs5zllwNV_Xe6mZ3vYrkeRTzjvvv6k8Q3n7TmT86OC541LG6tmt20Xpkr8pU9DLy0)
### Reactivate a CameraConfig
When a new camera (ie, one we can't match by-path to a deserialized CameraConfiguration) is activated, we'll create and spin up a new Vision Module for it.
![](https://www.plantuml.com/plantuml/svg/VP9BYnD158NtzIikirAmoSPL8s5YH1n8SB1duYQRsrtNcGlrAElHadzlLVgXXP9LACvNvvmwwViGqSUabN3vbmTsQ2BSVQSUdX_k00CahgKJ1xO6EflyG714Wo_ah-GOz7_HevL9KOrgVSDrTgk9VRUtVfA6C5XFjNpWVa1D7g-4Maut2ir5X4ZSR7Ft5huH3f57Z0II0_QA94msPzDV81d-cGWCQX82LOJdxYCuwoEmWHH8G9cWsIPkuSlJqoFyG5R9ao0ZXIXIZcbXxwaax4eKGVNm8DO2OrWpvWvN-sOxFRw5huxCh41_EPkrp9l-qZYChsy5m0GtKt2vGH9Exm-BOobMGlRTGnsoxlTlJc5BJYPNgWgOuUNL7_vK_aIHXhYOEMyT-SWKCbLDyzbduj7RaINv8ix_py6Y95bF9YJzjTcyiixmJag85ax7eyZdnMApsSdYeQ-VGDXibXijT15z14E_5b6CbJ9EiRdsG26mUJaRnuuK6te7yTKJoY3koSYarMy0)
# Camera Matching Requirements
## Definitions
- VALID USB PATH: a path in the form `/dev/v4l/by-path/[UUID]`
- VIDEO DEVICE PATH: a CSCore-provided identifier derived from the V4L path `/dev/video[N]` on Linux, or an opaque string on Windows
- UNIQUE NAME: an identifier that is unique within the set of all deserialized CameraConfigurations and unmatched USB cameras
- I don't love this, it means that a USB camera matched to a VisionModule will share a UNIQUE NAME, right?
- DESERIALIZED CAMERA CONFIGURATIONS: The set of camera configurations loaded from disk and provided to the VisionSourceManager. This configuration data structure includes the UNIQUE NAME
- CURRENTLY ACTIVE CAMERAS: The set of VisionModules currently active and processing vision data, and associated metadata
## Startup:
- GIVEN An emtpy set of deserialized Camera Configurations
<br>WHEN PhotonVision starts
<br>THEN no VisionModules will be started
- GIVEN A valid set of deserialized Camera Configurations
<br>WHEN PhotonVision starts
<br>THEN VisionModules will be started FOR EACH un-DISABLED config
- GIVEN A valid set of deserialized Camera Configurations
<br>WHEN PhotonVision starts
<br>THEN VisionModules will NOT be started FOR EACH DISABLED config
- GIVEN A CameraConfiguration with a VALID USB PATH
<br>WHEN a VisionModule is created
<br>THEN The VisionModule shall open the camera using the USB path
- GIVEN A CameraConfiguration without a valid USB path
<br>WHEN a VisionModule is created
<br>THEN The VisionModule shall open the camera using the VIDEO DEVICE PATH
## Camera (re)enumeration:
- GIVEN a NEW USB CAMERA is avaliable for enumeration
<br>WHEN a USB camera is discovered by VisionSourceManager
<br>AND the USB camera's VIDEO DEVICE PATH is not in the set of DESERIALIZED CAMERA CONFIGURATIONS
<br>THEN a UNIQUE NAME will be assigned to the camera info
- GIVEN a NEW USB CAMERA is avaliable for enumeration
<br>WHEN a USB camera is discovered by VisionSourceManager
<br>AND the USB camera's VIDEO DEVICE PATH is in the set of DESERIALIZED CAMERA CONFIGURATIONS
<br>THEN a UNIQUE NAME equal to the matching DESERIALIZED CAMERA CONFIGURATION will be assigned to the camera info
- This is a weird case. How -should- we handle this? see above
## Creating from a new camera
- Given: A UNIQUE NAME from a NEW USB CAMERA
<br>WHEN I request a new VisionModule is created for this NEW USB CAMREA
<br>AND the camera has a VALID USB PATH
<br>AND the camera's VALID USB PATH is not in use by any CURRENTLY ACTIVE CAMERAS
<br>THEN a NEW VisionModule will be started for the NEW USB CAMERA using the VALID USB PATH
- Given: A UNIQUE NAME from a NEW USB CAMERA
<br>WHEN I request a new VisionModule is created for this NEW USB CAMREA
<br>AND the camera does not have a VALID USB PATH
<br>AND the camera's VIDEO DEVICE PATH is not in use by any CURRENTLY ACTIVE CAMERAS
<br>THEN a NEW VisionModule will be started for the NEW USB CAMERA using the VIDEO DEVICE PATH
## Deactivate
- Given: A UNIQUE NAME from a CURRENTLY ACTIVE CAMERA
<br>WHEN I request the VisionModule be DEACTIVATED
<br>THEN the VisionModule will be stopped for the given CURRENTLY ACTIVE CAMERA
<br>AND the CameraConfiguration DISABLED flag will be set to TRUE
## Reactivate
- Given: A UNIQUE NAME from a DESERIALIZED CAMERA CONFIGURATIONS
<br>WHEN I request the VisionModule be ACTIVATED
<br>AND the CameraConfiguration's DISABLED flag is TRUE
<br>THEN a VisionModule will be created and started for the camera

Some files were not shown because too many files have changed in this diff Show More