Pathway (Docstrings)

Implementations of pathways for use by actuators.

class sympy.physics.mechanics.pathway.LinearPathway(*attachments)[source]

Linear pathway between a pair of attachment points.

Parameters:

attachments : tuple[Point, Point]

Pair of Point objects between which the linear pathway spans. Constructor expects two points to be passed, e.g. LinearPathway(Point('pA'), Point('pB')). More or fewer points will cause an error to be thrown.

Explanation

A linear pathway forms a straight-line segment between two points and is the simplest pathway that can be formed. It will not interact with any other objects in the system, i.e. a LinearPathway will intersect other objects to ensure that the path between its two ends (its attachments) is the shortest possible.

A linear pathway is made up of two points that can move relative to each other, and a pair of equal and opposite forces acting on the points. If the positive time-varying Euclidean distance between the two points is defined, then the “extension velocity” is the time derivative of this distance. The extension velocity is positive when the two points are moving away from each other and negative when moving closer to each other. The direction for the force acting on either point is determined by constructing a unit vector directed from the other point to this point. This establishes a sign convention such that a positive force magnitude tends to push the points apart. The following diagram shows the positive force sense and the distance between the points:

P           Q
o<--- F --->o
|           |
|<--l(t)--->|

Examples

>>> from sympy.physics.mechanics import LinearPathway

To construct a pathway, two points are required to be passed to the attachments parameter as a tuple.

>>> from sympy.physics.mechanics import Point
>>> pA, pB = Point('pA'), Point('pB')
>>> linear_pathway = LinearPathway(pA, pB)
>>> linear_pathway
LinearPathway(pA, pB)

The pathway created above isn’t very interesting without the positions and velocities of its attachment points being described. Without this its not possible to describe how the pathway moves, i.e. its length or its extension velocity.

>>> from sympy.physics.mechanics import ReferenceFrame
>>> from sympy.physics.vector import dynamicsymbols
>>> N = ReferenceFrame('N')
>>> q = dynamicsymbols('q')
>>> pB.set_pos(pA, q*N.x)
>>> pB.pos_from(pA)
q(t)*N.x

A pathway’s length can be accessed via its length attribute.

>>> linear_pathway.length
sqrt(q(t)**2)

Note how what appears to be an overly-complex expression is returned. This is actually required as it ensures that a pathway’s length is always positive.

A pathway’s extension velocity can be accessed similarly via its extension_velocity attribute.

>>> linear_pathway.extension_velocity
sqrt(q(t)**2)*Derivative(q(t), t)/q(t)
property extension_velocity

Exact analytical expression for the pathway’s extension velocity.

property length

Exact analytical expression for the pathway’s length.

to_loads(force)[source]

Loads required by the equations of motion method classes.

Parameters:

force : Expr

Magnitude of the force acting along the length of the pathway. As per the sign conventions for the pathway length, pathway extension velocity, and pair of point forces, if this Expr is positive then the force will act to push the pair of points away from one another (it is expansile).

Explanation

KanesMethod requires a list of Point-Vector tuples to be passed to the loads parameters of its kanes_equations method when constructing the equations of motion. This method acts as a utility to produce the correctly-structred pairs of points and vectors required so that these can be easily concatenated with other items in the list of loads and passed to KanesMethod.kanes_equations. These loads are also in the correct form to also be passed to the other equations of motion method classes, e.g. LagrangesMethod.

Examples

The below example shows how to generate the loads produced in a linear actuator that produces an expansile force F. First, create a linear actuator between two points separated by the coordinate q in the x direction of the global frame N.

>>> from sympy.physics.mechanics import (LinearPathway, Point,
...     ReferenceFrame)
>>> from sympy.physics.vector import dynamicsymbols
>>> q = dynamicsymbols('q')
>>> N = ReferenceFrame('N')
>>> pA, pB = Point('pA'), Point('pB')
>>> pB.set_pos(pA, q*N.x)
>>> linear_pathway = LinearPathway(pA, pB)

