Implement cart and pendulum simulation