-
Notifications
You must be signed in to change notification settings - Fork 165
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WIP] Simulation Overhaul #742
Conversation
…into sim-overhaul
…into sim-overhaul
…into sim-overhaul
photon-lib/src/main/java/org/photonvision/util/VideoSimUtil.java
Outdated
Show resolved
Hide resolved
photon-lib/src/main/java/org/photonvision/util/RotTrlTransform3d.java
Outdated
Show resolved
Hide resolved
if (result.empty()) { | ||
BufferedImage buf; | ||
try { | ||
buf = ImageIO.read(resource); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no null check here? Is this assumed to be non-null based on the previous check?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if you mean result
, it should always be at least an empty Mat. If you mean buf
, I believe it should throw an exception when it can't read the desired image.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean resource, you bill check before but not beyond that if statement
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If resource
is null, ImageIO.read
will throw an exception.
addVisionTargets( | ||
"apriltags", | ||
new VisionTargetSim( | ||
tagLayout.getTagPose(tag.ID).get(), // preserve alliance rotation |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Check if tag is present, getTagPose returns an optional
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are iterating through the tags that the tag layout reports through getTags()
and then redundantly getting their pose from the layout again (for handling different alliance origins), so this should not be empty.
|
||
// use camera pose from the image capture timestamp | ||
Pose3d lateRobotPose = getRobotPose(timestampCapture); | ||
Pose3d lateCameraPose = lateRobotPose.plus(getRobotToCamera(camSim).get()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
getRobotToCamera returns optional, camSim confirmed to be non-empty?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When adding a camera sim to the vision system sim, it is ensured that there is a transform. The only way for the getRobotToCamera
method to return empty should be if the given camera sim does not exist in the vision system sim. In this case, we are iterating through the camera sims in this vision system sim.
See github for things I thought warranted further discussion
Yes, but I think that it's OK as long as we add a note to the docs? |
- `PNPResults` can now be empty (`isPresent` = false) - solvePNP methods actually handle errors and return empty `PNPResults` - This reveals an odd error where some inputs to `solvePNP_SQUARE()` resulted in an estimated transform with NaN values, and attempts to handle it - Overwrites java changes from #817 since #742 had duplicate fixes - Minor bugfixes
Putting this (living) draft up for feedback and testing. Some of the videos on this repo's readme show this simulation in action. This is all currently just from my perspective, and there's still lots more that could be added, so I would appreciate opinions on anything and everything.
What does this do?
CameraProperties
class for describing a camera's basic/calibration info, and performance values for simulation. Calibration values can be loaded from theconfig.json
in the settings exported by photonvision.OpenCVHelp
provides convenience functions for using opencv methods with wpilib/photonvision classes, mainly to project 3d points to a camera's 2d image and perform solvePnP with the above camera calibration info.TargetModel
s describe the 3d shape of a target, both for projecting into the camera's 2d image and use in solvePnP.PhotonCameraSim
uses camera properties to simulate how 3d targets would appear in its view, and has simulated noise, latency, and FPS. For apriltags, the best/alternate camera-to-target transform is also estimated with solvePnP.VideoSimUtil
has helper functions for drawing apriltags to a simulated raw and processed MJPEG stream for each camera using the projected tag corners.VisionSystemSim
storesVisionTargetSim
s andPhotonCameraSim
s, and is periodically updated with the robot's simulated pose. When updating, camera sims are automatically processed and published with their visible targets from their respective poses with proper latency.How to test this
Possible Additions / Known Issues
warpPerspective
resultsThings that should be done to finish this PR