Double Cart Inverted Pendulum Mechanics

In summary, the conversation discusses an inverted pendulum system consisting of a cart and a pole, where forces are applied to move the cart along a track. The system can be described by four state variables: the angle and angular velocity of the pole, and the position and velocity of the cart. C++ code is provided to update the state of the system, and the conversation then introduces a modification to the system by adding a second cart. The attempted solution involves calculating the movement of the lower cart and transferring its forces to the upper cart. The accuracy of this solution is questioned and more information is requested on the physics behind the code.
  • #1
CandidClam
2
0

Homework Statement



Consider an inverted pendulum system as described in https://en.wikipedia.org/wiki/Inverted_pendulum. The system consists of a cart with mass M to which a pole of length l and mass m is 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 pole theta (radians, zero refers to an upright pole), the angular velocity of the pole theta_dot, the position of the cart along the track x, and the cart's velocity x_dot.

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

Code:
    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;

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.

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)

Code:
    // 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;

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?
 
Physics news on Phys.org
  • #2
You will get better advice here if you first describe how you think the original code works and then how you intend to modify it - paying attention to the physics, not C++.
 
  • #3
The original code was not my own creation and I've tried to puzzle through it several times without much success. However, here's an attempt:

The second and third lines of the code are calculating the acceleration of the pole and cart. I'm still trying to figure out what the temp variable actually represents. The 3rd line computes cart acceleration so the units should be m/s^2. Since temp appears in the 3rd line followed by subtraction, I feel that it's units should also be m/s^2. If anyone is able to understand what exactly temp is computing, that would in itself be a great help.
 

1. What is a double cart inverted pendulum?

A double cart inverted pendulum is a type of mechanical system that consists of two carts connected by a pole or rod that is free to rotate. The carts can move horizontally along a track, and the goal of the system is to maintain the pole in an upright position.

2. What are the applications of double cart inverted pendulum mechanics?

Double cart inverted pendulum mechanics have various applications, including robotics, control systems, and transportation. They are also used in research and education to study dynamic systems and control theory.

3. What are the challenges of controlling a double cart inverted pendulum?

Controlling a double cart inverted pendulum is challenging due to the complex dynamics and nonlinear behavior of the system. It requires advanced control strategies and precise sensing and actuation mechanisms.

4. How does feedback control work in a double cart inverted pendulum?

Feedback control in a double cart inverted pendulum involves using sensors to measure the position and velocity of the carts and the angle of the pole. This information is then fed back to the controller, which adjusts the control inputs to maintain the stability of the system.

5. What are the benefits of studying double cart inverted pendulum mechanics?

Studying double cart inverted pendulum mechanics can help scientists and engineers understand the principles of dynamic systems and control theory. It also has practical applications in fields such as robotics and transportation, making it a valuable area of research.

Similar threads

  • Introductory Physics Homework Help
Replies
20
Views
1K
  • Introductory Physics Homework Help
Replies
9
Views
700
  • Mechanical Engineering
Replies
1
Views
1K
  • Programming and Computer Science
Replies
1
Views
2K
  • Introductory Physics Homework Help
Replies
5
Views
1K
Replies
2
Views
59
  • Introductory Physics Homework Help
Replies
5
Views
5K
  • Introductory Physics Homework Help
Replies
21
Views
1K
  • Introductory Physics Homework Help
Replies
8
Views
2K
  • Introductory Physics Homework Help
Replies
3
Views
1K
Back
Top