sympy
sympy copied to clipboard
Implementation of actuators
This issue is coupled to the experimental mechanics development described in #24234. Feel free to comment down below and suggest improvements or even discuss a different approach.
Issue
It would be ideal to have an abstract base class representing a Actuator
. This Actuator
should represent two coupled loads acting upon two different bodies. Examples of actuators are springs, dampers, but a more complex actuator would for example be a muscle.
Solution
TODO
Implementation
TODO
Actuator
s will need some abstraction that allow for nonlinear pathways to be modelled. This could either be based on the obstacle set method (where via points are used), and/or wrapping surfaces. We will also need to consider how nonlinear pathways interact with via points/wrapping surfaces that may need to come into contact with the actuator pathway for a portion of its operating range.
Some form of abstraction that allows the definition for how these are controlled would also be useful. It may be possible for this to just be a simple sympy.physics.mechanics.dynamicsymbols
.
Finally, it may also be useful to think about how pathways can be approximated in order to reduce the complexity of defining pathways symbolically. Polynomial approximations have been used by others for this purpose with good results. This would still result in a symbolic description of the pathways but at a less symbolic complexity. This would be useful for codegen purposes.
Having investigated the possibility of adding classes for a torsional linear spring (TorsionalLinearSpring
) and torsional linear damper (TorsionalLinearDamper
) as subclasses of TorqueActuator
, @TJStienstra and I have decided that this is a fools errand and not worth doing. To implement these classes neatly would require the angle between the target_frame
and reaction_frame
to be known. There is no neat way to determine the angle between frames so this would need to be passed as an extra argument by the user. If this is done then having a subclass provides no benefit as it results in a clunkier API. A torsional linear actuator can be instantiated using (an adaptation of) the following code:
import sympy as sm
import sympy.physics.mechanics as me
k = sm.Symbol('k') # spring stiffness
theta = sm.Symbol('theta') # equilibrium angle
q = me.dynamicsymbols('q') # angle between frames
N = me.ReferenceFrame('N')
A = me.ReferenceFrame('A')
A.orient_axis(N, q, N.z)
torque = -k * (q - theta)
actuator = me.TorqueActuator(torque, N.z, N, A)
We have a public actuator now, so closing this.