|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
|||
|
|||
|
Re: PID Loop Controller with a Servo
Quote:
I think they do. The more I think about this the more I'm thinking of not using a PID loop and using the distance to the target as a ratio of the angle. The only problem is that the distance away from the target will change that ratio. For instance if you are two feet away changing the angle by one degree will be different if you are five feet away |
|
#2
|
||||
|
||||
|
Re: PID Loop Controller with a Servo
Angle to center of target is independent of distance.
You will need to make less adjustment the further away you are but the error reported will be less as well. What you may run into is a lack of resolution to adjust the servo accurately. That's why I mentioned using microseconds instead of degrees. ie. (~ 1000 vs. ~180) |
|
#3
|
|||
|
|||
|
Re: PID Loop Controller with a Servo
Quote:
|
|
#4
|
||||
|
||||
|
Re: PID Loop Controller with a Servo
That would likely dictate that you would need to not direct mount to the servo. You would probably have to build a specific interface with gearing to account for the extra degrees of motion.
|
|
#5
|
|||
|
|||
|
Re: PID Loop Controller with a Servo
What I meant is how would you control the servo in code using microseconds?
|
|
#6
|
||||
|
||||
|
Re: PID Loop Controller with a Servo
Servos are written a signal that is 1000-2000 uS high, then 20ms low. The number of uS you write is directly proportional to the angle; 1000uS is 0*, 1500uS is 90*, and 2000uS is 180*. There is some error but for relative angle movement (turn 5* to the left) it should be fine.
|
|
#7
|
|||
|
|||
|
Re: PID Loop Controller with a Servo
Quote:
|
|
#8
|
||||
|
||||
|
Re: PID Loop Controller with a Servo
There might be a way to access it in the Servo classes for the RIO, but I'm not familiar enough with it to say for sure.
You could also manipulate timers directly and make your own class for interfacing with them. Or you could send data to an Arduino, which has built-in Servo libraries, at the cost of lag time. |
|
#9
|
||||
|
||||
|
Re: PID Loop Controller with a Servo
A typical (non-continuous) servo already implements closed-loop control onboard, so a PID loop is unnecessary. Just set it to the angle you want and it will handle going there. Servos are quite effective at moving to positions quickly and without overshoot.
You can set a servo in wpilib using Servo.setAngle(degrees) |
|
#10
|
|||
|
|||
|
Re: PID Loop Controller with a Servo
Quote:
|
|
#11
|
||||
|
||||
|
Re: PID Loop Controller with a Servo
Quote:
In very simple terms, divide your camera's field of view in degrees by your horizontal resolution. That will give you degrees per pixel. Now just multiply the numbers of pixels you are out of alignment by the degrees per pixel and you have your degrees to turn. |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|