Vision Sensor Auto-Targeting

Over the summer I made this, but I just realized I never really shared it.

Vision Sensor Auto-Targeting

I used the V5 vision sensor to make the robot automatically look for, then hunt down, an object. It does this fully autonomously. I wrote the code myself, but no leekz this time.


This seems amazing, but is there a reason it spins so slowly? Were there tracking issues? Either way, great job!

It seems to be slow to initially locate the object, but then pounce on it once found. Is the slowness from a limitation on the sensor, or just coded that way?

It’s coded to go slow (25% power) for accuracy. It could have been going faster.

1 Like

If it can properly detect the object when locked on, it should be able to detect it when spinning. The slow spinning (especially such slow spinning) should be unnecessary. How does it behave when spinning at full power?

1 Like

For this project, you should be able to use PID to much improve the speed and accuracy.
I made something similar at the beginning of last year:
The code is here, though it was my first project in c++ so quite unnecessarily messy.

Here is how it works:
It grabs the largest object from the vision sensor, and stores it in a variable.
It then calculates how much the center of the object is away from the center of the vision’s FOV
giving an “error” value. For example, if the FOV was 100, and the object was in the middle (x of 50), then the error would be 0. I then use that error to calculate how much the base needs to turn, using a Proportional (PID) controller. The way it’s structured is quite unnecessarily complex, but it was my first program in c++.