3D pendulum and equations of motion of multi-body systems (KanesMethod)

280 views
Skip to first unread message

Nuno

unread,
Aug 5, 2016, 1:01:39 PM8/5/16
to sympy
I'm trying to get familiar with the sympy and its uses in obtaining the equations of motion of multi-body systems.

In order to test things out I decided to use an example similar to a 3D pendulum where I have two masses. However the mass that is not fixed has a force and torque applied to it. So I wanted to have a distance constraint between the two masses: (r_a - r_b)^2 - L = 0

However I'm not sure how I should set this constrain in python/sympy in order to input it to KanesMethod()

I'm sorry if this is question is a mess and thanks in advance for any help

Nuno

unread,
Aug 9, 2016, 11:28:55 AM8/9/16
to sympy
Since I think I was not clear with the first question, I'm going to try and explain it better now. 

What I'm trying to achieve is a simple example similar to a 3D pendulum. At the time I talked about 2 masses, but one of those was the anchor point, so in fact everything can be done with only one mass.

The twist here (in comparison with the simple 3D pendulum) is that besides the gravitational force, the mass is under the effect of:
- A force in the x-axis of the mass
- A torque about the z-axis of the mass

Futhermore, since I'm choosing to describe the system using the (x,y,z) coordinates of the mass (and 3 euler angles) I was trying to add a distance constraint:
      (r_anchor - r_mass) - L = 0

Here is the jupyter notebook I created in order to define this system:

Could someone help me understand any mistake I'm making and point me in the right direction?

Thanks in advance,
Nuno

Jason Moore

unread,
Aug 10, 2016, 6:27:42 AM8/10/16
to sy...@googlegroups.com
Nuno,

If you re using KanesMethod it supports two types of constraints: holonomic and non-holonomic. You can supply these constraints to the initializer and then the equations of motion will be formed that take the nonholonomic constraints into account. Note that if you have holonomic kinematic constraints, you'll have to ensure that any of your numerical analyses code properly deals with that constraint, for example you may need to numerically solve for your dependent coordinates when setting initial conditions for simulation.

--
You received this message because you are subscribed to the Google Groups "sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sympy+unsubscribe@googlegroups.com.
To post to this group, send email to sy...@googlegroups.com.
Visit this group at https://groups.google.com/group/sympy.
To view this discussion on the web visit https://groups.google.com/d/msgid/sympy/fd9a076b-8aad-4aeb-9765-6fc765d4119a%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Nuno

unread,
Aug 10, 2016, 8:06:12 AM8/10/16
to sympy
In the first place thanks for answering.

My doubt right know is connected to the holomonic constraint (distance constraint) and the resulting equations of motion. I don't have much experience with this kind of systems, but the resulting equations of motion seem really large for such a simple problem.

Would it be possible for someone to check it?

The way I'm dealing with the distance constrain right now is:

distance = (mass_cm.pos_from(anchor_cm)) #distance from the mass to the anchor point
holonomic_constraint = [x_m - cable_length*distance.normalize().to_matrix(inertial_frame)[0],
                                    y_m - cable_length*distance.normalize().to_matrix(inertial_frame)[1],
                                    z_m - cable_length*distance.normalize().to_matrix(inertial_frame)[2] ]

Thanks again,
Nuno
To unsubscribe from this group and stop receiving emails from it, send an email to sympy+un...@googlegroups.com.

To post to this group, send email to sy...@googlegroups.com.
Visit this group at https://groups.google.com/group/sympy.

Jason Moore

unread,
Aug 11, 2016, 6:56:08 AM8/11/16
to sy...@googlegroups.com
Nuno,

If you provide a sketch of the system, a description of the system, and what you are hoping to accomplish that will help us be able to help you.
To unsubscribe from this group and stop receiving emails from it, send an email to sympy+unsubscribe@googlegroups.com.

To post to this group, send email to sy...@googlegroups.com.
Visit this group at https://groups.google.com/group/sympy.

Nuno

unread,
Aug 11, 2016, 7:30:50 AM8/11/16
to sympy
Right now I'm trying to get the equations of motion of a 3D pendulum system (spherical pendulum) and I want to describe the system using the (x,y,z) coordinates of the mass as well as its attitude (phi, theta, psi),



