CS6555 Computer Animation – Lab 5 – Simple Car Control

This lab was an open assignment where we were given the freedom to make up our own animation project of limited scope. There were many topics that were available and I played with a few potential projects; however, above all others there was segment of material that appeared interesting and challenging that requires considerable knowledge to properly implement a convincing demonstration. When I decided on this topic, I knew that I would not be able to complete the project in a short span, so I requested an extension at the cost of an incomplete. I ended up spending several months working on this project and I am very satisfied with the practical knowledge I gained choosing such a challenging project over the more obvious and less intellectually stimulating options I considered. The irony of this project though is that the end product appears mundane which after weeks of watching the dynamics explode, bad planning, and bad control is fantastic but obscures the complexity underlying the system. Below is a video of the car and following that is a report I submitted along with the source code.

Overview

A car is a nonholonomic system meaning that the system cannot be integrated. Nonholonomic implies that paths between states are curves rather than linear and therefore the system must pass through intermediate states in order to reach the predicted state. To correct error, the system must also follow a curved trajectory but summing system inputs does not result in rectification due to nonholonomy.

A car's degrees of freedom are constrained by the rolling motion of the wheels and a car has a limited range of steering angles constrained by limitations imposed by the mechanical linkage that make up the steering system. A typical car has a steering range somewhere around +/- 30 degrees. Additionally, a car cannot move unless it has a speed input driving the car forward or backward. The turning radius of the car, i.e. the radius of the circle the rear axel rotates around, is subject to the speed that the car carries through the turn. A car moving at slow speed through a small steering angle will turn more sharply than the same car moving through the same steering angle at a fast speed. This dependency of curvature subject to speed makes a car nonholonomic.

This project implemented dynamic control of a simple car following a prescribed trajectory. Modeling the system required kinematic and dynamic models, planning and control systems, and a dynamical simulation. The implementation was produced in the Gazebo simulator[1] using the Open Dynamics Engine(()ODE())[3] to model dynamical behavior.

Kinematic Model

The car kinematic model is based on the simple car model[2]. For the sake of simplicity, the world in which this car operates is treated as a flat plane. In this case, the car's state can be described by the state (q = (x,y,\theta)). The center of the rear axel (r) acts as the center of the car with the (x)-axis pointing along the longitudinal axis of the car (()forward()). Let (s) denote the signed speed of the car and let (\phi) denote the steering angle. Let the wheel base (L) denote the distance from the front axel (f) to (r). Let (u = (u_s, u_\phi)) define a command for the car. Given the above, the change in state can be defined as:

(\dot{x}=u_s\cos\theta)

(\dot{y}=u_s\sin\theta)

(\dot{\theta}=\frac{u_s}{L}\tan\phi)

Diagram of the car kinematic model

Dynamic Model

The center of mass is located at the origin of the car local frame. The forward and backward directions are along the car local frame's negative and positive (x)-axis respectively and the left and right directions are along the car local frame's positive and negative (y)-axis respectively.

Each wheel is a cylinder attached to a bearing joint at the wheel's center that rotates around the local frame's (x)-axis. The rear bearings attach to the car body allowing the rear wheels to roll freely. The front bearings attach to spindle links that attach to kingpin joints. The kingpins attach the front wheel assembly to the car body and rotate around the car frame's (z)-axis. The front wheel assemblies allow the wheels to roll freely and to steer by applying torque to the kingpins.

The steering linkage is a virtual double four-bar design which allows the innermost wheel to travel a shorter arc than the outer wheel and helps to minimize wheel sliding and skidding when steering. The steering linkage is virtual in that the geometric constraints are applied when a steering angle is provided but the linkage is not physically modeled in the car geometry. The steering box joint and steering link allow steering angles to be maintained and dynamically controlled using a component subject to dynamic forces. Steering angles are computed and input into the steering box and the state of the steering box (()steering angle()) is transmiitted to the kingpins via the steering linkage.

The center of the rear axel is modeled with a differential joint and driveshaft link. Due to the kinematic model, the position of the car is not measured relative to the center of mass (()CoM()) but is instead measure relative to the center of the rear axel (()CoA()). The state of the car is therefore a function of the center of axel where the position of the car is the position of the rear differential/driveshaft in the world frame and the orientation of the car is the direction of the normalized vector drawn from the rear differential/driveshaft to the steering box/link in the world frame.

Diagram of the car dynamics model. The positions of the center of mass (c), the kingpins (k), the differential (d), and steering box (s) are visible along with the virtual geometry of the double four-bar steering linkage.

Planning

