Replies: 3 comments 5 replies
-
Here is my suggested adjustments (also I think this may be complete for that actual problem). from sympy import zeros, symbols
from sympy.physics.mechanics import (dynamicsymbols, Body, PrismaticJoint,
PinJoint, apply_constant_gravity,
JointsMethod)
l, k, c, g, kT = symbols('l, k, c, g, kT')
ma, mb, mc, IBzz = symbols('ma, mb, mc, IBzz')
q1, q2, q3, u1, u2, u3 = dynamicsymbols('q1, q2, q3, u1, u2, u3')
F, T = dynamicsymbols('F, T')
# bodies
wall = Body('N')
block = Body('A', mass=ma)
IB = zeros(3, 3)
IB[2, 2] = IBzz
compound_pend = Body('B', mass=mb, central_inertia=IB)
simple_pend = Body('C', mass=mc, central_inertia=0)
bodies = (wall, block, compound_pend, simple_pend)
# joints
slider = PrismaticJoint('J1', wall, block, coordinate=q1, speed=u1)
rev1 = PinJoint('J2', block, compound_pend, coordinate=q2, speed=u2,
child_axis=compound_pend.z, child_pos=l*2/3*compound_pend.y,
parent_axis=compound_pend.z)
rev2 = PinJoint('J3', compound_pend, simple_pend, coordinate=q3, speed=u3,
child_axis=compound_pend.z, child_pos=-l/3*compound_pend.y,
parent_axis=simple_pend.z, parent_pos=l*simple_pend.y)
joints = (slider, rev1, rev2)
# loads
block.apply_force(F*block.x)
block.apply_force(-k*q1*block.x, body=wall)
block.apply_force(-c*u1*block.x, body=wall)
compound_pend.apply_torque(T*compound_pend.z, body=block)
simple_pend.apply_torque(kT*q3*simple_pend.z, body=compound_pend)
apply_constant_gravity(-wall.y, g, *bodies)
# equations of motion
method = JointsMethod(wall, *joints)
eqs = method.calculate_equations_of_motion() |
Beta Was this translation helpful? Give feedback.
-
It would be key to make sure this Method class works with PyDy's system: |
Beta Was this translation helpful? Give feedback.
-
Thinking about applying a constant gravity force to all bodies more. Maybe we should have a function that applies the same force to a collection of bodies's mass center. Some ideas: apply_same_force(F*A.x, body1, body2, body3, ...) # applies the force F*A.x to each body's mass center
apply_same_torque(T*A.z, body1, body2, body3, ...) # applies the same torque T*A.z to each bodies' frame
apply_same_force(F*A.x, (body1, point1), (body2, point2), (body3, point3)) # applies same force to each point and attaches the force to the body Not sure we need the last one, but there could be use cases. So maybe any function we create is just to support applying to multiple bodies at once. But this works too: for body in bodies:
body.apply_force(F*A.x) Which is simple, so maybe we don't need a function for this very simple loop. |
Beta Was this translation helpful? Give feedback.
-
@moorepants For
JointsMethod
, I think it would be wise for me to complete Sahil's PR #9835.My idea for JointsMethod is something like:-
An example would be Multi degree of freedom holonomic system
Beta Was this translation helpful? Give feedback.
All reactions