Now create a symbol F to describe the magnitude of the (expansile) force that will be produced along the pathway. The list of loads that KanesMethod requires can be produced by calling the pathway’s to_loads method with F passed as the only argument.

>>> from sympy import symbols
>>> F = symbols('F')
>>> linear_pathway.to_loads(F)
[(pA, - F*q(t)/sqrt(q(t)**2)*N.x), (pB, F*q(t)/sqrt(q(t)**2)*N.x)]
class sympy.physics.mechanics.pathway.ObstacleSetPathway(*attachments)[source]

Obstacle-set pathway between a set of attachment points.

Parameters:

attachments : tuple[Point, Point]

The set of Point objects that define the segmented obstacle-set pathway.

Explanation

An obstacle-set pathway forms a series of straight-line segment between pairs of consecutive points in a set of points. It is similiar to multiple linear pathways joined end-to-end. It will not interact with any other objects in the system, i.e. an ObstacleSetPathway will intersect other objects to ensure that the path between its pairs of points (its attachments) is the shortest possible.

Examples

To construct an obstacle-set pathway, three or more points are required to be passed to the attachments parameter as a tuple.

>>> from sympy.physics.mechanics import ObstacleSetPathway, Point
>>> pA, pB, pC, pD = Point('pA'), Point('pB'), Point('pC'), Point('pD')
>>> obstacle_set_pathway = ObstacleSetPathway(pA, pB, pC, pD)
>>> obstacle_set_pathway
ObstacleSetPathway(pA, pB, pC, pD)

The pathway created above isn’t very interesting without the positions and velocities of its attachment points being described. Without this its not possible to describe how the pathway moves, i.e. its length or its extension velocity.

>>> from sympy import cos, sin
>>> from sympy.physics.mechanics import ReferenceFrame
>>> from sympy.physics.vector import dynamicsymbols
>>> N = ReferenceFrame('N')
>>> q = dynamicsymbols('q')
>>> pO = Point('pO')
>>> pA.set_pos(pO, N.y)
>>> pB.set_pos(pO, -N.x)
>>> pC.set_pos(pA, cos(q) * N.x - (sin(q) + 1) * N.y)
>>> pD.set_pos(pA, sin(q) * N.x + (cos(q) - 1) * N.y)
>>> pB.pos_from(pA)
- N.x - N.y
>>> pC.pos_from(pA)
cos(q(t))*N.x + (-sin(q(t)) - 1)*N.y
>>> pD.pos_from(pA)
sin(q(t))*N.x + (cos(q(t)) - 1)*N.y

A pathway’s length can be accessed via its length attribute.

>>> obstacle_set_pathway.length.simplify()
sqrt(2)*(sqrt(cos(q(t)) + 1) + 2)

A pathway’s extension velocity can be accessed similarly via its extension_velocity attribute.

>>> obstacle_set_pathway.extension_velocity.simplify()
-sqrt(2)*sin(q(t))*Derivative(q(t), t)/(2*sqrt(cos(q(t)) + 1))
property attachments

The set of points defining a pathway’s segmented path.

property extension_velocity

Exact analytical expression for the pathway’s extension velocity.

property length

Exact analytical expression for the pathway’s length.

to_loads(force)[source]

Loads required by the equations of motion method classes.

Parameters:

force : Expr

The force acting along the length of the pathway. It is assumed that this Expr represents an expansile force.

Explanation

KanesMethod requires a list of Point-Vector tuples to be passed to the loads parameters of its kanes_equations method when constructing the equations of motion. This method acts as a utility to produce the correctly-structred pairs of points and vectors required so that these can be easily concatenated with other items in the list of loads and passed to KanesMethod.kanes_equations. These loads are also in the correct form to also be passed to the other equations of motion method classes, e.g. LagrangesMethod.

Examples

The below example shows how to generate the loads produced in an actuator that follows an obstacle-set pathway between four points and produces an expansile force F. First, create a pair of reference frames, A and B, in which the four points pA, pB, pC, and pD will be located. The first two points in frame A and the second two in frame B. Frame B will also be oriented such that it relates to A via a rotation of q about an axis N.z in a global frame (N.z, A.z, and B.z are parallel).

