intermediateTypes#

Contains intermediate representations of bodies and joints to support conversion between FreeCAD and kdFlex formats.

Classes#

SimpleQuaternion

Minimal unit quaternion class using x,y,z,w representation.

SimpleHomTran

Simple Homogeneous Transformation object corresponding to a passive rotation + offset.

MeshData

Basic representation of a triangle mesh.

BasicBody

Basic representation of a Body object.

BasicJoint

Basic representation of a joint object. Holds the joint frame relative to each body, plus body names to lookup elsewhere.

BasicModelData

Basic intermediate representation of a multibody model.

Module Contents#

class intermediateTypes.SimpleQuaternion(xyzw: numpy.ndarray | list | tuple)#

Minimal unit quaternion class using x,y,z,w representation.

__slots__ = ('_q',)#
classmethod identity() SimpleQuaternion#

Compute a quaternion corresponding to the identity operation.

conjugate() SimpleQuaternion#

Get conjugate representation (same as inverse since we’re a unit quaternion).

__mul__(other: SimpleQuaternion) SimpleQuaternion#
__mul__(other: numpy.ndarray) numpy.ndarray

Multiply this quaternion A by either another quaternion B (e.g., A * B) or by a vector v (e.g., A * v).

__eq__(other) bool#

Equality test.

__repr__()#

Dump quaternion into a string representation.

class intermediateTypes.SimpleHomTran(/, **data: Any)#

Bases: pydantic.BaseModel

Simple Homogeneous Transformation object corresponding to a passive rotation + offset.

translation: numpy.ndarray = None#
rotation: SimpleQuaternion = None#
__repr__()#

Dump HomTran into a string representation.

classmethod identity() SimpleHomTran#

Construct a SimpleHomTran corresponding to identity.

__eq__(other)#

Check equality.

__mul__(other: SimpleHomTran) SimpleHomTran#
__mul__(other: numpy.ndarray) numpy.ndarray

Premultiply this by either another SimpleHomTran or a numpy array of 3-vectors.

inverse() SimpleHomTran#

Get inverse transformation.

model_config#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class intermediateTypes.MeshData(/, **data: Any)#

Bases: pydantic.BaseModel

Basic representation of a triangle mesh.

vertices: numpy.ndarray#
faces: numpy.ndarray#
__repr__()#

Display mesh concisely as a string.

model_config#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class intermediateTypes.BasicBody(/, **data: Any)#

Bases: pydantic.BaseModel

Basic representation of a Body object.

name: str#
label: str#
source_object_name: str | None#
body_frame: SimpleHomTran#

Body frame relative to global origin

density: float#
visible: bool#
mesh: MeshData | None#
mass: float#
cm_in_body: numpy.ndarray#

Vector from body frame to center-of-mass

inertia_matrix_in_body: numpy.ndarray#

Inertia matrix in the body frame (not the CM frame)

rgba: numpy.ndarray | None = None#

Color for the body in RGBA (or None)

model_config#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class intermediateTypes.BasicJoint(/, **data: Any)#

Bases: pydantic.BaseModel

Basic representation of a joint object. Holds the joint frame relative to each body, plus body names to lookup elsewhere.

name: str#
joint_type: str#
body_1_name: str#
body_2_name: str#
body_1_to_joint: SimpleHomTran#
body_2_to_joint: SimpleHomTran#
model_config#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class intermediateTypes.BasicModelData(/, **data: Any)#

Bases: pydantic.BaseModel

Basic intermediate representation of a multibody model.

bodies: dict[str, BasicBody]#
joints: dict[str, BasicJoint]#
grounded_bodies: list[str]#
extra_info: dict[str, Any]#
to_yaml(path: str | pathlib.Path | None = None) str#

Write this data structure to a yaml file.

Parameters:

path (str | Path | None) – If given, automatically writes all yaml data to a file.

Returns:

Serialized yaml representation of this data structure.

Return type:

str

classmethod from_yaml(yaml_input: str | pathlib.Path) BasicModelData#

Load a yaml input file into an intermediate representation.