![]() |
Camera to motor setup
We got the camera to track the green, but now we've got another problem.
We've hooked up the servos on the camera directly to two motors so the camera tells the motors what to do. However, when the camera sees it, it sets the motor running in one direction and doesn't stop it. How are some of the other teams doing this? Are you guys modifying the code sent to the motors or will this setup work? |
Re: Camera to motor setup
Servo values don't directly translate to motor values.
A servo value of say 175 could be off to the left or right of center. In terms of a motor, it is forward. You need some translating code in there |
Re: Camera to motor setup
Servos are position-commanded. A pwm value of 127 is center, 0 is one extreme, 254 is another.
Motors are velocity-commanded. Pwm 127 is neutral, 0 is full reverse, 254 is full forward. You have to translate between the two. Using an encoder or pot and a feedback loop is one way. |
Re: Camera to motor setup
Quote:
a) Turn the bot until the pan servo reads 127 (0 degrees) b) Use a gyro (It would be a shame if a team skimped out on using one of these, seeing as we got a pretty nice one in the kit!) and turn to the calculated angle. c) Use a combination of both: Lock onto the target.. get the relative angle.. turn UBER fast using the gyro to slow down.. and reposition yourself by using choice A. |
Re: Camera to motor setup
Quote:
Mike |
Re: Camera to motor setup
Quote:
We haven't gotten our encoders to work well yet. What do you mean by "pot and a feedback loop?" Quote:
|
Re: Camera to motor setup
Quote:
Quote:
|
Re: Camera to motor setup
Quote:
I am by no means a programmer, but with no encoders/gyros/etc. whatsoever (method A you are referring to) is it not possible to write some code kinda like this: Code:
|
Re: Camera to motor setup
The true center value for a servo is 127 but in Kevin's code he defines them in tracking.h!
|
Re: Camera to motor setup
There are 2 solutions available using proportional control if you are either
1) steering a gun turret using the pan and tilt output from the camera data packet; or 2) slaving the turret in the x-plane by fixing the camera to it First, if you are using an optical encoder to measure the rotation of the turret and Tmid is the midpoint measurement of the turret and Cmid is the midpoint servo output for panning, then once the camera finds the target, the desired turret position, or turret_dx, is given by Tmid*(1+((pan/Cmid)-1)). If we set error_x = turret_dx-OE, then the pwm output to the motor powering the turret is 127-Kp*error_x, where Kp is a proportionality constant. Second, if the camera is afixed to the turret in the x-plane, then the error is simply Cmid-pan. The pwm output is then 127+Kp*error_x. You can refine these equations to make a PID controller if needed. The math should be optimized for integer math by multiplying and dividing by 100 to avoid truncation error. Post your own solutions! Jon Mittelman Team236 Programming Mentor |
Re: Camera to motor setup
Quote:
-Kevin |
Re: Camera to motor setup
so
pan ceter is 124 tilt center is 144 right, Kevin? Jon |
Re: Camera to motor setup
This is the basic outline that I came up with, where the camera is mounted on the cannon.
Quote:
Does the pan & tilt center change when you change the degrees of panning & tilting? |
Re: Camera to motor setup
Quote:
|
Re: Camera to motor setup
Kevin: Would you recomend fixing the camera to the turret and slaving the pan (and a factoring in the tilt assuming the turret can tilt)? I am not an exrteemly versed programmer but i know i could pull it off. As is i figured that i would just keep them independant.
Also: is the confidance rating of the camera a good relfection of magnitude in the vector to the light (after all, vectors have direction & magnitude!). I could perhaps use this to throttle the shooter's wheels. |
| All times are GMT -5. The time now is 01:53. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi