By Preston Ohta

I approached this problem by first determining an appropriate position function for the cart. Given its initial position is x = 0 and its final position is x = 10, my function p(t) had to reflect this state. However, to minimize travel time, the function had to quickly reach x = 10 and, ideally, without much overshooting. I then concluded that my function could follow the form:

p(t) = -K/exp(t-L) + M

where K, L, and M are constants.

After testing this function in Matlab, I settled with the following function:

p(t) = -2/exp(t-1.61) + 10

From this point, I adjusted the kp and kd constants of the cart and pole to enable stability and rapid movement to the goal line. The inverted pendulum has the unique property of being in an unstable equilibrium, whereas the cart has an unchanging amount of stability with respect to its position. This meant that, in order for the pendulum to remain balanced, priority in movement must be given to it, rather than to the cart, to successfully reach the goal line. This would translate into the magnitude of the kp and kd constants of the pole being greater than those of the cart.

The unstable equilibrium and mass properties of the pole caused another, less intuitive behavior. To reach the goal while balancing the pole, the pole must initially be tilted forward, which can only be achieved if the cart first moves backward. I realized that this behavior could be achieved without modifying the position function by making kp of the cart negative, causing the cart to initially move away from the goal before being overwhelmed by the larger kp and kd values of the pole, which would then cause the cart to move forward and remain stable at the 10 meter line.

A similar, counterintuitive property became present with the kd value for the cart. To enable deceleration of the system, the momentum of the pole must be opposed, which means that the pole must be behind the vertical centerline of the cart when it is decelerating. Therefore, before the system can decelerate, the cart itself must actually accelerate to move ahead of the pole. This consequently led to my conclusion that kd for the pole should also be negative because the cart must move faster than the pole prior to deceleration of the entire system (so the pole can remain balanced during deceleration) as the cart nears the goal.After tuning the controller, I found that my fastest recorded time resulted from the following values:

Kp_c = -45

Kd_c = -25

Kp_p = 975

Kd_p = 55

With these values, I completed the time trial in 2.326 seconds.

View simulate_planarCartPole.m View getDesiredTrajectory_planarCartPole.m