Help with Vision processing

My team 948 has a small problem of fine tuning vision processing of driving to retro reflective tape . The problem being our robot makes it near it but it doesnt orient itself to the target in a aligned/ straight way it just gets it near it. Anyone with experience with this please feel free to help.
Team 948

This is the problem a lot of teams are having. Since they have two of the same size and same angle tapes, the software gets confused of which one to follow. You would have to get the center of the two and then make you robot follow that X coordinate.

We were attempting to tackle this problem of approaching the target perpendicular earlier on in the season. We resorted to trying to calculate some horizontal “skew” value that is proportional to the angle at which we come into the target at. Then just multiply this value by a gain and add that to the steering command.

We tried multiple ways to get this skew value but what worked out most consistently for us was calculating the width to height ratio of the contour and then signing this val based on which side of the contour was taller (if the right side of the contour is taller, you are coming in from the right side, if the left side is taller, multiply the value by negative 1 because you’re coming in from the left). This value was pretty consistent but jumped around a bunch still. Slapping a bunch of rolling averages everywhere helped but not great.

Ultimately, our panel mechanism allowed us to come in from pretty steep angles and still score so we just decided to ditch the whole skew thing.

1 Like

They way you are trying to tackle this problem sounds good. You can also try adding midpoint formula to make sure your value stays the same.

x1 + x2 / 2
For example
60 + 140 / 2 = 100

*If the values gets switched

140 + 60 / 2 = 100

Using some simple trig we were able to come up with a method that can deduce both the exact location and orientation of the target from a single image. You can find some code here for reference: https://github.com/Arctos6135/frc-2019-jetson/blob/master/src/bot_vision/src/bot_vision_node.cpp (Vision processing is in the image_callback() function).

In a nutshell, since we know the exact real-life sizes of the vision tapes, we can deduce our distance to each of the pieces using trigonometry. We basically took the regular size of the tape, and the angle of the field of view of the camera it took up, and calculated the distance from there. One thing to take note of is when the target is skewed, it will look “smaller” horizontally and thus appear “further” to the algorithm. We tackled this issue by using not the width but the height of the target in the image, since fortunately the skew can only be horizontal.

Now with the distance to each of the two pieces of tape, we can take the angle between them and apply the cosine law, and get the skew of the target. One more thing we did was to compare the calculated distance between the two pieces of tape with the actual distance that we got from the manual, and applying a crude correction based on that. With this method, we were able to determine the location of the targets to within 2% error.

However, one caveat is that this method works the best only when the camera is roughly at the same height as the targets and also pointing directly at them. But I guess if you really wanted, you can correct for that with even more trig.

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