The Comparator (Cp) is an element of the Autonomous Car (AC) control loop which connects three elements. The Cp receives inputs from the Path Planning and from the Filter and outputs data to the Controller. Its name reveals its task: compare the desired positions of the AC (computed with the Path Planning element) with the AC current position (estimated with the Filter element). The result of this operation, named the error, is outputted to the Controller.
We will remind that the desired position of the AC is a smooth trajectory which links the start point with the target point. In fact, the trajectory is defined like a set of m points.
(1)
Usually, for a close loop system, a comparator computes the error by subtracting the estimated value from the desired value. This solution is not possible for the AC comparator. Here the goal is to be as close as possible to the trajectory, which links the mentioned points and not to jump from one point to another.
Figure 1. Comparing the estimated position (red dot) with the desired positions (black dots)
This observation suggests that it is more practical to relate the robot estimated position with the segment defined by two successive points (see figure 1). This means that, in a particular moment of locomotion, from all of m-1 segments, one segment must be selected. We will name this segment the active segment.
The Controller element (Ct) receives the input from the comparator (Co) and output the command signal to the AC. For our close loop system model the command signal generates the AC steering angle. Because there are many possibilities to define the Ct transfer function and to compute its gains, the Ct problem consist on choosing a solution from these possibilities.
In conclusion the Cp, Ct problems consist on:
- For the Cp is necessary to define :
- A procedure for the active segments selection;
- The procedure to compute the error;
- For the Ct is necessary to select:
- A suitable transfer function;
- A method of gains computation.
The error is defined like the distance from the AC current position to the active segment. In figure 2 we have illustrated this concept for two positions of the AC.
Figure 2. The error definition
Figure 2 illustrates two possible position of the AC which are symmetric relative to the vector defined from point i to point i+1. Even the length of the errors, illustrated in figure 2, is equal, the active segment orientation gives us the possibility to distinct them by defining the sign of the error
(2)
(3)
(4)
The active segment selection depends on the angel between vectors u and v i.e. if the angel is bigger than 90o then the active segment will be replaced from to .
Figure 3. The active segment selection
(5)
Another method used in active segment selection is to compare the projection of vector v on the support of vector u with the length of vector u.
In conclusion the error computation procedure consists on:
- Select the first segment like the active segment;
- Until condition (5) allows it compute the error with (4);
- Change the active segment accordingly to (5) and go to step 2, until the last segment is achieved
The command signal computation
The chosen controller is the PID. The controller transfer function is given by:
(6)
where: u is the command signal, e is the error computed with (4) and KP,V,I are the controller gains.
In order to compute the gains several methods can be used. We have selected the twiddle method which consists on searching for a particular combination of the gains values which minimize the value of the Total Error (TE).The TE is a cumulated error of tracking an imposed trajectory. Shortly, the twiddle is an iterative algorithm and can be describe by the following steps:
- Impose a number of total iterations Nmax, and an error tolerance Tol;
- Choose a trajectory; This can be a straight line; an open or an closed contour;
- Propose (guess) an initial set of values for the gains Gains=[KP,KV,KI];
- Impose an initial adjustment increment for each gain d_Gains=[dKP,dKV,dKI];
- Run a simulation of the AC which follow the desire trajectory; Compute the TE (7);
- Modify the gains by increasing or decreasing them accordingly to the mentioned increments Gains=Gains+d_Gains; The modifications are made in the following order: the proportional gain; the derivative gain and the integrative gain;
- After each modifications of the gain, a simulation is made and the actual value of the TE is computed;
- If the actual value of the TE is smaller than the error tolerance or if the number of iterations is equal to the total number of the iterations stop the searching loop;
- Compare the actual value of the TE with its previous value; Accordingly modify the increments d_Gains and go to 6; increase the number of iteration with 1;
(7)
Figure 4. The twiddle algorithm flowchart
Figure 4 contain the previous algorithm flowchart. The flowchart is composed from an initialization block and continues with an iterative block which modifies the controller parameters. The iterative block is composed from three blocks which have an identical structure but refers to different gains.
Figure 5. The close loop diagram used in twiddle algorithm
Several observations are necessary.
- In order to compute the TE simulations are made. The simulations consist on controlling the AC to track the chosen trajectory. The diagram from figure 5 illustrates the close loop system used to simulate the trajectory tracking.
- The computed command u is related to the front AC wheel steering angle γ (see figure 6):
- in an proportional way
(8)
- or, in order to saturate the value of the steering angel to
(9)
Figure 6. The steering angle function
Figure 7 illustrate the connection between the error sign and the steering angle sign. For more details of AC models consult the Model section of this site.
Figure 6. The steering angle for two possible situations