Issues with using PhotonVision with the Romi to detect AprilTags

I’ve been working on using to Romi to detect AprilTags to get experience before kickoff. The issue I am having is that the readings for distance have been extremely erratic, fluctuating based of the yaw of the target and sometimes reaching into the negatives, an impossibility. My original guess for the cause of the problem was the little height delta between the tag and camera, so I mounted the tag significantly above the Romi. This has done nothing to resolve the issue. I also have calibrated the camera. My code to find the distance is as follows:

public double getBestTagDistance(){
if(bestTag != null)
return PhotonUtils.calculateDistanceToTargetMeters(Constants.CAMERA_HEIGHT,
Constants.TARGET_HEIGHT[bestTag.getFiducialId()],
Constants.CAMERA_PITCH,
Units.degreesToRadians(bestTag.getPitch()));
else
return -1;
}

The constants in question are a camera height of 4.5 inches, converted to meters, a target height of 32 13/16 inches converted to meters(I use a list to store the heights if I would work with multiple targets), and a camera pitch of 0. Unfortunately, the Camera I am using has a flexible mount, but the camera looks quite parallel to me.

Any ideas for potential causes for this erratic reading and methods to solve it would be greatly appreciated.

Do you have your full code?

If you’ve calibrated the camera, why even bother with calculateDistanceToTargetMeters? You get a a target pose out already. Depending on what photon version you’re running, I think it may have been renamed a bit? Probably something like getCameraToTarget() /GetCameraToTarget()
Getting Target Data - PhotonVision Docs

1 Like

Here is the link to my current code. Since I’m working on it right now, I’ll try to push whenever I get something working. GitHub - Cephandrius42/RomiTags: Currently nonfunctional code for detecting April Tags with a Romi robot for FRC

Good idea. I’ll try that.

The issue seems to be with the FOV of my camera, adjusting that fixed the issue.

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.