In the jupyter notebook (https://nbviewer.jupyter.org/github/ndevelop/sympy_3D_pendulum/blob/master/3D%20pendulum.ipynb) I have added 3 reference frames (Inertial, one for the anchor point and other to the mass). 

The anchor frame is not really necessary since its the same as the inertial frame for this problem, however futher down the line I want to test the system with a mobile anchor point (imagine it as a balloon with a lift force applied in the anchor center of mass).


The mass frame is centered on the "Mass" center of mass (this nomenclature is not the best) and it's orientation in relation to the inertial frame is composed by 3 euler angles.


Now the twist in the problem is that the mass is "actuated". Besides the gravity force acting on its center of mass (along the inertial frame z-axis), there is also a force F applied on the positive direction of x-axis of the mass reference frame and a torque T about the z-axis of the mass reference frame.


Furthermore, I want to "model" the cable connecting the mass to the anchor point, by using a distance constraint:  (r_anchor - r_mass) - cable_length = 0


The goal is to obtain the equations of motion for this system.

I have set everything as described in this jupyter notebook, however I'm not sure if the way I'm doing things is correct, since the resulting equations of motion seem to be really large for such a simple problem. Then again, I'm not experienced with this kind of problems.


Thanks in advance for all the help,

Nuno





Jason Moore

unread,
Aug 15, 2016, 2:13:25 PM8/15/16
to sy...@googlegroups.com
Nuno,

You can only select one set of independent generalized coordinates for things to work out. You seem to be setting two sets, both the cartesian and the angular coordinates. You may need to refer to a dynamics text to see how to go about selecting generalized coordinates.


--
You received this message because you are subscribed to the Google Groups "sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sympy+unsubscribe@googlegroups.com.
To post to this group, send email to sy...@googlegroups.com.
Visit this group at https://groups.google.com/group/sympy.

Nuno

unread,
Aug 17, 2016, 5:28:44 AM8/17/16
to sympy
Jason, thanks again for answering and excuse me for any dumb questions.

When you are saying that I can't use the position (x,y,z) and euler angles (roll, pitch, yaw) as my generalized coordinates, is that something specific to the Kane's Method?
I ask this since that's the first time I hear about that and for example, when one wants to model a rigid body in space (both its position and orientation) those are the generalized coordinates used (Think for example of a quadcopter model).

Thanks,
Nuno


segunda-feira, 15 de Agosto de 2016 às 19:13:25 UTC+1, Jason Moore escreveu:
Nuno,

You can only select one set of independent generalized coordinates for things to work out. You seem to be setting two sets, both the cartesian and the angular coordinates. You may need to refer to a dynamics text to see how to go about selecting generalized coordinates.


On Thu, Aug 11, 2016 at 4:30 AM, Nuno <nmi...@gmail.com> wrote:
Right now I'm trying to get the equations of motion of a 3D pendulum system (spherical pendulum) and I want to describe the system using the (x,y,z) coordinates of the mass as well as its attitude (phi, theta, psi),



In the jupyter notebook (https://nbviewer.jupyter.org/github/ndevelop/sympy_3D_pendulum/blob/master/3D%20pendulum.ipynb) I have added 3 reference frames (Inertial, one for the anchor point and other to the mass). 

The anchor frame is not really necessary since its the same as the inertial frame for this problem, however futher down the line I want to test the system with a mobile anchor point (imagine it as a balloon with a lift force applied in the anchor center of mass).


The mass frame is centered on the "Mass" center of mass (this nomenclature is not the best) and it's orientation in relation to the inertial frame is composed by 3 euler angles.


Now the twist in the problem is that the mass is "actuated". Besides the gravity force acting on its center of mass (along the inertial frame z-axis), there is also a force F applied on the positive direction of x-axis of the mass reference frame and a torque T about the z-axis of the mass reference frame.


Furthermore, I want to "model" the cable connecting the mass to the anchor point, by using a distance constraint:  (r_anchor - r_mass) - cable_length = 0


The goal is to obtain the equations of motion for this system.

I have set everything as described in this jupyter notebook, however I'm not sure if the way I'm doing things is correct, since the resulting equations of motion seem to be really large for such a simple problem. Then again, I'm not experienced with this kind of problems.


Thanks in advance for all the help,

Nuno





--
You received this message because you are subscribed to the Google Groups "sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sympy+un...@googlegroups.com.

To post to this group, send email to sy...@googlegroups.com.
Visit this group at https://groups.google.com/group/sympy.

Jason Moore

unread,
Aug 18, 2016, 3:54:33 AM8/18/16
to sy...@googlegroups.com
No this is not specific to Kane's method. You, as the modeler, get to choose whatever coordinates you want to describe a system including redundant coordinates. But for efficiency and simplicity's sake you are better off choosing a unique set of minimal coordinates, i.e. generalized coordinates. You will get much tidier and easy to work with results if you try to choose a good set of generalized coordinates for you system. The KanesMethod object can work with anything, but things will be much cleaner if you make good gc choices. Your pedulum is redundantly described by all of the coordinates you have. I think you pendulum should only have 2 generalized coordinates.
To unsubscribe from this group and stop receiving emails from it, send an email to sympy+unsubscribe@googlegroups.com.

To post to this group, send email to sy...@googlegroups.com.
Visit this group at https://groups.google.com/group/sympy.

James Milam

unread,
Aug 18, 2016, 10:48:35 AM8/18/16
to sympy
To kind of expand on what Jason's saying a 3D pendulum can be completely defined using just (x, y, z) and you can deduce the angles from these coordinates. In your case the pendulum only has two degrees of freedom (x and y for instance and z be calculated because the pendulum has a fixed length) and is why Jason suggests using only two generalized coordinates. A quadcopter does actually have 6 degrees of freedom and is why it would use (x, y, z) in addition to (pitch, roll, yaw).

Nuno

unread,
Aug 18, 2016, 11:01:23 AM8/18/16
to sympy
Thanks for the input!

I probably wasn't able to explain it properly, but in this pendulum system the mass is actuated. Think of it as a differential drive robot with fans instead of wheels (instead of the mass). The force acting on the x-axis of the mass frame and the torque about the z-axis of the mass frame are the result of such structure.

This makes it different from the normal pendulum where the z-axis is aligned with the cable. The reference frames would look something like this:


This doesn't make the mass a 6DOF system, since the (x,y,z) of the mass are dependent of the anchor point position, and in fact in the jupyter notebook I created I have set only (phi, theta, psi) as the independet generalized coordinates and (x,y,z) are dependent.


That being said I'm sure I'm still making mistakes, so if it was possible for you to clarify what I'm doing wrong or suggest how to do it properly I would really appreciate it. 


Thanks again for all the help,

Nuno

Jason Moore

unread,
Aug 18, 2016, 11:19:35 AM8/18/16
to sy...@googlegroups.com
The system that you drew only has two degrees of freedom regardless of what forces you apply to the system. It also isn't clear as to whether you consider the mass a particle or a rigid body. The problem is very different depending on that. If you want a conical pendulum that has forces applied to the particle, then all you need are two generalized coordinates to describe the pendulum's configuration and some definition of force that is applied to the particle.

--
You received this message because you are subscribed to the Google Groups "sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sympy+unsubscribe@googlegroups.com.
To post to this group, send email to sy...@googlegroups.com.
Visit this group at https://groups.google.com/group/sympy.

Nuno

unread,
Aug 19, 2016, 9:38:09 AM8/19/16
to sympy
The mass is a symmectric rigid body with a diagonal inertial matrix.

Are you proposing the use of spherical coordinates? Since the length of the cable is constant, there would only be two generalized coordinates. 
The thing is that is that I have an interest in the position in space of the mass.

I'm going to try and explain why I was doing things this way. This is a simplification of a larger problem I want to work on, where instead of the anchor point, there would be another mass with a lift force (a balloon basically). In order to describe that system in space I would need the coordinates of the mass (x,y,z) as well as its orientation (phi, theta, psi).

Could you steer me in the right direction to set things up? I'm sorry for asking as much, but after several atempts I'm having a hard time to wrap my mind around how to model the system. 

Thanks in advance,
Nuno

quinta-feira, 18 de Agosto de 2016 às 16:19:35 UTC+1, Jason Moore escreveu:
The system that you drew only has two degrees of freedom regardless of what forces you apply to the system. It also isn't clear as to whether you consider the mass a particle or a rigid body. The problem is very different depending on that. If you want a conical pendulum that has forces applied to the particle, then all you need are two generalized coordinates to describe the pendulum's configuration and some definition of force that is applied to the particle.
On Thu, Aug 18, 2016 at 8:01 AM, Nuno <nmi...@gmail.com> wrote:
Thanks for the input!

I probably wasn't able to explain it properly, but in this pendulum system the mass is actuated. Think of it as a differential drive robot with fans instead of wheels (instead of the mass). The force acting on the x-axis of the mass frame and the torque about the z-axis of the mass frame are the result of such structure.

This makes it different from the normal pendulum where the z-axis is aligned with the cable. The reference frames would look something like this:


This doesn't make the mass a 6DOF system, since the (x,y,z) of the mass are dependent of the anchor point position, and in fact in the jupyter notebook I created I have set only (phi, theta, psi) as the independet generalized coordinates and (x,y,z) are dependent.


That being said I'm sure I'm still making mistakes, so if it was possible for you to clarify what I'm doing wrong or suggest how to do it properly I would really appreciate it. 


Thanks again for all the help,

Nuno



quinta-feira, 18 de Agosto de 2016 às 15:48:35 UTC+1, James Milam escreveu:
To kind of expand on what Jason's saying a 3D pendulum can be completely defined using just (x, y, z) and you can deduce the angles from these coordinates. In your case the pendulum only has two degrees of freedom (x and y for instance and z be calculated because the pendulum has a fixed length) and is why Jason suggests using only two generalized coordinates. A quadcopter does actually have 6 degrees of freedom and is why it would use (x, y, z) in addition to (pitch, roll, yaw).

--
You received this message because you are subscribed to the Google Groups "sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sympy+un...@googlegroups.com.

To post to this group, send email to sy...@googlegroups.com.
Visit this group at https://groups.google.com/group/sympy.
Reply all
Reply to author
Forward
0 new messages