>>> from sympy.physics.mechanics import (ObstacleSetPathway, Point,
...     ReferenceFrame)
>>> from sympy.physics.vector import dynamicsymbols
>>> q = dynamicsymbols('q')
>>> N = ReferenceFrame('N')
>>> N = ReferenceFrame('N')
>>> A = N.orientnew('A', 'axis', (0, N.x))
>>> B = A.orientnew('B', 'axis', (q, N.z))
>>> pO = Point('pO')
>>> pA, pB, pC, pD = Point('pA'), Point('pB'), Point('pC'), Point('pD')
>>> pA.set_pos(pO, A.x)
>>> pB.set_pos(pO, -A.y)
>>> pC.set_pos(pO, B.y)
>>> pD.set_pos(pO, B.x)
>>> obstacle_set_pathway = ObstacleSetPathway(pA, pB, pC, pD)

Now create a symbol F to describe the magnitude of the (expansile) force that will be produced along the pathway. The list of loads that KanesMethod requires can be produced by calling the pathway’s to_loads method with F passed as the only argument.

>>> from sympy import Symbol
>>> F = Symbol('F')
>>> obstacle_set_pathway.to_loads(F)
[(pA, sqrt(2)*F/2*A.x + sqrt(2)*F/2*A.y),
 (pB, - sqrt(2)*F/2*A.x - sqrt(2)*F/2*A.y),
 (pB, - F/sqrt(2*cos(q(t)) + 2)*A.y - F/sqrt(2*cos(q(t)) + 2)*B.y),
 (pC, F/sqrt(2*cos(q(t)) + 2)*A.y + F/sqrt(2*cos(q(t)) + 2)*B.y),
 (pC, - sqrt(2)*F/2*B.x + sqrt(2)*F/2*B.y),
 (pD, sqrt(2)*F/2*B.x - sqrt(2)*F/2*B.y)]
class sympy.physics.mechanics.pathway.PathwayBase(*attachments)[source]

Abstract base class for all pathway classes to inherit from.

Notes

Instances of this class cannot be directly instantiated by users. However, it can be used to created custom pathway types through subclassing.

property attachments

The pair of points defining a pathway’s ends.

abstract property extension_velocity

An expression representing the pathway’s extension velocity.

abstract property length

An expression representing the pathway’s length.

abstract to_loads(force)[source]

Loads required by the equations of motion method classes.

Explanation

KanesMethod requires a list of Point-Vector tuples to be passed to the loads parameters of its kanes_equations method when constructing the equations of motion. This method acts as a utility to produce the correctly-structred pairs of points and vectors required so that these can be easily concatenated with other items in the list of loads and passed to KanesMethod.kanes_equations. These loads are also in the correct form to also be passed to the other equations of motion method classes, e.g. LagrangesMethod.

class sympy.physics.mechanics.pathway.WrappingPathway(attachment_1, attachment_2, geometry)[source]

Pathway that wraps a geometry object.

Parameters:

attachment_1 : Point

First of the pair of Point objects between which the wrapping pathway spans.

attachment_2 : Point

Second of the pair of Point objects between which the wrapping pathway spans.

geometry : WrappingGeometryBase

Geometry about which the pathway wraps.

Explanation

A wrapping pathway interacts with a geometry object and forms a path that wraps smoothly along its surface. The wrapping pathway along the geometry object will be the geodesic that the geometry object defines based on the two points. It will not interact with any other objects in the system, i.e. a WrappingPathway will intersect other objects to ensure that the path between its two ends (its attachments) is the shortest possible.

