|
Re: Camera Tracking help please
What you want to do is repeatedly re-run that code as you rotate your robot to face the target. Look at the reports[i].center_mass_x, as that will tell you the center of the target. Generally, the index, i, goes from 0 being the highest target to the left, and reports.length-1 being the lowest to the right.
You will want the center_mass_x value to be your video resolution divided by two.
You can go about this by using a PID loop for accurate results, though that requires tuning. If you don't need it to be super precise, you can just have it turn the robot at a speed proportional to the distance between the center_mass_x value and the center of your camera, and stop turning when you are within, say, 10 pixels.
__________________
2011-2014 - FRC 2607 - Student
2012-2012 - FLL 2249 - Coach
2015- ???? - FRC 4791 - Mentor
|