![]() |
Centering Camera and Robot
We need to figure out how to get our camera to center itself on rectangular objects.
Basically, we can get the camera to take a picture and recognize the rectangle as a target. But the rectangle in the image isn't centered. We want the robot and camera to move until the rectangle is in the dead center of the camera and the image, that way we can aim correctly. Thank you in advance for any assistance you might be able to offer us, we're really looking forward to finally using vision targeting this year. |
Re: Centering Camera and Robot
I faced this problem a few weeks ago and here is my solution
Code:
private void centerShooter() { |
Re: Centering Camera and Robot
why not calculate the angle, than use a gyro with a pid loop to turn?
|
Re: Centering Camera and Robot
Hey, try checking out my guide. It explains how to do the vision processing parts of what you're trying to do.
As for the rest, check out my code for automatic turret tracking. RobotMap.top[0] is the reported x coordinate of the center of the detected target. If you're doing your own vision processing, just pass it that value as such. CameraXOffset is just 160, the x value of the center of the camera's vision. HorizontalTurretAxis.rotate() is a method I added to HorizontalTurretAxis, but replace that with whatever you want the PID output to be of course. If you need more explanation on how this works please ask. TL;DR image processing sends x,y coordinates of detected target back to a command that runs a PID controller using that coordinate as input and your motors as output to align itself. |
| All times are GMT -5. The time now is 10:09. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi