Unexpected simulation behavior in variable length cartpole #2374
Replies: 1 comment
-
I got it working by separating the hinge and slide joints between an intermediate body with low mass/inertia. However, I would like to point out that the documentation says that an arbitrary set of joints can be used to create degrees of freedom between two bodies: https://mujoco.readthedocs.io/en/stable/modeling.html#kinematic-tree So it seems there was a problem with the simulator, unless someone can point me towards what I was doing wrong. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Intro
Hi!
I am a graduate student/robotics hobbyist working on some basic trajectory optimization problems.
My setup
Pymujoco version 3.1.1
Ubuntu 22.04.5 LTS
My question
TLDR
I am simulating a mass that is connected to a radial sliding joint -> hinge joint -> horizontal sliding joint chain, all of which are frictionless and unactuated. This mass is unconstrained and should fall straight down, but it falls with a horizontal component.
Original question
I am attempting to verify that my analytical model for a cartpole with variable length pole matches simulation. The cart and pole length are actuated, with pole angle free. Both the cart and bob (CoM of pole) are simulated as point masses with low moment of inertia.
The problem I'm running into is that under certain conditions the simulation does not appear to behave in a physical way. If the pole length is left to be free/unactuated and the pole length is within joint limits, the bob should drop vertically. Instead, the bob falls at a small angle from the vertical. I've attached plots to depict this behavior. The data labeled 'Euler' corresponds to my analytical model.
The variables are as follows:
x_c: x position of cart
x_p: x position/horizontal displacement of bob w.r.t. cart
r_p: distance between bob and hinge joint
v*: velocity of quantity
What I'm seeing is that under this free fall condition, vx_p should stay 0 but it does not, resulting in some change in x_p during the simulation. I've double checked that I'm setting x_p = r_p * sin (theta). Intuitively this seems to be consistent with the hinge joint being damped - gravity pushes the bob along the axis of the pole, changing the horizontal displacement. I am using the default damping settings for all my joints in the XML so I'm not sure why this would be the case (or how to change it).
I have also simulated a similar system but with the hinge joint fixed instead of moving on a cart. For this system, the bob correctly falls vertically and my model and the simulation track each other closely (until the slide joint limit is reached). The horizontal displacement changes from 0.399 to 0.396 over 100 timesteps.
Would really appreciate some help with this. Thank you!
Minimal model and/or code that explain my question
Cartpole model:
minimal XML
Slide pendulum model:
minimal XML
Code snippet for running cartpole:
Python
Confirmations
Beta Was this translation helpful? Give feedback.
All reactions