View Single Post
  #1   Spotlight this post!  
Unread 15-01-2013, 20:14
rudun's Avatar
rudun rudun is offline
Registered User
FRC #0496 (Royals)
Team Role: Coach
 
Join Date: Jan 2009
Rookie Year: 2005
Location: Babylon
Posts: 43
rudun is an unknown quantity at this point
Converting between camera normalized data and servo

I have been trying to have a servo attached to the camera x axis twist to turn it so the center image is the center of the target. Since the normalized output in the vision target is a value that shows it to the left or right of the center of the image, you should be able to take that and convert it to the scale a servo uses. Then make changes to the servo until it and the target are centered.

The issue I am having is figuring out how to normalize the ranges. I have gotten this far, I do not think I am lost, but that I am just not understanding the math, or the proper procedure for determining it. Suggestions or help would be greatly appreciated.
I tried following the math on this page http://stackoverflow.com/questions/1471370/normalizing-from-0-5-1-to-0-1
not sure if this is the right method or not
Code:
            double servoChange = ((report.center_mass_x_normalized-(-1))/2);
                        System.out.println("Servo Change: " + servoChange);
                        double servoInput = CameraX.get()-servoChange;
                               if(servoChange > 1) {
                        servoChange = 1; }
                    else if(servoChange < 0) {
                        servoChange = 0;
                    }
                        CameraX.set(servoInput);

Last edited by rudun : 15-01-2013 at 20:23.