From 06398c4baf788ca95dc568267226532995aae7d9 Mon Sep 17 00:00:00 2001 From: Tarun Gaba Date: Wed, 19 Jun 2013 01:49:50 +0530 Subject: [PATCH 1/7] Added a 3 link pendulum problem, with massless links. and Added a 3 link pendulum problem, with links as RigidBodies --- three_link_pendulum/three_link_pendulum.py | 141 ++++++++++++++++++ .../three_link_pendulum_massless_links.py | 90 +++++++++++ 2 files changed, 231 insertions(+) create mode 100644 three_link_pendulum/three_link_pendulum.py create mode 100644 three_link_pendulum/three_link_pendulum_massless_links.py diff --git a/three_link_pendulum/three_link_pendulum.py b/three_link_pendulum/three_link_pendulum.py new file mode 100644 index 0000000..11eed83 --- /dev/null +++ b/three_link_pendulum/three_link_pendulum.py @@ -0,0 +1,141 @@ +#For this one we assume massless links +from sympy import symbols,sympify +from sympy.physics.mechanics import * + +#Number of links = 3 +N_links = 3 + +#Number of masses = 3 +N_bobs = 3 + +#Defining Dynamic Symbols ................ + +#Generalized coordinates ... +q = dynamicsymbols('q:' + str(N_bobs)) + +#Generalized speeds ... +u = dynamicsymbols('u:' + str(N_links + 1)) + +#Mass of each bob: +m = symbols('m:'+str(N_bobs)) + + +#Length and mass of each link .. +l = symbols('l:' + str(N_links)) +M = symbols('M:' + str(N_links)) +#For storingInertia for each bob : +i = symbols('i:'+str(N_bobs)) + + +#gravity and time .... +g, t = symbols('g t') + + +#Now defining an Inertial ReferenceFrame First .... + +I = ReferenceFrame('I') + +#Getting more referenceframes for RigidBodies ... + +A = I.orientnew('A', 'Axis', [q[0], I.z]) +B = I.orientnew('B', 'Axis', [q[1], I.z]) +C = I.orientnew('C', 'Axis', [q[2], I.z]) + +#Setting angular velocities of new frames ... +A.set_ang_vel(I, u[0] * I.z) +B.set_ang_vel(I, u[1] * I.z) +C.set_ang_vel(I, u[2] * I.z) + + + +# An Origin point, with velocity = 0 +O = Point('O') +O.set_vel(I,0) + +#Three more points, for masses .. +P1 = O.locatenew('P1', l[0] * A.y) +P2 = O.locatenew('P2', l[1] * B.y) +P3 = O.locatenew('P3', l[2] * C.y) + +#Setting velocities of points with v2pt theory ... +P1.v2pt_theory(O, I, A) +P2.v2pt_theory(P1, I, B) +P3.v2pt_theory(P2, I, C) +points = [P1,P2,P3] + +Pa1 = Particle('Pa1', points[0], m[0]) +Pa2 = Particle('Pa2', points[1], m[1]) +Pa3 = Particle('Pa3', points[2], m[2]) +particles = [Pa1,Pa2,Pa3] + + + +#defining points for links(RigidBodies) +#Assuming CoM as l/2 ... +P_link1 = O.locatenew('P_link1', l[0]/2 * A.y) +P_link2 = O.locatenew('P_link1', l[1]/2 * B.y) +P_link3 = O.locatenew('P_link1', l[2]/2 * C.y) +#setting velocities of these points with v2pt theory ... +P_link1.v2pt_theory(O, I, A) +P_link2.v2pt_theory(P_link1, I, B) +P_link3.v2pt_theory(P_link2, I, C) + +points_rigid_body = [P_link1,P_link2,P_link3] + + +#defining inertia tensors for links +#Since links are rods, rotating axis= z-axis +#Hence, xx = yy = (1/12)*m*l**2 + +i0 = (1.0/12)*M[0]*l[0]**2 +i1 = (1.0/12)*M[1]*l[1]**2 +i2 = (1.0/12)*M[2]*l[2]**2 + +inertia_link1 = inertia(A,i0,i0,0) +inertia_link2 = inertia(B,i1,i1,0) +inertia_link3 = inertia(C,i2,i2,0) + +#Defining links as Rigid bodies ... + +link1 = RigidBody('link1', P_link1, A, M[0], (inertia_link1, O)) +link2 = RigidBody('link2', P_link2, B, M[1], (inertia_link2, P1)) +link3 = RigidBody('link3', P_link3, C, M[2], (inertia_link3, P2)) +links = [link1,link2,link3] + + +#Applying forces on all particles , and adding all forces in a list.. +forces = [] +for particle in particles: + + mass = particle.get_mass() + point = particle.get_point() + forces.append((point, -mass * g * I.y) ) + +#Applying forces on rigidbodies .. +for link in links: + mass = link.get_mass() + point = link.get_masscenter() + forces.append((point, -mass * g * I.y) ) +kinetic_differentials = [] +for i in range(0,N_bobs): + kinetic_differentials.append(q[i].diff(t) - u[i]) + +#Adding particles and links in the same system ... +total_system = [] +for particle in particles: + total_system.append(particle) + +for link in links: + total_system.append(link) + +kane = KanesMethod(I, q_ind=q, u_ind=u, kd_eqs=kinetic_differentials) +fr, frstar = kane.kanes_equations(forces, total_system) + +print fr + + + + + + + diff --git a/three_link_pendulum/three_link_pendulum_massless_links.py b/three_link_pendulum/three_link_pendulum_massless_links.py new file mode 100644 index 0000000..8b7561e --- /dev/null +++ b/three_link_pendulum/three_link_pendulum_massless_links.py @@ -0,0 +1,90 @@ +#For this one we assume massless links +from sympy import symbols +from sympy.physics.mechanics import * + +#Number of masses = 3 +N_bobs = 3 + +#Defining Dynamic Symbols ................ + +#Generalized coordinates ... +q = dynamicsymbols('q:' + str(N_bobs)) + +#Generalized speeds ... +u = dynamicsymbols('u:' + str(N_links + 1)) + +#Mass of each bob: +m = symbols('m:'+str(N_bobs)) + +#Length of each link .. +l = symbols('l:' + str(N_links)) + + +#gravity and time .... +g, t = symbols('g t') + + +#Now defining an Inertial ReferenceFrame First .... + +I = ReferenceFrame('I') + +#Getting more referenceframes for RigidBodies ... + +A = I.orientnew('A', 'Axis', [q[0], I.z]) +B = I.orientnew('B', 'Axis', [q[1], I.z]) +C = I.orientnew('C', 'Axis', [q[2], I.z]) + +#Setting angular velocities of new frames ... +A.set_ang_vel(I, u[0] * I.z) +B.set_ang_vel(I, u[1] * I.z) +C.set_ang_vel(I, u[2] * I.z) + + + +# An Origin point, with velocity = 0 +O = Point('O') +O.set_vel(I,0) + +#Three more points, for particles .. +P1 = O.locatenew('P1', l[0] * A.x) +P2 = O.locatenew('P2', l[1] * B.x) +P3 = O.locatenew('P3', l[2] * C.x) + +#Setting velocities of points with v2pt theory ... +P1.v2pt_theory(O, I, A) +P2.v2pt_theory(P1, I, B) +P3.v2pt_theory(P2, I, C) +points = [P1,P2,P3] + +#Defining particles ... +Pa1 = Particle('Pa1', points[0], m[0]) +Pa2 = Particle('Pa2', points[1], m[1]) +Pa3 = Particle('Pa3', points[2], m[2]) +particles = [Pa1,Pa2,Pa3] + + + +#Applying forces on all particles , and adding all forces in a list.. +forces = [] +for particle in particles: + + mass = particle.get_mass() + point = particle.get_point() + forces.append((point, -mass * g * I.y) ) + + + + +print forces +kinetic_differentials = [] +for i in range(0,N_bobs): + kinetic_differentials.append(q[i].diff(t) - u[i]) + +print kinetic_differentials + +kane = KanesMethod(I, q_ind=q, u_ind=u, kd_eqs=kinetic_differentials) +fr, frstar = kane.kanes_equations(forces, particles) + +print(fr+frstar) + + From 11a0059c78f0064a33ae1c2fdca061a920e80360 Mon Sep 17 00:00:00 2001 From: Tarun Gaba Date: Wed, 19 Jun 2013 01:53:00 +0530 Subject: [PATCH 2/7] Added README Changed inertia value --- three_link_pendulum/README | 4 ++++ three_link_pendulum/three_link_pendulum.py | 6 +++--- 2 files changed, 7 insertions(+), 3 deletions(-) create mode 100644 three_link_pendulum/README diff --git a/three_link_pendulum/README b/three_link_pendulum/README new file mode 100644 index 0000000..9f6552e --- /dev/null +++ b/three_link_pendulum/README @@ -0,0 +1,4 @@ +This is a 3 link pendulum problem, +it includes two scripts, one for massless links, +and other assuming links as RigidBodies .. +I will add a fig soon .. diff --git a/three_link_pendulum/three_link_pendulum.py b/three_link_pendulum/three_link_pendulum.py index 11eed83..b0e99d5 100644 --- a/three_link_pendulum/three_link_pendulum.py +++ b/three_link_pendulum/three_link_pendulum.py @@ -87,9 +87,9 @@ #Since links are rods, rotating axis= z-axis #Hence, xx = yy = (1/12)*m*l**2 -i0 = (1.0/12)*M[0]*l[0]**2 -i1 = (1.0/12)*M[1]*l[1]**2 -i2 = (1.0/12)*M[2]*l[2]**2 +i0 = (1.0/3)*M[0]*l[0]**2 +i1 = (1.0/3)*M[1]*l[1]**2 +i2 = (1.0/3)*M[2]*l[2]**2 inertia_link1 = inertia(A,i0,i0,0) inertia_link2 = inertia(B,i1,i1,0) From d5f2d44d1cdfad02031ebaa125dab82275908b75 Mon Sep 17 00:00:00 2001 From: Tarun Gaba Date: Wed, 19 Jun 2013 01:58:30 +0530 Subject: [PATCH 3/7] Update three_link_pendulum.py --- three_link_pendulum/three_link_pendulum.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/three_link_pendulum/three_link_pendulum.py b/three_link_pendulum/three_link_pendulum.py index b0e99d5..8cd7f9a 100644 --- a/three_link_pendulum/three_link_pendulum.py +++ b/three_link_pendulum/three_link_pendulum.py @@ -1,4 +1,4 @@ -#For this one we assume massless links +#For this one we assume RigidBody links from sympy import symbols,sympify from sympy.physics.mechanics import * From a61e6028d6c8e470a5548cc7ec5ed618e493109b Mon Sep 17 00:00:00 2001 From: Tarun Gaba Date: Wed, 19 Jun 2013 23:24:11 +0530 Subject: [PATCH 4/7] Modified script for two dimensional joints --- three_link_pendulum/README | 4 +- three_link_pendulum/three_link_pendulum.py | 66 ++++++++------ .../three_link_pendulum_massless_links.py | 90 ------------------- 3 files changed, 42 insertions(+), 118 deletions(-) delete mode 100644 three_link_pendulum/three_link_pendulum_massless_links.py diff --git a/three_link_pendulum/README b/three_link_pendulum/README index 9f6552e..e07eeb0 100644 --- a/three_link_pendulum/README +++ b/three_link_pendulum/README @@ -1,4 +1,2 @@ -This is a 3 link pendulum problem, -it includes two scripts, one for massless links, -and other assuming links as RigidBodies .. +This is a 3 link pendulum problem, assuming links as RigidBodies .. I will add a fig soon .. diff --git a/three_link_pendulum/three_link_pendulum.py b/three_link_pendulum/three_link_pendulum.py index b0e99d5..c5ec0aa 100644 --- a/three_link_pendulum/three_link_pendulum.py +++ b/three_link_pendulum/three_link_pendulum.py @@ -1,4 +1,4 @@ -#For this one we assume massless links +#For this one we assume RigidBody links from sympy import symbols,sympify from sympy.physics.mechanics import * @@ -10,11 +10,14 @@ #Defining Dynamic Symbols ................ -#Generalized coordinates ... -q = dynamicsymbols('q:' + str(N_bobs)) +#Generalized coordinates(angular) ... -#Generalized speeds ... -u = dynamicsymbols('u:' + str(N_links + 1)) +alpha = dynamicsymbols('alpha1 alpha2 alpha3') +beta = dynamicsymbols('beta1 beta2 beta3') + +#Generalized speeds(angular) ... +alphad = dynamicsymbols('alpha1 alpha2 alpha3',1) +betad = dynamicsymbols('beta1 beta2 beta3',1) #Mass of each bob: m = symbols('m:'+str(N_bobs)) @@ -23,9 +26,9 @@ #Length and mass of each link .. l = symbols('l:' + str(N_links)) M = symbols('M:' + str(N_links)) -#For storingInertia for each bob : -i = symbols('i:'+str(N_bobs)) - +#For storing Inertia for each link : +Ixx = symbols('Ixx:'+str(N_links)) +Iyy = symbols('Iyy:'+str(N_links)) #gravity and time .... g, t = symbols('g t') @@ -35,16 +38,20 @@ I = ReferenceFrame('I') -#Getting more referenceframes for RigidBodies ... +#And some other frames ... + +A = ReferenceFrame('A') +A.orient(I,'Body',[alpha[0],beta[0],0],'ZXY') +B = ReferenceFrame('B') +B.orient(I,'Body',[alpha[1],beta[1],0],'ZXY') +C = ReferenceFrame('C') +C.orient(I,'Body',[alpha[2],beta[2],0],'ZXY') -A = I.orientnew('A', 'Axis', [q[0], I.z]) -B = I.orientnew('B', 'Axis', [q[1], I.z]) -C = I.orientnew('C', 'Axis', [q[2], I.z]) #Setting angular velocities of new frames ... -A.set_ang_vel(I, u[0] * I.z) -B.set_ang_vel(I, u[1] * I.z) -C.set_ang_vel(I, u[2] * I.z) +A.set_ang_vel(I, alphad[0] * I.z + betad[0] * I.x) +B.set_ang_vel(I, alphad[1] * I.z + betad[1] * I.x) +C.set_ang_vel(I, alphad[2] * I.z + betad[2] * I.x) @@ -84,16 +91,10 @@ #defining inertia tensors for links -#Since links are rods, rotating axis= z-axis -#Hence, xx = yy = (1/12)*m*l**2 -i0 = (1.0/3)*M[0]*l[0]**2 -i1 = (1.0/3)*M[1]*l[1]**2 -i2 = (1.0/3)*M[2]*l[2]**2 - -inertia_link1 = inertia(A,i0,i0,0) -inertia_link2 = inertia(B,i1,i1,0) -inertia_link3 = inertia(C,i2,i2,0) +inertia_link1 = inertia(A,Ixx[0],Iyy[0],0) +inertia_link2 = inertia(B,Ixx[1],Iyy[1],0) +inertia_link3 = inertia(C,Ixx[2],Iyy[2],0) #Defining links as Rigid bodies ... @@ -118,7 +119,8 @@ forces.append((point, -mass * g * I.y) ) kinetic_differentials = [] for i in range(0,N_bobs): - kinetic_differentials.append(q[i].diff(t) - u[i]) + kinetic_differentials.append(alphad[i] - alpha[i]) + kinetic_differentials.append(betad[i] - beta[i]) #Adding particles and links in the same system ... total_system = [] @@ -128,6 +130,20 @@ for link in links: total_system.append(link) +q = [] +for angle in alpha: + q.append(angle) +for angle in beta: + q.append(angle) +print q +u = [] + +for vel in alphad: + u.append(vel) +for vel in betad: + u.append(vel) + +print u kane = KanesMethod(I, q_ind=q, u_ind=u, kd_eqs=kinetic_differentials) fr, frstar = kane.kanes_equations(forces, total_system) diff --git a/three_link_pendulum/three_link_pendulum_massless_links.py b/three_link_pendulum/three_link_pendulum_massless_links.py deleted file mode 100644 index 8b7561e..0000000 --- a/three_link_pendulum/three_link_pendulum_massless_links.py +++ /dev/null @@ -1,90 +0,0 @@ -#For this one we assume massless links -from sympy import symbols -from sympy.physics.mechanics import * - -#Number of masses = 3 -N_bobs = 3 - -#Defining Dynamic Symbols ................ - -#Generalized coordinates ... -q = dynamicsymbols('q:' + str(N_bobs)) - -#Generalized speeds ... -u = dynamicsymbols('u:' + str(N_links + 1)) - -#Mass of each bob: -m = symbols('m:'+str(N_bobs)) - -#Length of each link .. -l = symbols('l:' + str(N_links)) - - -#gravity and time .... -g, t = symbols('g t') - - -#Now defining an Inertial ReferenceFrame First .... - -I = ReferenceFrame('I') - -#Getting more referenceframes for RigidBodies ... - -A = I.orientnew('A', 'Axis', [q[0], I.z]) -B = I.orientnew('B', 'Axis', [q[1], I.z]) -C = I.orientnew('C', 'Axis', [q[2], I.z]) - -#Setting angular velocities of new frames ... -A.set_ang_vel(I, u[0] * I.z) -B.set_ang_vel(I, u[1] * I.z) -C.set_ang_vel(I, u[2] * I.z) - - - -# An Origin point, with velocity = 0 -O = Point('O') -O.set_vel(I,0) - -#Three more points, for particles .. -P1 = O.locatenew('P1', l[0] * A.x) -P2 = O.locatenew('P2', l[1] * B.x) -P3 = O.locatenew('P3', l[2] * C.x) - -#Setting velocities of points with v2pt theory ... -P1.v2pt_theory(O, I, A) -P2.v2pt_theory(P1, I, B) -P3.v2pt_theory(P2, I, C) -points = [P1,P2,P3] - -#Defining particles ... -Pa1 = Particle('Pa1', points[0], m[0]) -Pa2 = Particle('Pa2', points[1], m[1]) -Pa3 = Particle('Pa3', points[2], m[2]) -particles = [Pa1,Pa2,Pa3] - - - -#Applying forces on all particles , and adding all forces in a list.. -forces = [] -for particle in particles: - - mass = particle.get_mass() - point = particle.get_point() - forces.append((point, -mass * g * I.y) ) - - - - -print forces -kinetic_differentials = [] -for i in range(0,N_bobs): - kinetic_differentials.append(q[i].diff(t) - u[i]) - -print kinetic_differentials - -kane = KanesMethod(I, q_ind=q, u_ind=u, kd_eqs=kinetic_differentials) -fr, frstar = kane.kanes_equations(forces, particles) - -print(fr+frstar) - - From 8d379c28f9b64cca844959db1f8b03289bc5f6d6 Mon Sep 17 00:00:00 2001 From: Tarun Gaba Date: Sun, 23 Jun 2013 13:15:52 +0530 Subject: [PATCH 5/7] modified Inertia and Velocity symbols. Changed code to acc to pep8 style guide --- three_link_pendulum/three_link_pendulum.py | 66 ++++++++++++---------- 1 file changed, 35 insertions(+), 31 deletions(-) diff --git a/three_link_pendulum/three_link_pendulum.py b/three_link_pendulum/three_link_pendulum.py index c5ec0aa..5ab5b82 100644 --- a/three_link_pendulum/three_link_pendulum.py +++ b/three_link_pendulum/three_link_pendulum.py @@ -1,5 +1,5 @@ #For this one we assume RigidBody links -from sympy import symbols,sympify +from sympy import symbols, sympify from sympy.physics.mechanics import * #Number of links = 3 @@ -16,19 +16,24 @@ beta = dynamicsymbols('beta1 beta2 beta3') #Generalized speeds(angular) ... -alphad = dynamicsymbols('alpha1 alpha2 alpha3',1) -betad = dynamicsymbols('beta1 beta2 beta3',1) +vel_alpha = dynamicsymbols('vel_alpha1 vel_alpha2 vel_alpha3') +vel_beta = dynamicsymbols('vel_beta1 vel_beta2 vel_beta3') #Mass of each bob: -m = symbols('m:'+str(N_bobs)) +m = symbols('m:' + str(N_bobs)) #Length and mass of each link .. l = symbols('l:' + str(N_links)) M = symbols('M:' + str(N_links)) + #For storing Inertia for each link : -Ixx = symbols('Ixx:'+str(N_links)) -Iyy = symbols('Iyy:'+str(N_links)) +Ixx = symbols('Ixx:' + str(N_links)) +Iyy = symbols('Iyy:' + str(N_links)) +Izz = symbols('Izz:' + str(N_links)) +Ixy = symbols('Ixy:' + str(N_links)) +Iyz = symbols('Iyz:' + str(N_links)) +Ixz = symbols('Ixz:' + str(N_links)) #gravity and time .... g, t = symbols('g t') @@ -40,24 +45,23 @@ #And some other frames ... -A = ReferenceFrame('A') -A.orient(I,'Body',[alpha[0],beta[0],0],'ZXY') -B = ReferenceFrame('B') -B.orient(I,'Body',[alpha[1],beta[1],0],'ZXY') -C = ReferenceFrame('C') -C.orient(I,'Body',[alpha[2],beta[2],0],'ZXY') +A = I.orientnew('A', 'Body', [alpha[0], beta[0], 0], 'ZXY') + +B = A.orientnew('B', 'Body', [alpha[1], beta[1], 0], 'ZXY') + +C = B.orientnew('C', 'Body', [alpha[2], beta[2], 0], 'ZXY') #Setting angular velocities of new frames ... -A.set_ang_vel(I, alphad[0] * I.z + betad[0] * I.x) -B.set_ang_vel(I, alphad[1] * I.z + betad[1] * I.x) -C.set_ang_vel(I, alphad[2] * I.z + betad[2] * I.x) +A.set_ang_vel(I, vel_alpha[0] * I.z + vel_beta[0] * I.x) +B.set_ang_vel(A, vel_alpha[1] * A.z + vel_beta[1] * A.x) +C.set_ang_vel(B, vel_alpha[2] * B.z + vel_beta[2] * B.x) # An Origin point, with velocity = 0 O = Point('O') -O.set_vel(I,0) +O.set_vel(I, 0) #Three more points, for masses .. P1 = O.locatenew('P1', l[0] * A.y) @@ -68,12 +72,12 @@ P1.v2pt_theory(O, I, A) P2.v2pt_theory(P1, I, B) P3.v2pt_theory(P2, I, C) -points = [P1,P2,P3] +points = [P1, P2, P3] Pa1 = Particle('Pa1', points[0], m[0]) Pa2 = Particle('Pa2', points[1], m[1]) Pa3 = Particle('Pa3', points[2], m[2]) -particles = [Pa1,Pa2,Pa3] +particles = [Pa1, Pa2, Pa3] @@ -87,21 +91,21 @@ P_link2.v2pt_theory(P_link1, I, B) P_link3.v2pt_theory(P_link2, I, C) -points_rigid_body = [P_link1,P_link2,P_link3] +points_rigid_body = [P_link1, P_link2, P_link3] #defining inertia tensors for links -inertia_link1 = inertia(A,Ixx[0],Iyy[0],0) -inertia_link2 = inertia(B,Ixx[1],Iyy[1],0) -inertia_link3 = inertia(C,Ixx[2],Iyy[2],0) +inertia_link1 = inertia(A, Ixx[0], Iyy[0], Izz[0], ixy=Ixy[0], iyz=Iyz[0], izx=Ixz[0]) +inertia_link2 = inertia(B, Ixx[1], Iyy[1], Izz[1], ixy=Ixy[1], iyz=Iyz[1], izx=Ixz[1]) +inertia_link3 = inertia(C, Ixx[2], Iyy[2], Izz[2], ixy=Ixy[2], iyz=Iyz[2], izx=Ixz[2]) #Defining links as Rigid bodies ... link1 = RigidBody('link1', P_link1, A, M[0], (inertia_link1, O)) link2 = RigidBody('link2', P_link2, B, M[1], (inertia_link2, P1)) link3 = RigidBody('link3', P_link3, C, M[2], (inertia_link3, P2)) -links = [link1,link2,link3] +links = [link1, link2, link3] #Applying forces on all particles , and adding all forces in a list.. @@ -119,8 +123,8 @@ forces.append((point, -mass * g * I.y) ) kinetic_differentials = [] for i in range(0,N_bobs): - kinetic_differentials.append(alphad[i] - alpha[i]) - kinetic_differentials.append(betad[i] - beta[i]) + kinetic_differentials.append(vel_alpha[i] - alpha[i].diff(t)) + kinetic_differentials.append(vel_beta[i] - beta[i].diff(t)) #Adding particles and links in the same system ... total_system = [] @@ -132,16 +136,16 @@ q = [] for angle in alpha: - q.append(angle) + q.append(angle) for angle in beta: - q.append(angle) + q.append(angle) print q u = [] -for vel in alphad: - u.append(vel) -for vel in betad: - u.append(vel) +for vel in vel_alpha: + u.append(vel) +for vel in vel_beta: + u.append(vel) print u kane = KanesMethod(I, q_ind=q, u_ind=u, kd_eqs=kinetic_differentials) From b7571e7f5270b76a0b586ec1ef10e6dc5aa4f041 Mon Sep 17 00:00:00 2001 From: Tarun Gaba Date: Sun, 23 Jun 2013 13:18:52 +0530 Subject: [PATCH 6/7] Updated according to PEP8 style guide --- three_link_pendulum/three_link_pendulum.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/three_link_pendulum/three_link_pendulum.py b/three_link_pendulum/three_link_pendulum.py index 5ab5b82..336daf9 100644 --- a/three_link_pendulum/three_link_pendulum.py +++ b/three_link_pendulum/three_link_pendulum.py @@ -96,9 +96,9 @@ #defining inertia tensors for links -inertia_link1 = inertia(A, Ixx[0], Iyy[0], Izz[0], ixy=Ixy[0], iyz=Iyz[0], izx=Ixz[0]) -inertia_link2 = inertia(B, Ixx[1], Iyy[1], Izz[1], ixy=Ixy[1], iyz=Iyz[1], izx=Ixz[1]) -inertia_link3 = inertia(C, Ixx[2], Iyy[2], Izz[2], ixy=Ixy[2], iyz=Iyz[2], izx=Ixz[2]) +inertia_link1 = inertia(A, Ixx[0], Iyy[0], Izz[0], ixy = Ixy[0], iyz = Iyz[0], izx = Ixz[0]) +inertia_link2 = inertia(B, Ixx[1], Iyy[1], Izz[1], ixy = Ixy[1], iyz = Iyz[1], izx = Ixz[1]) +inertia_link3 = inertia(C, Ixx[2], Iyy[2], Izz[2], ixy = Ixy[2], iyz = Iyz[2], izx = Ixz[2]) #Defining links as Rigid bodies ... @@ -148,7 +148,7 @@ u.append(vel) print u -kane = KanesMethod(I, q_ind=q, u_ind=u, kd_eqs=kinetic_differentials) +kane = KanesMethod(I, q_ind = q, u_ind = u, kd_eqs = kinetic_differentials) fr, frstar = kane.kanes_equations(forces, total_system) print fr From 944ab76a89371d3dc26f54998d0066bc9fabb2d5 Mon Sep 17 00:00:00 2001 From: Tarun Gaba Date: Thu, 11 Jul 2013 11:43:44 +0530 Subject: [PATCH 7/7] modified README, added a figure --- three_link_pendulum/README | 12 ++++++++++-- three_link_pendulum/three_link_pendulum.gif | Bin 0 -> 3601 bytes 2 files changed, 10 insertions(+), 2 deletions(-) create mode 100644 three_link_pendulum/three_link_pendulum.gif diff --git a/three_link_pendulum/README b/three_link_pendulum/README index e07eeb0..62c9691 100644 --- a/three_link_pendulum/README +++ b/three_link_pendulum/README @@ -1,2 +1,10 @@ -This is a 3 link pendulum problem, assuming links as RigidBodies .. -I will add a fig soon .. +This example is the symbolic equations of motions derivation of a three +link conical pendulum. +The links of the pendulum are also considered to have mass, and are represented +as RigidBodies. The the end points of the links are represented by Particles. +The pendulum has six degrees of freedom. + +To run this program type in terminal: + +python three_link_pendulum.py + diff --git a/three_link_pendulum/three_link_pendulum.gif b/three_link_pendulum/three_link_pendulum.gif new file mode 100644 index 0000000000000000000000000000000000000000..94062076d98ed674e83822fa01b6c93aaa117a66 GIT binary patch literal 3601 zcmXYwd0dTK)W^3>DVIXZ9Fg>-xZ4ntAyPbjR?AxGjksKjU^XXKlQ$ky1h{z*p zc1kj)X-niuN=TO|O1c{4+V8pV`|f}CXRr17?6ubS_gm(c>y4MWA|*1U5B%SO03ZM` z00aOE7yuXu7z7v$7y=jySO8cESOi!MSOQoIH~=^ZI0QHhI085dcmQ|^cm#M1cmj9| z1ONmG1Ox;O1Of!A_#03NC;}7%N&ri0Dv4F6Eu|Tju zF$I`HOcACSQ-Z02zCvtB03rYrKonvS1`q}k1`!4mh7g7l77!K^77-Q`mJpT_4iF9! z4iOF$ju4I#9uOW99uXcBo)DfA0T2Na0TBTcfe?Wb3J8USB0@2tgi!jQ5fo}DkSO|6 zBo$U*0A(O$5M?lB2xTZ`0c9a&5oIxD31une0OcU%5alrC2<0f{0p%g(5#=%E3FRpj z02Lq=5EU>L2o?S-rZAd9Z3S}0-2Yqr|9!8xW)2J+0>DpT@L%Y^odC+2pl{Svi|q6F zLY2qsJ5^*~co39Y#wamR#c|y;QcdE=yuRguNt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