Skip to content
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

Changes sim to use 36h11 tags #1056

Merged
merged 13 commits into from
Jan 2, 2024
Merged

Conversation

r4stered
Copy link
Contributor

Fixes #1041

There is an issue with generating the AprilTags through the JNI that I have not figured out yet. Any help is appreciated. I have virtually no experience with JNI. I can confirm it works with C++ though.

@mcm001
Copy link
Contributor

mcm001 commented Dec 22, 2023

Looks like WPILib merged the PR fix this needs right?

@r4stered
Copy link
Contributor Author

Looks like WPILib merged the PR fix this needs right?

Yea! Do we know if WPILIB is releasing another beta to build against or should we wait on the first official release to merge this?

@mcm001
Copy link
Contributor

mcm001 commented Dec 22, 2023

Not sure. I would vote to wait for a full release of wpilib but let's get it ready to go so I can just click the button on kickoff day

@mcm001
Copy link
Contributor

mcm001 commented Dec 22, 2023

(Or, we cut a photon release now, then merge this and bump wpilib to a dev version. Idc)

@mcm001 mcm001 marked this pull request as ready for review December 25, 2023 01:30
@mcm001 mcm001 requested a review from a team as a code owner December 25, 2023 01:30
@mcm001
Copy link
Contributor

mcm001 commented Dec 25, 2023

image

I've updated wpilib to "2024.1.1-beta-4-26-g1ce617b", but ./gradlew swervedriveposeestsim:simulatejava has tags that look... odd?

But C++ still looks good
image

@mcm001
Copy link
Contributor

mcm001 commented Dec 25, 2023

Yeah, poked some more and Java still looks broken to me
image

@r4stered
Copy link
Contributor Author

That's annoying :/

I will try to debug some more on the WPILIB side after my holiday break.

I'm pretty sure it's an issue with how memory is handled between the cpp and jni side.

@mcm001
Copy link
Contributor

mcm001 commented Dec 25, 2023

Yep Peter found a use after free in the JNI. He can probably track those fixes after Xmas

@r4stered
Copy link
Contributor Author

Bumping wpilib version to newest and running I get this:
image

Odd because its detecting the tags, but they are visually wrong. This happens on the C++ and Java version. Looking into it now...

@r4stered
Copy link
Contributor Author

Fixed! It was an issue with the conversion to a cv Mat
image

@mcm001
Copy link
Contributor

mcm001 commented Dec 28, 2023

Are there old tag images that we can now delete?

@r4stered
Copy link
Contributor Author

Are there old tag images that we can now delete?

Pretty sure the whole resources folder in photon-lib can be deleted

@mcm001 mcm001 added this to the 2024 Kickkoff milestone Dec 29, 2023
else result = Imgcodecs.imread(kLocalTagImagesPath + name + ".png", Imgcodecs.IMREAD_GRAYSCALE);
public static Mat get36h11TagImage(int id) {
RawFrame frame = AprilTag.generate36h11AprilTagImage(id);
Mat result = new Mat(10, 10, CvType.CV_8UC1, frame.getData(), frame.getStride());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that this mat constructor doesn't actually ever allocate data? Which means that if frame ever gets closed, we could end up with another use-after-free. Instead, make a clone of this mat and then close the RawFrame

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be fixed in the latest commit

Copy link
Contributor

@mcm001 mcm001 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's official nobody reads these

@mcm001 mcm001 merged commit 96de176 into PhotonVision:master Jan 2, 2024
23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Change VisionSystemSim.addAprilTags to assume 36h11 tags
2 participants