2
$\begingroup$

I'm building a line following robot. I have made different chassis designs. The main prototype I'm using is a rectangle base. At one side motors are placed. On the other side of the rectangle caster wheel is placed in the middle. Look at the following image.

Robot Design Prototype

By varying the values of distance, I have seen that the stability of the robot is varying rapidly.

I'm driving the robot using PID. I have seen that for some chassis designs it is very hard(sometimes impossible) to calculate correct constant values. And for some chassis it is very easy. By the word stability I meant this. I have a feeling that the robot dimensions, distance values and that stability has a relationship..

Is there an equation or something that can be used to estimate the value of the distance when the width of the robot is known..?

Other than that is there a relationship between robot weight and diameter of the wheel or robot dimensions and the diameter..?

Thanks for the attention!!

$\endgroup$
12
  • $\begingroup$ Can you give us more information about what you mean by "stability"? I'm guessing you mean that the caster wheel is on a bit of an offset so it causes the vehicle to turn a bit when driving in reverse (to the right in your image)? If the caster wheel was just a ball with minimal friction then changing the distance shouldn't make any difference to the kinematics at all. $\endgroup$ Nov 27, 2015 at 20:04
  • 1
    $\begingroup$ Word stability is explained in the post. I edited the earlier post. $\endgroup$
    – Ramesh-X
    Nov 27, 2015 at 20:25
  • $\begingroup$ Great, that helps a lot. How is your PID controller working? Are you controlling both speed and turn rate? $\endgroup$ Nov 27, 2015 at 20:31
  • $\begingroup$ PID algorithm is generating a values according to the error of sensor reading. The generated value is used to change the mid speed value of the motor. setMotorSpeed(midSpeed + value, midSpeed - value) According to the sign of the value, speed changes and robot turns.. $\endgroup$
    – Ramesh-X
    Nov 27, 2015 at 20:40
  • $\begingroup$ Cool, so you are maintaining a constant midSpeed and then varying value to turn. $\endgroup$ Nov 27, 2015 at 20:44

1 Answer 1

5
$\begingroup$

Actually, the caster wheel has ideally no effect on the kinematics of the vehicle. In reality there will be some resistance from the caster wheel that does impact the vehicle motion, but we can still ignore it for the sake of designing a control law.

Based on the extended discussion in the comments, your sensor can be used to measure the lateral error of the robot with respect to the line it is following. Consider the diagram below, where the robot position is depicted with a dark blue circle and its direction of motion is the red arrow (with constant speed $v$). The lateral error is $e$ (perpendicular distance to the line), while the heading error is $\alpha$ (angle of the velocity with respect to the line).

enter image description here

What you care about is having a control law that controls the robot heading so that an appropriate value of $\alpha$ causes $e$ to be minimized. To do that, consider the error dynamics of $e$:

$\dot{e} = v \sin \alpha$

Which can be extended to:

$\ddot{e} = v \dot{\alpha} \cos \alpha$

If we ignore the fact that the line direction may be changing (valid for most cases similar to roads), then the rate of change of the heading error is approximately the rate of change of the robot heading (turn rate $\omega$):

$\dot{\alpha} \approx \omega$

$\ddot{e} = v \omega \cos \alpha$

Now comes the tricky part. What we really want to do is minimize the error $e$ by controlling the turn rate $\omega$, but the above equation is non-linear and we prefer to design control laws with linear systems. So let's make up a new control input $\eta$ that is related to $\omega$:

$\eta = v \omega \cos \alpha$

Then we can make a feedback control law for $\eta$. I'll go straight to the answer and then follow it up with the details if you are interested...

The feedback controller can be a full PID as shown below:

$\eta = -K_p e - K_d \dot{e} - K_i \int e dt$

And then we calculate the necessary turn rate $\omega$:

$\omega = \frac{\eta}{v \cos \alpha}$

Normally you might do this by using a measurement of $\alpha$, but since you are only measuring $e$ you could just assume that term is constant and use:

$\omega = \frac{\eta}{v}$

Which is really just using a PID control law for $\omega$ based on $e$ but now with the factor $\frac{1}{v}$ in the gains.

With $\omega$ known, you can compute the necessary wheel speed differential as follows (based on your variable names, and where $b$ is the width between wheels):

midSpeed + value $ = \frac{1}{2} \omega b + v$

$v = $ midSpeed

value $= \frac{1}{2}\omega b$

Overall, you are computing $\omega$ using a PID control law as a function of lateral error $e$ (coming from your sensor). You then compute value from the value for $\omega$ and use it to determine the left and right wheel speeds.


Now, read on for more details regarding the error dynamics and linearized control system:

We can write out the system dynamics like this, where we consider $z$ to be the vector of the error states.

$z = \begin{bmatrix} \dot{e} \\ e \end{bmatrix}$

$\dot{z} = \begin{bmatrix} 0 & 0 \\ 1 & 0 \end{bmatrix} z + \begin{bmatrix} 1 \\ 0 \end{bmatrix} \eta$

If you are familiar with linear control theory then you can start to see how this is a convenient form where we can make a feedback control law with input $\eta$ as a function of the error:

$\eta = -\begin{bmatrix} K_d & K_p \end{bmatrix} z$

$\dot{z} = \begin{bmatrix} 0 & 0 \\ 1 & 0 \end{bmatrix} z - \begin{bmatrix} 1 \\ 0 \end{bmatrix} \begin{bmatrix} K_d & K_p \end{bmatrix} z$

$\dot{z} = \begin{bmatrix} -K_d & -K_p \\ 1 & 0 \end{bmatrix} z$

This closed-loop system has the following characteristic equation:

$s^2 + K_d s + K_p = 0$

Which results in the poles (this is a PD control law, not PID):

$p = -\frac{1}{2}K_d \pm \sqrt{\frac{1}{4}K_d^2 - Kp}$

So if you wanted a critically damped system with no oscillations around the line, you could choose one of the gains and use the following relationship to get the other (start with smaller gains and tune until you get the response you want):

$K_p = \frac{1}{4}K_d^2$

$\endgroup$
3
  • $\begingroup$ No problem, the only thing I didn't talk about was how to convert your 8-bit sensor reading into an estimate of the lateral error. That shouldn't be too hard but let me know if you need some ideas! $\endgroup$ Nov 28, 2015 at 10:54
  • $\begingroup$ I can do that.. But I have another question. When implementing this kind of a kinematic model, there can be error due to factors like mass, friction of the robot. How to minimize the error due to those factors..? Do I need to implement a kinetic model..? I think it would be hard.. $\endgroup$
    – Ramesh-X
    Nov 28, 2015 at 11:02
  • $\begingroup$ What I have shown here is for a robot like yours but assuming that the wheel does not slip sideways. Mass has no consequence here since our input is the actual turn rate $\omega$, not the applied torque. This then assumes your robot has its own control system for applying appropriate voltage to the motors to achieve the input turn rate and speed. You are referring to a dynamic model, which is indeed harder but not too difficult. The real question is: do you need to? If your robot accepts $v$ and $\omega$ commands, then you don't have to worry about it. $\endgroup$ Nov 28, 2015 at 11:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.