Gain Tuning for Leaning Two and Three Wheeler Vehicles

Altair Driver controls the direction and lean angle of leaning vehicles by steering the front fork. Altair Driver counter steers initially to create an unbalanced moment about the vehicle’s longitudinal axis to start the vehicle leaning in the demanded direction and then steers to control the vehicle’s lean angle match a demanded lean angle. For open loop events like step-steer and sinusoidal steer, the demanded lean angle is a function of time and the output of the event is the vehicle’s path. For closed loop path following events, like constant radius cornering or road course drive, the demanded lean angle is the sum of a target lean angle and corrective lean angle. The target lean angle depends on the vehicle speed, the path curvature, and the vehicle mass and the angular momentum wheels and tires. The target lean angle balances the moments on the vehicle due to gravity, lateral acceleration, and the change in angular momentum of the wheel and tires. While the corrective lean angle is meant to minimize the path error at the look-a head-time in the future. For more information see the Leaning Two and Three Wheeler Vehicles topic.

Please note, however, that if the vehicle speed drops too low, steering the front fork is ineffective because neither the tire force nor the change in direction of angular momentum of the wheels and tires produce a moment on the vehicle large enough to overcome the moment on the vehicle due to gravity and the vehicle capsizes. One set of controller gains may allow Altair Driver to control the vehicle to a lower speed than another set all else being equal, but given that leaning vehicles are inherently un-stable at low speeds capsizing at low speed cannot be eliminated by tuning the gains.

For both open loop and closed loop events Altair Driver employs a PID controller of type ‘Follow_Lean’ in the Altair Driver File (.adf). The input to the ‘Follow_Lean’ is the error between the demanded lean angle and actual lean angle. The ‘Follow_Lean’ controller’s output is the front fork steer angle. For open loop events the demanded lean angle is an explicit function of time. For path following events the demanded lean angle comes implicitly from the feed-forward steer controller that references the ‘Follow_Lean’ controller.

When you run an event on a leaning vehicle, MotionView writes an Altair Driver File (.adf) for the event which sets the proportional, integral and derivative gains for the ‘Follow_Lean’ PID controller. For example, the .adf file will contain a block like this:
[PID_CONTROLLER]
TAG = 'PID'
TYPE = 'FOLLOW_LEAN'
KP = 20
KI = 30
KD = 7
You can edit Altair Driver File to modify these gains and then run a simulation using the modified file to see the effects on the gains. To do this:
  • Add an AltairDriverFile event to the same model that generated the Altair Driver File (.adf) you want to edit.
  • Edit the AltairDriverFile event and select .adf file you will edit.
  • Edit the .adf file to modify the ‘FOLLOW_LEAN’ gains as you desire.
  • Run the AltairDriverFile event to produce new output you can compare to the original event with default gains.

Now you can iterate to tune the gains to meet your needs. A method for tuning the gains to achieve good performance in a constant radius cornering event is described below.

How to Tune a 'FOLLOW-LEAN' PID Controller

A common method for tuning a PID controller is outlined in the following steps:
  1. Initially, set the integral () and derivative () gains to zero, then increase proportional () gain until the vehicle shows an oscillating behavior.
  2. Increase the gain until oscillations stop.
  3. Repeat the two steps above until increasing the gain does not stop the oscillations.
  4. Increase the gain until it brings the system to the setpoint with the desired/lesser number of oscillations, but a quicker response.
The table below shows the effect of increasing gain values on rise time, overshoot, and setting time.
Parameter Rise Time Overshoot Setting Time
Decrease Increase Small change
Decrease Increase Increase
Minor change Decrease Decrease

Example Constant Radius Cornering (CRC) Event

For a default wizard-built motorcycle model and Constant Radius Cornering (CRC) event, the gain values of the ‘FOLLOW_LEAN’ PID controller are tuned step by step to achieve good steering performance. The controller performance may be seen by plotting the REQSUB “steer control feedback” output request channels f2 (demand lean angle) and f3 (actual lean angle) from either the .plt, .mrf, or .abf output files in HyperGraph.

Step 1: Set Integral and Derivative Gains to Zero

Edit the constant radius cornering .adf file and set the ‘FOLLOW_LEAN’ proportional () gain to 10 and the integral () and derivative () gains to zero (0).



Run a simulation using an AltairDriverFile event that references the edited .adf file. Plot actual lean angle and/or animate the results in HyperView. Observe that motorcycle capsizes (lean angle >> PI/4 radians) as shown in the plot below:



Figure 1.
Step 2: Increase Proportional Gain

Edit the constant radius cornering .adf file again, keeping the integral and derivative gains to zero, increase the proportional gain from ten (10) to thirty (30) as shown below:



Rerun the AltairDriverFile event using the edited .adf file. Again, plot the actual lean angle or animate the results in HyperView. At higher speed and lateral acceleration, the motorcycle becomes unstable and capsizes.



Figure 2.
Step 3: Increase Derivative Gain

Edit the constant radius cornering .adf file again and introduce a derivative gain of ten (10) as show, while leaving the proportional gain unchanged:



Rerun the AltairDriverFile using the edited .adf file. Again, plot the actual lean angle and demanded lean angle in HyperView. Observe that the motorcycle does not capsize, but there is a large error between the actual and demanded lean angle:



Figure 3.
Step 4: Increase Integral Gain

Edit the constant radius cornering .adf file again and introduce an integral gain of twenty (s0) as show, while leaving the proportional and derivative gains unchanged:



Rerun the AltairDriverFile using the edited .adf file. Again, plot the actual and demanded lean angles in HyperView. Observe that the motorcycle does not capsize and the error between the actual and demand lean angle is small:



Figure 4.