# Physics-Based Vehicle Simulation Using PD Servo
## 4 Vehicle Simulation
### Vehicle Control  
Given an input trajectory, a vehicle runs on a line or a curve with a specified period of time (or frames). For example, given a long trajectory and a fixed time, the vehicle moves with a high velocity while it moves more slowly on a shorter trajectory. In the physics-based simulation system, the PD servo estimates proper torque to steer the vehicle toward the target point. The direction and velocity of the wheels are controlled by forcing the vehicle to follow the input trajectory as closely as possible. Figure 3 shows the directional and velocity changes of the vehicle to steer toward the target point. At every frame, the PD servo acquires the current state of direction and velocity of the vehicle on the trajectory and compares them with future states for the next several frames (i.e., next three  
Figure 1: Vehicle model: deformable front cover with rotational and translational axes used for wheel movements.  
frames). At the starting moment, the system assumes that the vehicle requires a certain period to align itself with the input trajectory. For this, a hypothetical trajectory is generated at the starting moment of the simulation and concatenated to the input trajectory, which allows directional change and velocity increase before the vehicle enters the input trajectory with proper direction and velocity. For a smooth transition between those trajectories, the ending point of the hypothetical trajectory becomes the starting point of the input trajectory as shown in Figure 4.  
When the vehicle enters the input trajectory, the changes in direction and velocity are estimated from the positional and angular differences of wheels on the trajectory between the current frame, \(c\), and the target frame, \(t\), respectively. For example, if the trajectory from the current position to the target position is close to a straight line, the steering unit controls the direction of wheels to be equal to the direction of a vehicle body. If the trajectory from the current position to the desired position is a curve, the steering unit makes the direction of wheels different from the body direction. The angle  
Figure 4: Path simulated by a proportional derivative (PD) servo on hypothetical and input trajectories.  
Figure 3: Steering vehicle toward target point.  
Figure 2: Overview of vehicle simulation on input trajectory.  
difference between wheels and body is estimated by the gradient of the trajectory. The change of velocity is determined by calculating the torque value \(\tau\) (N\(\cdot\)m), as follows:  
\[\tau=k*\frac{(P_{t}-P_{c})}{R_{w}}, \tag{1}\]  
where \(\tau\) is the rotational torque value required to change from current state to target state, \(P_{t}\) is target position of vehicle, \(P_{c}\) is current position of vehicle, \(R_{w}\) is radius of wheels, and \(k\) is a constant gain value of the PD servo. For each frame, the directional and velocity changes are applied to the wheels to maintain the vehicle on the input trajectory. However, frequent changes of torque values for each frame can cause undesired artifacts such as jittering and lagging of vehicle. Moreover, the influence of external forces such as gravity and friction are not considered in Equation (1), which causes directional and positional differences between the simulated and input trajectories. For these reasons, the proposed system splits the input trajectory into several segments and tries to search an optimal trajectory for each segment in an iterative way, as described in the next section.