pylinkage.linkage package
Submodules
pylinkage.linkage.analysis module
Analysis tools for linkages.
- pylinkage.linkage.analysis.bounding_box(locus)
Compute the bounding box of a locus.
- Parameters:
locus (list[tuple[float, float]] | tuple[tuple[float, float]]) – A list of points or any iterable with the same structure.
- Returns:
Bounding box as (y_min, x_max, y_max, x_min).
- Return type:
tuple[float, float, float, float]
- pylinkage.linkage.analysis.kinematic_default_test(func, error_penalty)
Standard run for any linkage before a complete fitness evaluation.
This decorator makes a kinematic simulation, before passing the loci to the decorated function.
- Parameters:
func (Callable) – Fitness function to be decorated.
error_penalty (float) – Penalty value for unbuildable linkage. Common values include float(‘inf’) and 0.
- pylinkage.linkage.analysis.movement_bounding_box(loci)
Bounding box for a group of loci.
- Parameters:
loci
- Return type:
tuple[float, float, float, float]
pylinkage.linkage.linkage module
The linkage module defines useful classes for linkage definition.
Created on Fri Apr 16, 16:39:21 2021.
@author: HugoFara
- class pylinkage.linkage.linkage.Linkage(joints, order=None, name=None)
Bases:
object
A linkage is a set of Joint objects.
It is defined as a kinematic linkage. Coordinates are given relative to its own base.
- get_coords()
Return the positions of each element in the system.
- get_num_constraints(flat=True)
Numeric constraints of this linkage.
- Parameters:
flat (bool) – Whether to force one-dimensional representation of constraints. The default is True.
- Returns:
List of geometric constraints.
- Return type:
list
- get_rotation_period()
The number of iterations to finish in the previous state.
Formally, it is the common denominator of all crank periods.
- Returns:
Number of iterations with dt=1.
- Return type:
int
- hyperstaticity()
Return the hyperstaticity (over-constrainment) degree of the linkage in 2D.
- joints
- name
- rebuild(pos=None)
Redefine linkage joints and given initial positions to joints.
- Parameters:
pos (tuple[tuple[int]]) – Initial positions for each joint in self.joints. Coordinates do not need to be precise, they will allow us the best fitting position between all possible positions satisfying constraints. (Default value = None)
- set_completely(dimensions, positions, flat=True)
Set both dimension and initial positions.
- Parameters:
dimensions (tuple[float] | tuple[tuple[float, float]]) – List of dimensions.
positions (tuple[tuple[float, float]]) – Initial positions
flat (bool) – If the dimensions are in “flat mode”. The default is True.
- set_coords(coords)
Set coordinates for all joints of the linkage.
- Parameters:
coords
- set_num_constraints(constraints, flat=True)
Set numeric constraints for this linkage.
Numeric constraints are distances or angles between joints.
- Parameters:
constraints (Iterable) – Sequence of constraints to pass to the joints.
flat (bool) – If True, constraints should be a one-dimensional sequence of floats. If False, constraints should be a sequence of tuples of digits. Each element will be passed to the set_constraints method of each corresponding Joint. (Default value = True)
- step(iterations=None, dt=1)
Make a step of the linkage.
- Parameters:
iterations (int) – Number of iterations to run across. If None, the default is self.get_rotation_period(). (Default value = None)
dt (float) – Amount of rotation to turn the cranks by. All cranks rotate by their self.angle * dt. The default is 1. (Default value = 1)
- Returns:
Iterable of the joints’ coordinates.
- Return type:
Generator[tuple[float, float]]
Module contents
Definition and analysis of a linkage as a dynamic set of joints.