To explain the sign conventions used for pathway length, extension velocity, and direction of applied forces, we can ignore the geometry with which the wrapping pathway interacts. A wrapping pathway is made up of two points that can move relative to each other, and a pair of equal and opposite forces acting on the points. If the positive time-varying Euclidean distance between the two points is defined, then the “extension velocity” is the time derivative of this distance. The extension velocity is positive when the two points are moving away from each other and negative when moving closer to each other. The direction for the force acting on either point is determined by constructing a unit vector directed from the other point to this point. This establishes a sign convention such that a positive force magnitude tends to push the points apart. The following diagram shows the positive force sense and the distance between the points:

P           Q
o<--- F --->o
|           |
|<--l(t)--->|

Examples

>>> from sympy.physics.mechanics import WrappingPathway

To construct a wrapping pathway, like other pathways, a pair of points must be passed, followed by an instance of a wrapping geometry class as a keyword argument. We’ll use a cylinder with radius r and its axis parallel to N.x passing through a point pO.

>>> from sympy import symbols
>>> from sympy.physics.mechanics import Point, ReferenceFrame, WrappingCylinder
>>> r = symbols('r')
>>> N = ReferenceFrame('N')
>>> pA, pB, pO = Point('pA'), Point('pB'), Point('pO')
>>> cylinder = WrappingCylinder(r, pO, N.x)
>>> wrapping_pathway = WrappingPathway(pA, pB, cylinder)
>>> wrapping_pathway
WrappingPathway(pA, pB, geometry=WrappingCylinder(radius=r, point=pO,
    axis=N.x))
property extension_velocity

Exact analytical expression for the pathway’s extension velocity.

property geometry

Geometry around which the pathway wraps.

property length

Exact analytical expression for the pathway’s length.

to_loads(force)[source]

Loads required by the equations of motion method classes.

Parameters:

force : Expr

Magnitude of the force acting along the length of the pathway. It is assumed that this Expr represents an expansile force.

Explanation

KanesMethod requires a list of Point-Vector tuples to be passed to the loads parameters of its kanes_equations method when constructing the equations of motion. This method acts as a utility to produce the correctly-structred pairs of points and vectors required so that these can be easily concatenated with other items in the list of loads and passed to KanesMethod.kanes_equations. These loads are also in the correct form to also be passed to the other equations of motion method classes, e.g. LagrangesMethod.

Examples

The below example shows how to generate the loads produced in an actuator that produces an expansile force F while wrapping around a cylinder. First, create a cylinder with radius r and an axis parallel to the N.z direction of the global frame N that also passes through a point pO.

>>> from sympy import symbols
>>> from sympy.physics.mechanics import (Point, ReferenceFrame,
...     WrappingCylinder)
>>> N = ReferenceFrame('N')
>>> r = symbols('r', positive=True)
>>> pO = Point('pO')
>>> cylinder = WrappingCylinder(r, pO, N.z)

Create the pathway of the actuator using the WrappingPathway class, defined to span between two points pA and pB. Both points lie on the surface of the cylinder and the location of pB is defined relative to pA by the dynamics symbol q.

>>> from sympy import cos, sin
>>> from sympy.physics.mechanics import WrappingPathway, dynamicsymbols
>>> q = dynamicsymbols('q')
>>> pA = Point('pA')
>>> pB = Point('pB')
>>> pA.set_pos(pO, r*N.x)
>>> pB.set_pos(pO, r*(cos(q)*N.x + sin(q)*N.y))
>>> pB.pos_from(pA)
(r*cos(q(t)) - r)*N.x + r*sin(q(t))*N.y
>>> pathway = WrappingPathway(pA, pB, cylinder)

Now create a symbol F to describe the magnitude of the (expansile) force that will be produced along the pathway. The list of loads that KanesMethod requires can be produced by calling the pathway’s to_loads method with F passed as the only argument.

>>> F = symbols('F')
>>> loads = pathway.to_loads(F)
>>> [load.__class__(load.location, load.vector.simplify()) for load in loads]
[(pA, F*N.y), (pB, F*sin(q(t))*N.x - F*cos(q(t))*N.y),
 (pO, - F*sin(q(t))*N.x + F*(cos(q(t)) - 1)*N.y)]