(adsbygoogle = window.adsbygoogle || []).push({}); 1. The problem statement, all variables and given/known data

Consider an inverted pendulum system as described in https://en.wikipedia.org/wiki/Inverted_pendulum. The system consists of a cart with massMto which a pole of lengthland massmis affixed via a pivot point. Forces applied to the cart move it along a track. At any point in time the system can be described by the angle of the poletheta(radians, zero refers to an upright pole), the angular velocity of the poletheta_dot, the position of the cart along the trackx, and the cart's velocityx_dot.

The following C++ code updates the state of the system given a force input and a timestep size tau:

This code comes from a reasonably reliable source so I assume it is correct. I wish to modify this system by adding a second cart atop which the first cart rests. This second, lower cart rests upon the track and has no pole, forming a stack of carts. Forces may now be applied independently to each cart.Code (Text):float temp = (force + m * l * theta_dot * theta_dot * sin(theta)) / (M+m);

float thetaacc = (gravity * sin(theta) - cos(theta) * temp) / (l * ((4.0/3.0) - m * cos(theta) * cos(theta) / (M+m)));

float xacc = temp - m * l * thetaacc * cos(theta) / (M+m);

// Update the four state variables, using Euler's method.

x += tau * x_dot;

x_dot += tau * xacc;

theta += tau * theta_dot;

theta_dot += tau * thetaacc;

3. The attempt at a solution

This attempted solution first calculates the movement of the lower cart based the force applied to the lower cart (lowerCartForce) then applies the lower cart's acceleration to the temp variable. (lower_x and lower_x_dot refer respectively to the position and velocity of the lower cart)

My question to these forums: Is the physics of the above system accurate? Specifically have I correctly transferred the lower cart forces to the upper cart?Code (Text):// Lower cart physics calculations. This assumes wheel rigidity -- eg lower cart is not

// influenced by movements of the upper cart.

float lower_xacc = lowerCartForce / (lowerCartMass + M + m);

lower_x += tau * lower_x_dot;

lower_x_dot += tau * lower_xacc;

// This next line is the only one that differs from the last code block

float temp = lower_xacc + (force + m * l * theta_dot * theta_dot * sin(theta)) / (M+m);

float thetaacc = (gravity * sin(theta) - cos(theta) * temp) / (l * ((4.0/3.0) - m * cos(theta) * cos(theta) / (M+m)));

float xacc = temp - m * l * thetaacc * cos(theta) / (M+m);

// Update the four state variables, using Euler's method.

x += tau * x_dot;

x_dot += tau * xacc;

theta += tau * theta_dot;

theta_dot += tau * thetaacc;

**Physics Forums - The Fusion of Science and Community**

# Double Cart Inverted Pendulum Mechanics

Know someone interested in this topic? Share a link to this question via email,
Google+,
Twitter, or
Facebook

Have something to add?

- Similar discussions for: Double Cart Inverted Pendulum Mechanics

Loading...

**Physics Forums - The Fusion of Science and Community**