Environment Utils

Usage

This module contains a set of utility functions for the Mech environment.

env_utils methods

linkage_gym.utils.env_utils.circIntersectionVect(jointA, jointB, jointC_pos)[source]

Circle Intersection Method for linkage FK

Parameters
  • jointA (Nd.Array) – jointA path

  • jointB (Nd.Array) – jointB path

  • jointC_pos (Nd.Array) – New joint being added

Returns

Path of jointC

Return type

Nd.Array

linkage_gym.utils.env_utils.distance(curve_i, curve_j, ordered=False, distance_metric='euclidean')[source]

distance between curve_i and curve_j

Parameters
  • curve_i (Nd.Array) – Array of x,y points that is from curve_i Shape: (n, 2)

  • curve_j (Nd.Array) – Array of x,y points that is from curve_j Shape: (n, 2)

  • ordered (bool, optional) – if ordering of points matters. Defaults to False.

  • distance_metric (str, optional) – check scipy.cdist for various options. Defaults to ‘euclidean’.

Returns

Distance between all points

Return type

Nd.Array

linkage_gym.utils.env_utils.normalize_curve(input, scale=None, shift=None)[source]

normalizes input curve with shift and scale factors

Parameters
  • input (Nd.Array) – Shape: (n, 2)

  • scale (float, optional) – scaling factor. Defaults to None.

  • shift (Nd.Array, optional) – shift factor [x offset, y offset]. Defaults to None.

Returns

updated curve

Return type

Nd.Array

linkage_gym.utils.env_utils.symbolic_kinematics(xi, xj, xk0)[source]

Symbolic Kinematics implementation

Parameters
  • xi (Nd.Array) – Path of revolute joint xi Shape: (2, n)

  • xj (Nd.Array) – Path of revolute joint xj Shape: (2, n)

  • xk0 (Nd.Array) – Initial position of new point xk Shape: (2,)

Returns

Path of revolute joint xk Shape: (2,n)

Return type

Nd.Array

linkage_gym.utils.env_utils.uniquify(path)[source]