I'm going to try to explain my problem as clearly as I can.
I have been building a robot that has four wheels, 2 motors and 2 free wheels. Its a differential drive system.
O --- O Motor Wheels
| |
-o---o- Free Wheels.
The objective of this robot is to follow something/someone. I have cameras that give me a 3D point I use to define a position, and based on a setpoint, I correct the Front Error and Side Error with two PID controllers.
1 - Basic calculations to adjust robot are
Left Wheel = ( FrontError - SideError ) * Acceleration;
Right Wheel = ( FrontError + SideError ) * Acceleration;
Side Error and Front Error are results of Two different PIDs. One for each axis of a 3D coordinate space. Front is error on Z ( distance ), Side is error on X ( deviation from center ).
Q1: When I test the two PIDs independently, if only testing for front correction, or only side correction, everything works. But when I use the two PIDs I lose control of the robot. Any Idea why? Higher the speed the less control I have.
2 - I am controlling this through software on a computer, and sending those values to a board that controls the motors. What I am sending is PWM values. My problem is: since two motors are never equal, and depending on the load/weight the robot has on top of it, I need different PWM values for EACH wheel, for the robot to go forward. Sometimes, on a scale of 0-1023, if I set 150 PWM to one wheel and 400 to the other wheel, the robot doesn't turn as my calculations predict it would turn and goes straight forward.
Leading to my second question.
Q2: When dealing with this kind of robots and control. What are the best way to solve this problem? I'm thinking of encoders. Controlling through RPM rather than PWM, and having a PID on each wheel on the motor controller board. Which leads to another issue. Lattency. I have a loop of 175ms. Taking that into account, what's the best solution for me?
Answer
Your second problem is probably closely related to the first. When you write the calculation:
Left Wheel = ( FrontError - SideError ) * Acceleration
what you really mean is:
Left Motor Input = ( FrontError - SideError ) * Acceleration
If there is a significant difference between the input to the motor and what the wheel actually does, perhaps because there is an unexpected load on the robot, then it is going to be difficult or impossible to tune those FrontError
and SideError
PID controllers in combination. If the wheel response is not linear you cannot simply add together two PID outputs and expect to have both work at once.
You have two general solutions here -- either develop a model so you can compensate for the difference, or make it so that the wheels actually respond fairly linearly to their input. This second option is probably the best one and it is what you will get if you use encoders and separate well-tuned PID controllers for each wheel.
Depending on all the other variables involved, the latency may prevent your control system from being stable. A simple two-pole PID controller might not be able to compensate adequately for it, but if you're experimenting it would be worth a shot, especially if you can fix up your wheel drives.
No comments:
Post a Comment