A plan for the car to follow is computed from a lissajous curve using parameters that generate a figure eight(()(a=1), (b=2), (\delta=\frac{\pi}{2})()). The lissajous function is used to compute the state of the car along discrete steps along the curve. From a given state and a previous state, a command to move from the previous state to the given state is computed. Each planned state and planed command is then added to a list for use by the controller. In order to compute the command, the inverse differential equation of the kinematic model is used which requires a minimization.

Control

Although the plan is in a sense perfect for the kinematic model, the performance in the dynamical simulator results in side effects, e.g. oversteer, understeer, skidding, and control lag, which ensure that the car cannot follow the plan exactly as prescribed simply by following the planned commands. These effects result in the car drifting off the plan or responding late to control input and therefore the car can reasonably track the plan but there is substantial accumulation of error and therefore the car cannot reach the end of the plan in the prescribed time and state. The planned commands are therefore handled as feed-forward commands and are modified by dynamically computed feed-back commands.

Feed-back commands are generated by computing the state error between the current state of the car and linear interpolation of the planned states. The state error is fed into the kinematic differential equations to compute a command. The feed-back command is then scaled and capped to minimize extreme conditions such that the feed-back command will continually adjust the system but no single command will make the system unstable.

The feed-back command is added to the feed-forward command to generate the current command. This combination constantly readjusts the system behavior. Although the current command will not fully realize the actual predicted planned state, the constant input of the feed-back command will allow the system to reasonably approximate the planned behavior.

The current command is fed into the controller which is composed of a speed controller and steering controller. The speed controller is implemented as a proportional only controller and the steering controller is implemented as a proportional-derivative controller. Speed is affected by applying a force directly to the CoG of the car which is like a phantom hand pushing the car. Note, differential drive was considered but was determined out of scope for this project. Steering is affected by PD control on the steering box and the state of the steering box is fed through the double four-bar steering computation which sets the angle of each respective kingpin resulting in the correlating angle to be applied to each steering wheel.

The planner produces the set of feedforward commands (u_{ff}) as well as a set of expected states (q). As the car follows the commands, inverse kinematics produces a corrective feedback command (u_{fb}) determined from the error between the current state and the next expected state which is linearly interpolated from the set of expected states. The actual command (u) is the summation of (u_{ff}) and (u_{fb}) which is then fed into the dynamics controller.

Results

The experiment was run in Gazebo 1.8.6 and demonstrates that the kinematic, planning, control and dynamic models can be combined together to produced the desired trajectory and behavior. The combination of feed-forward and feed-back control enable the car to closely approximate the planned trajectory in the expected time. The lissajous function was scaled such that the car maintains a moderate speed so that it does not skid in corners and also does not stop in corners which can occur when the steering angle is high and the speed is low. The overall period of the trajectory is approximately 64 seconds.

State

Figure[State] shows the car follows the plan with reasonable accuracy. The O in the figure indicates the start position and the X indicates the end position and the overlap between the start and end positions shows that the car ends its route in close proximity to the expected position as indicated by the start position.

Planned(()P()) and Actual(()A()) Commands

Figure[Planned(()P()) and Actual(()A()) Commands] indicates the difference in the planned commands, i.e. the feed-forward commands, and the current command. The control lag is evident from the elongation in wavelength of the actual commands and shows that the car completes the trajectory slower than the planned expectation. Additionally, while the speed is a fairly smooth curve, the state error results in substantial steering correction.

Speed Feed-Forward, Feed-Back, and Combined Commands

Steering Angle Feed-Forward, Feed-Back, and Combined Commands

Figure[Speed Feed-Forward, Feed-Back, and Combined Commands] and Figure[Steering Angle Feed-Forward, Feed-Back, and Combined Commands] give a more detailed view of the summation of commands. In the speed plot, the feed-back control peaks quickly to account for starting from rest and then settles into a smooth curve that has maximum peaks about the exits of turns to assist in acceleration and steadily diminishes along the straight-aways into minimum troughs when decelerating into the turns. The cap on feed-back speed keeps the system from generating a large spike due to initial error and then has no further impact and therefore the car does not immediately explode into instability due to speed. In the steering plot, the feed-back oscillates quickly from left and right extremes which is evident in the animation of the car. The cap on feed-back steering keeps the steering from generating extreme inputs that will cause the steering linkage to exceed its constraints or to cause singularities.

Feedback Error

Figure[Feedback Error] shows the state error determined in the feed-back command calculation. The error spikes quickly at start due to starting from rest but quickly settles into oscillating about zero error. The end error state shows that the car completes the trajectory with relatively little error.

References

[1] Open Source Robotics Foundation. Gazebo simulator, 2013. http://www.gazebosim.org/
[2] Steven M. LaValle. Planning Algorithms. Cambrige University Press, 2006.
[3] Russell Smith. Open dynamics engine, 2007. http://www.ode.org/

Comments are closed.