linkage¶
Joint and Linkage definition¶
Created on Fri Apr 16 16:39:21 2021.
@author: HugoFara
- class pylinkage.linkage.Crank(x=None, y=None, joint0=None, distance=None, angle=None, name=None)¶
Bases:
pylinkage.linkage.Joint
Define a crank joint.
- __init__(x=None, y=None, joint0=None, distance=None, angle=None, name=None)¶
Define a crank (circular motor).
- xfloat, optional
initial horizontal position, won’t be used thereafter. The default is None.
- yfloat, optional
initial vertical position. The default is None.
- joint0Joint, optional
first reference joint. The default is None.
- distancefloat, optional
distance to keep between joint0 and self. The default is None.
- anglefloat, optional
It is the angle (horizontal axis, joint0, self). Should be in radian and in trigonometric order. The default is None.
- namestr, optional
user-friendly name. The default is None.
None.
- _abc_impl = <_abc_data object>¶
- angle¶
- get_constraints()¶
Return the distance to the center of rotation.
- r¶
- reload(dt=1)¶
Make a step of crank.
- set_anchor0(joint, distance=None)¶
First joint anchor and fixed distance.
- set_constraints(distance=None, *args)¶
Set geometric constraints, only self.r is affected.
- class pylinkage.linkage.Fixed(x=None, y=None, joint0=None, joint1=None, distance=None, angle=None, name=None)¶
Bases:
pylinkage.linkage.Joint
Define a joint using parents locations only, with no ambiguity.
- __init__(x=None, y=None, joint0=None, joint1=None, distance=None, angle=None, name=None)¶
Create a point, of position fully defined by its two references.
joint0: first reference joint,
joint1: second reference joint.
distance: to keep constant between joint0 and self.
angle: It is the angle (joint1, joint0, self).
Should be in radian and in trigonometric order.
- _abc_impl = <_abc_data object>¶
- angle¶
- get_constraints()¶
Return the constraining distance and angle parameters.
- r¶
- reload()¶
Compute point coordinates.
We know point position relative to its two parents, which gives a local space. The know the orientation of local space, so we can solve the whole. Local space is defined by link[0] as the origin and (link[0], link[1]) as abscisses axis.
- set_anchor0(joint, distance=None, angle=None)¶
First joint anchor and characterisitcs.
- set_anchor1(joint)¶
Second joint anchor.
- set_constraints(distance=None, angle=None)¶
Set geometric constraints.
- class pylinkage.linkage.Joint(x=0, y=0, joint0=None, joint1=None, name=None)¶
Bases:
abc.ABC
Geometric constraint expressed by two joints.
Abstract class, should not be used by itself.
- __init__(x=0, y=0, joint0=None, joint1=None, name=None)¶
Create Joint.
x: joint axis, scalar
y: joint ordinate
joint0: first reference to use, usually a Joint
joint1: second reference, same behavior as joint0
name: unique name
- _abc_impl = <_abc_data object>¶
- coord()¶
Return cartesian coordinates.
- abstract get_constraints()¶
Return geometric constraints applying to this Joint.
- joint0¶
- joint1¶
- name¶
- abstract set_constraints(*args)¶
Set geometric constraints applying to this Joint.
- set_coord(*args)¶
Take a sequence or two scalars, and assign them to object x, y.
- x¶
- y¶
- class pylinkage.linkage.Linkage(joints, order=None, name=None)¶
Bases:
object
A linkage is a set of Joint objects.
It is defined kinematicaly. Coordinates are given relative to its own base.
- __init__(joints, order=None, name=None)¶
Define a linkage, a set of joints.
joints: all Joint to be part of the linkage
order: sequence that manually define resolution order for each step.
Should be elements of joints if provided. * name: linkage name
- _cranks¶
- _solve_order¶
- get_coords()¶
Return positions of all elements of the system.
- get_num_constraints(flat=True)¶
Return numeric constraints of this linkage.
- flatbool
Whether to force one-dimensionnal representation of constraints. The default is True.
- constraintslist
List of geometric constraints.
- get_rotation_period()¶
Return the number of iterations to finish in the previous state.
Formally it is the common denominator of all crank periods.
Number of iterations, with dt=1.
- hyperstaticity()¶
Return the hyperstaticity degree of the linkage in 2D.
- joints¶
- name¶
- rebuild(pos=None)¶
Redifine linkage joints and given intial positions to joints.
- postuple[tuple[int]]
Initial positions for each joint in self.joints. Coordinates does not need to be precise, they will allow us the best fitting position between all possible positions satifying constraints.
- set_coords(coords)¶
Set coordinatess for all joints of the linkage.
- set_num_constraints(constraints, flat=True)¶
Set numeric constraints for this linkage.
Numeric constraints are distances or angles between joints.
- constraintssequence
Sequence of constraints to pass to the joints.
- flatbool
If flat is True, should be a one-dimensionnal sequence of floats. If flat is False, should be a sequence of tuples of digits.
Each element will be passed to the set_constraints method of each correspondig Joint.
The default is True.
- step(iterations=None, dt=1)¶
Make a step of the linkage.
- iterationsint, optional
Number of iterations to run across. If None, the default is self.get_rotation_period().
- dtint, optional
Amount of rotation to turn the cranks by. All cranks rotate by their self.angle * dt. The default is 1.
- generator
Iterable of the joints’ coordinates.
- class pylinkage.linkage.Pivot(x=0, y=0, joint0=None, joint1=None, distance0=None, distance1=None, name=None)¶
Bases:
pylinkage.linkage.Joint
Center of pivot joint.
- __init__(x=0, y=0, joint0=None, joint1=None, distance0=None, distance1=None, name=None)¶
Set point position, parents, and if it is fixed for this turn.
x: position on horizontal axis
y: position on vertical axis
name: friendly name for human readability
joint0: linked pivot joint 1 (geometric constraints). A Joint
representing the center of a pivot joint. * joint1: other pivot joint linked. * distance0: distance from joint0 to the current Joint * distance1: distance from joint1 to the current Joint.
- _abc_impl = <_abc_data object>¶
- circle(joint)¶
Return first link between self and parent as a circle.
Circle is a tuple (abscisse, ordinate, radius).
- get_constraints()¶
Return the two constraining distances of this joint.
- r0¶
- r1¶
- reload()¶
Compute position of pivot joint, use the two linked joints.
- set_anchor0(joint, distance=None)¶
Set the first anchor for this Joint.
- jointJoint
The joint to use as achor.
- distancefloat, optional
Distance to keep constant from the anchor. The default is None.
None.
- set_anchor1(joint, distance=None)¶
Set the second anchor for this Joint.
- jointJoint
The joint to use as achor.
- distancefloat, optional
Distance to keep constant from the anchor. The default is None.
None.
- set_constraints(distance0=None, distance1=None)¶
Set geometric constraints.
- class pylinkage.linkage.Static(x=0, y=0, name=None)¶
Bases:
pylinkage.linkage.Joint
Special case of Joint that should not move.
Mostly used for the frame.
- __init__(x=0, y=0, name=None)¶
Create Joint.
x: joint axis, scalar
y: joint ordinate
joint0: first reference to use, usually a Joint
joint1: second reference, same behavior as joint0
name: unique name
- _abc_impl = <_abc_data object>¶
- get_constraints()¶
Return an empty tuple.
- reload()¶
Do nothing, for consistency only.
- set_anchor0(joint)¶
First joint anchor.
- set_anchor1(joint)¶
Second joint anchor.
- set_constraints(*args)¶
Do nothing, for consistency only.