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?