pylinkage.joints package

Submodules

pylinkage.joints.crank module

Crank joint definition.

class pylinkage.joints.crank.Crank(x=None, y=None, joint0=None, distance=None, angle=None, name=None)

Bases: Joint

Define a crank joint.

angle
get_constraints()

Return the distance to the center of rotation.

r
reload(dt=1)

Make a step of crank.

Parameters:

dt (float) – Fraction of steps to take (Default value = 1)

set_anchor0(joint, distance=None)

First joint anchor and fixed distance.

Parameters:
  • joint

  • distance – (Default value = None)

set_constraints(distance=None, *args)

Set geometric constraints, only self.r is affected.

Parameters:
  • distance (float) – Distance from the reference point. (Default value = None)

  • args – Unused, but preserves the object structure.

pylinkage.joints.fixed module

Fixed joint.

class pylinkage.joints.fixed.Fixed(x=None, y=None, joint0=None, joint1=None, distance=None, angle=None, name=None)

Bases: Joint

Define a joint using parents locations only, with no ambiguity.

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. We 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 abscissas axis.

set_anchor0(joint, distance=None, angle=None)

First joint anchor and characteristics.

Parameters:
  • joint

  • distance – (Default value = None)

  • angle – (Default value = None)

set_anchor1(joint)

Second joint anchor.

Parameters:

joint – Joint to set as anchor

set_constraints(distance=None, angle=None)

Set geometric constraints.

Parameters:
  • distance – (Default value = None)

  • angle – (Default value = None)

pylinkage.joints.joint module

Definition of the different joints used for pylinkage.

class pylinkage.joints.joint.Joint(x=0, y=0, joint0=None, joint1=None, name=None)

Bases: ABC

Geometric constraint expressed by two joints.

Abstract class should always be inherited.

coord()

Return cartesian coordinates.

Return type:

tuple[float | None, float | None]

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.

Parameters:

args (tuple[float, float] | tuple[tuple[float, float]]) – Coordinates to set, either as two elements or as a tuple of 2 elements

x
y
class pylinkage.joints.joint.Static(x=0, y=0, name=None)

Bases: Joint

Special case of Joint that should not move.

Mostly used for the frame.

get_constraints()

Return an empty tuple.

reload()

Do nothing, for consistency only.

set_anchor0(joint)

First joint anchor.

Parameters:

joint – Joint to set as anchor.

set_anchor1(joint)

Second joint anchor.

Parameters:

joint – Joint to set as anchor.

set_constraints(*args)

Do nothing, for consistency only.

Parameters:

args – Unused

pylinkage.joints.joint.joint_syntax_parser(joint)

Syntactic parser that understand a joint definition.

Parameters:

joint (Joint | tuple[float, float] | None) – Input joint definition to be parsed.

Returns:

New static joint definition if possible, or None.

Return type:

Joint | Static | None

pylinkage.joints.linear module

Definition of a linear joint.

class pylinkage.joints.linear.Linear(x=0, y=0, joint0=None, joint1=None, joint2=None, revolute_radius=None, name=None)

Bases: Joint

Define a point constrained by a prismatic joint and a revolute joint.

get_constraints()

Return the only distance constraint for this joint.

joint2
reload()

Compute position of revolute joint, with the three linked joints.

revolute_radius
set_constraints(distance0=None)

Set the only distance constraint for this joint.

pylinkage.joints.revolute module

Definition of a revolute joint.

It is also called pin joint or hinge joint, and used to be called a pivot joint in this project.

class pylinkage.joints.revolute.Pivot(x=0, y=0, joint0=None, joint1=None, distance0=None, distance1=None, name=None)

Bases: Revolute

Revolute Joint definition.

Deprecated since version 0.6.0: This class has been de@recated in favor of Revolute which has a standard name. It will be removed in PyLinkage 0.7.0.

r0
r1
class pylinkage.joints.revolute.Revolute(x=0, y=0, joint0=None, joint1=None, distance0=None, distance1=None, name=None)

Bases: Joint

Center of a revolute joint.

circle(joint)

Return the first link between self and parent as a circle.

Parameters:

joint (Joint) – Parent joint you want to use

Returns:

Circle is a tuple (abscissa, ordinate, radius).

Return type:

tuple[float, float, float]

get_constraints()

Return the two constraining distances of this joint.

r0
r1
reload()

Compute the position of revolute joint, use the two linked joints.

set_anchor0(joint, distance=None)

Set the first anchor for this Joint.

Parameters:
  • joint (Joint | tuple[float]) – The joint to use as anchor.

  • distance (float) – Distance to keep constant from the anchor. The default is None.

set_anchor1(joint, distance=None)

Set the second anchor for this Joint.

Parameters:
  • joint (Joint | tuple[float]) – The joint to use as anchor.

  • distance (float) – Distance to keep constant from the anchor. The default is None.

set_constraints(distance0=None, distance1=None)

Set geometric constraints.

Parameters:
  • distance0 (float) – Distance to the first reference (Default value = None)

  • distance1 (float) – Distance to the second reference (Default value = None)

pylinkage.joints.static module

Static joint definition file.

class pylinkage.joints.static.Static(x=0, y=0, name=None)

Bases: Joint

Special case of Joint that should not move.

Mostly used for the frame.

get_constraints()

Return an empty tuple.

reload()

Do nothing, for consistency only.

set_anchor0(joint)

First joint anchor.

Parameters:

joint (Joint) – Other joint to join with.

set_anchor1(joint)

Second joint anchor.

Parameters:

joint (Joint) – Other joint to join with.

set_constraints(*args)

Do nothing, for consistency only.

Parameters:

args – Unused

Module contents

Definition of joints.