Karana.Dynamics.SOADyn_types

Contents

Karana.Dynamics.SOADyn_types#

Collection of types that represent SOADyn classes as DataStructs.

There are DataStructs that represent the classes (the structure of the Multibody and associated classes) and their states. For example, MultibodyDS is used to represent the data needed to create a Multibody class and all the associated bodies, nodes, etc. SubGraphStateDS is used to represent the coordinates of the various subhinges, force nodes, etc. that make up the SubGraph. Together, they can be used to represent the Multibody at an instance in time (both the structure and state).

Attributes#

Classes#

ConstraintFrameDS

DataStruct used to represent a frame that is part of a constraint.

NodeDS

DataStruct used to represent a Node.

ForceNodeStateDS

This class holds state data for a force node.

SubhingeDS

Base class for all subhinges.

PinSubhingeDS

PinSubhinge DataStruct.

LinearSubhingeDS

LinearSubhinge DataStruct.

SphericalSubhingeDS

SphericalSubhinge DataStruct.

Linear3SubhingeDS

Linear3Subhinge DataStruct.

LockedSubhingeDS

LockedSubhinge DataStruct.

ScrewSubhingeDS

ScrewSubhinge DataStruct.

SubhingeStateDS

This class holds the state of a subhinge.

HingeDS

Base class for all hinge types.

HingeStateDS

Represents the state of a hinge.

LoopConstraintDS

Represents a loop constraint.

LoopConstraintCutJointDS

Represents a loop constraint across a hinge.

LoopConstraintConVelDS

Represents a constant velocity loop constraint.

BodyDS

A DataStruct that represents a PhysicalBody.

BodyStateDS

This class holds state data for a body.

BodyWithContextDS

A BodyDS with context, i.e., with children that are defined by `BodyDS`s.

BodyStateWithContextDS

A BodyStateDS with context, i.e., with children that are defined by `BodyStateDS`s.

CoordinateConstraintDS

CoordinateConstraint DataStruct.

MultibodyDS

Multibody DataStruct.

BaseDataDS

DataStruct for BaseData.

CoordDataDS

DataStruct for CoordData.

SubTreeStateDS

SubTree State DataStruct.

SubGraphStateDS

SubGraph State DataStruct.

KModelDS

A base class for representing a KModel as a DataStruct.

StatePropagatorDS

A DataStruct that represents the StatePropagator.

Module Contents#

Karana.Dynamics.SOADyn_types.HAVE_MODAL_FLEX = True#
Karana.Dynamics.SOADyn_types.HAVE_MODAL_FLEX = True#
Karana.Dynamics.SOADyn_types.SubhingePyType#
class Karana.Dynamics.SOADyn_types.ConstraintFrameDS(/, **data: Any)[source]#

Bases: Karana.KUtils.DataStruct.DataStruct

DataStruct used to represent a frame that is part of a constraint.

Parameters:
  • name (str) – Name of the frame.

  • translation (Vec3) – Translation of the frame relative to its parent.

  • unit_quaternion (UnitQuaternion) – UnitQuaternion that represents the orientation of the frame relative to its parent.

  • parent (Literal["newtonian","vroot"]) – Parent frame. For constraint frames, this can only be the newtonian frame or the vroot (virtual root).

name: str#
translation: Karana.KUtils.Ktyping.Length3#
unit_quaternion: Karana.Math.UnitQuaternion#
parent: Literal['newtonian', 'vroot']#
property rel_transform: Karana.Math.HomTran#

The HomTran of the constraint frame relative to it’s parent.

toFrame(mb: Karana.Dynamics.Multibody) Karana.Frame.Frame[source]#

Create an instance of a Frame from this ConstraintFrameDS.

Parameters:

mb (Multibody) – The Multibody to add the constraint frame to.

Returns:

Frame instance created from this ConstraintFrameDS.

Return type:

Frame

classmethod fromFrame(frame: Karana.Frame.Frame, mb: Karana.Dynamics.Multibody) Self[source]#

Create an instance of ConstraintFrameDS from the provided Frame.

Parameters:
  • frame (Frame) – The Frame used to create the ConstraintFrameDS.

  • mb (Multibody) – The Multibody using the constraint frame.

Returns:

A ConstraintFrameDS that represents the provided Frame.

Return type:

Self

class Karana.Dynamics.SOADyn_types.NodeDS(/, **data: Any)[source]#

Bases: Karana.KUtils.DataStruct.DataStruct, Karana.KUtils.DataStruct.IdMixin[Karana.Dynamics.Node], Karana.KUtils.DataStruct.NestedBaseMixin

DataStruct used to represent a Node.

Parameters:
  • name (str) – The name of the node.

  • force_node (bool) – Whether or not this node is a force node.

  • translation (Length3 = np.zeros(3)) – The body-to-node translation.

  • unit_quaternion (UnitQuaternion = UnitQuaternion(0.0, 0.0, 0.0, 1.0)) – The body-to-node unit quaternion.

name: str#
constraint_node: bool#
force_node: bool#
translation: Karana.KUtils.Ktyping.Length3#
unit_quaternion: Karana.Math.UnitQuaternion#
property body_to_node_transform: Karana.Math.HomTran#

A HomTran that represents the body to node transform of the node.

Returns:

HomTran that represents the body to node transform of the node.

Return type:

HomTran

toNode(body: Karana.Dynamics.PhysicalBody) Karana.Dynamics.Node[source]#

Create a Node from this NodeDS.

Parameters:

body (PhysicalBody) – The body to attach the node to.

classmethod fromNode(nd: Karana.Dynamics.Node) Self[source]#

Create a NodeDS from the given Node.

Parameters:

nd (Node) – The Node to use to create this NodeDS.

class Karana.Dynamics.SOADyn_types.ForceNodeStateDS(/, **data: Any)[source]#

Bases: Karana.KUtils.DataStruct.DataStruct

This class holds state data for a force node.

Parameters:
  • name (str) – Name of the node.

  • external_spatial_force (SpatialVector) – The external spatial force on the node in the local node frame.

name: str#
external_spatial_force: Karana.Math.SpatialVector#
classmethod fromNode(force_node: Karana.Dynamics.Node) Self[source]#

Create a ForceNodeStateDS from the provided node.

Parameters:

force_node (Node) – The force node used to create the ForceNodeStateDS.

Returns:

The ForceNodeStateDS.

Return type:

Self

toNode(nd: Karana.Dynamics.Node) None[source]#

Set the state of the provided node.

Parameters:

nd (Node) – The node to set the state of.

class Karana.Dynamics.SOADyn_types.SubhingeDS(/, **data: Any)[source]#

Bases: Karana.KUtils.DataStruct.DataStruct, Karana.KUtils.DataStruct.NestedBaseMixin

Base class for all subhinges.

Parameters:

subhinge_type (SubhingeType) – The subhinge type associated with the subhinge.

subhinge_type: Karana.Dynamics.SubhingeType#
classmethod fromSubhinge(sh: SubhingePyType) SubhingeDS[source]#

Create an instance of SubhingeDS from the provided Subhinge.

Parameters:

sh (SubhingeType) – The Subhinge used to create the SubhingeDS.

Returns:

A SubhingeDS that represents the provided Subhinge.

Return type:

Self

abstract setSubhingeValues(sh: SubhingePyType) None[source]#

Set the subhinge values for the provided subhinge.

class Karana.Dynamics.SOADyn_types.PinSubhingeDS(/, **data: Any)[source]#

Bases: SubhingeDS

PinSubhinge DataStruct.

Parameters:
  • unit_axis (Vec3) – Unit axis for the pin subhinge.

  • joint_limits (Annotated[Vec, npSizeCheck((2,))]) – The lower and upper bound for the joint limit.

  • prescribed (bool) – Determines if the subhinge is prescribed or not.

subhinge_type: Karana.Dynamics.SubhingeType#
unit_axis: Annotated[Karana.KUtils.Ktyping.Vec3, normCheck(1.0)]#
joint_limits: Annotated[Karana.KUtils.Ktyping.Vec, npSizeCheck(2)]#
prescribed: bool#
classmethod fromSubhinge(sh: Karana.Dynamics.PinSubhinge) Self[source]#

Create a PinSubhingeDS from a PinSubhinge.

setSubhingeValues(sh: Karana.Dynamics.PinSubhinge) None[source]#

Set the values of a PinSubhinge.

class Karana.Dynamics.SOADyn_types.LinearSubhingeDS(/, **data: Any)[source]#

Bases: SubhingeDS

LinearSubhinge DataStruct.

Parameters:
  • unit_axis (Vec3) – Unit axis for the pin subhinge.

  • joint_limits (Annotated[Vec, npSizeCheck((2,))]) – The lower and upper bound for the joint limit.

  • prescribed (bool) – Determines if the subhinge is prescribed or not.

subhinge_type: Karana.Dynamics.SubhingeType#
unit_axis: Annotated[Karana.KUtils.Ktyping.Vec3, normCheck(1.0)]#
joint_limits: Annotated[Karana.KUtils.Ktyping.Vec, npSizeCheck(2)]#
prescribed: bool#
classmethod fromSubhinge(sh: Karana.Dynamics.LinearSubhinge) Self[source]#

Create a LinearSubhingeDS from a LinearSubhinge.

setSubhingeValues(sh: Karana.Dynamics.LinearSubhinge) None[source]#

Set the values of a LinearSubhinge.

class Karana.Dynamics.SOADyn_types.SphericalSubhingeDS(/, **data: Any)[source]#

Bases: SubhingeDS

SphericalSubhinge DataStruct.

prescribedbool

Determines if the subhinge is prescribed or not.

subhinge_type: Karana.Dynamics.SubhingeType#
prescribed: bool#
classmethod fromSubhinge(sh: Karana.Dynamics.SphericalSubhinge) Self[source]#

Create a SphericalSubhingeDS from a SphericalSubhinge.

setSubhingeValues(sh: Karana.Dynamics.SphericalSubhinge) None[source]#

Set the values of a SphericalSubhinge.

class Karana.Dynamics.SOADyn_types.Linear3SubhingeDS(/, **data: Any)[source]#

Bases: SubhingeDS

Linear3Subhinge DataStruct.

Parameters:

prescribed (bool) – Determines if the subhinge is prescribed or not.

subhinge_type: Karana.Dynamics.SubhingeType#
prescribed: bool#
classmethod fromSubhinge(sh: Karana.Dynamics.Linear3Subhinge) Self[source]#

Create a Linear3SubhingeDS from a Linear3Subhinge.

setSubhingeValues(sh: Karana.Dynamics.Linear3Subhinge) None[source]#

Set the values of a Linear3Subhinge.

class Karana.Dynamics.SOADyn_types.LockedSubhingeDS(/, **data: Any)[source]#

Bases: SubhingeDS

LockedSubhinge DataStruct.

subhinge_type: Karana.Dynamics.SubhingeType#
classmethod fromSubhinge(_: Karana.Dynamics.LockedSubhinge) Self[source]#

Create a LockedSubhingeDS from a LockedSubhinge.

setSubhingeValues(_: Karana.Dynamics.LockedSubhinge) None[source]#

Set the values of a LockedSubhinge.

class Karana.Dynamics.SOADyn_types.ScrewSubhingeDS(/, **data: Any)[source]#

Bases: SubhingeDS

ScrewSubhinge DataStruct.

Parameters:
  • prescribed (bool) – Determines if the subhinge is prescribed or not.

  • unit_axis (Vec3) – Unit axis for the pin subhinge.

  • pitch (float) – The pitch of the screw subhinge.

  • joint_limits (Annotated[Vec, npSizeCheck((2,))]) – The lower and upper bound for the joint limit.

subhinge_type: Karana.Dynamics.SubhingeType#
prescribed: bool#
unit_axis: Annotated[Karana.KUtils.Ktyping.Vec3, normCheck(1.0)]#
pitch: float#
joint_limits: Annotated[Karana.KUtils.Ktyping.Vec, npSizeCheck(2)]#
classmethod fromSubhinge(sh: Karana.Dynamics.ScrewSubhinge) Self[source]#

Create a ScrewSubhingeDS from a ScrewSubhinge.

setSubhingeValues(sh: Karana.Dynamics.ScrewSubhinge) None[source]#

Set the values of a ScrewSubhinge.

class Karana.Dynamics.SOADyn_types.SubhingeStateDS(/, **data: Any)[source]#

Bases: Karana.KUtils.DataStruct.DataStruct

This class holds the state of a subhinge.

Parameters:
  • Q (Vec) – Positional state of the subhinge.

  • U (Vec) – Velocity state of the subhinge.

  • Udot (Vec) – Acceleration state of the subhinge.

  • T (Vec) – Force state of the subhinge.

Q: Karana.KUtils.Ktyping.Vec#
U: Karana.KUtils.Ktyping.Vec#
Udot: Karana.KUtils.Ktyping.Vec#
T: Karana.KUtils.Ktyping.Vec#
classmethod fromSubhinge(sh: SubhingePyType) Self[source]#

Create a SubhingeStateDS from a subhinge.

Parameters:

sh (SubhingeBase) – The subhinge to create this from.

Returns:

A SubhingeStateDS that reflects the state of the provided subhinge.

Return type:

SubhingeStateDS

toSubhinge(sh: SubhingePyType) None[source]#

Set the state of the provided subhinge.

Parameters:

sh (SubhingeBase) – The subhinge whose state will be set using this.

class Karana.Dynamics.SOADyn_types.HingeDS(/, **data: Any)[source]#

Bases: Karana.KUtils.DataStruct.DataStruct

Base class for all hinge types.

Hinges that have 0 axes associated with them, e.g., BALL, use this DataStruct. Classes with more axes (or information) will use derived classes.

Parameters:
  • hinge_type (HingeType) – The hinge type associated with the hinge.

  • subhinges (list[SubhingeDS]) – A list of subhinges that make up this hinge.

hinge_type: Karana.Dynamics.HingeType#
subhinges: list[pydantic.SerializeAsAny[SubhingeDS]]#
toHinge(parent_bd: Karana.Dynamics.PhysicalBody, child_bd: Karana.Dynamics.PhysicalBody) Karana.Dynamics.PhysicalHinge[source]#

Create a Hinge between the provided bodies.

Parameters:
Returns:

The hinge that was created between the two provided bodies.

Return type:

PhysicalHinge

classmethod fromHinge(hge: Karana.Dynamics.FramePairHinge, htype: Karana.Dynamics.HingeType) Self[source]#

Create a HingeDS from the provided hinge.

Parameters:
  • hge (FramePairHinge) – The FramePairHinge used to create the HingeDS.

  • htype (HingeType) – The hinge type associated with the FramePairHinge.

Returns:

A HingeDS that represents the provided FramePairHinge.

Return type:

Self

class Karana.Dynamics.SOADyn_types.HingeStateDS(/, **data: Any)[source]#

Bases: Karana.KUtils.DataStruct.DataStruct

Represents the state of a hinge.

Parameters:

subhinges (list[SubhingeStateDS]) – Data for the hinge’s subhinges.

subhinges: list[SubhingeStateDS]#
classmethod fromHinge(hge: Karana.Dynamics.HingeBase) Self[source]#

Create a HingeStateDS from the provided hinge.

Parameters:

hge (HingeBase) – The hinge used to this HingeStateDS.

Returns:

A HingeStateDS that reflects the state of the provided hinge.

Return type:

HingeStateDS

toHinge(hge: Karana.Dynamics.HingeBase) None[source]#

Set the state of the provided hinge using this.

Parameters:

hge (HingeBase) – The hinge whose state will be set from this.

class Karana.Dynamics.SOADyn_types.LoopConstraintDS(/, **data: Any)[source]#

Bases: Karana.KUtils.DataStruct.DataStruct, Karana.KUtils.DataStruct.NestedBaseMixin

Represents a loop constraint.

Parameters:
  • name (str) – The name of the LoopConstraintCutJoint.

  • get_oframe (dict[Literal["body","frame","node"],str]) – A dictionary that specifies how to get to the associated oframe of the LoopConstraint. This uses body names, frame names, and node names to drill down to the correct location.

  • get_pframe (dict[Literal["body","frame","node"],str]) – A dictionary that specifies how to get to the associated pframe of the LoopConstraint. This uses body names, frame names, and node names to drill down to the correct location.

name: str#
get_oframe: dict[Literal['body', 'frame', 'node'], str]#
get_pframe: dict[Literal['body', 'frame', 'node'], str]#
classmethod fromLoopConstraint(lc: Karana.Dynamics.LoopConstraintBase) Self[source]#

Create a LoopConstraintDS from the provided LoopConstraintBase.

Parameters:

lc (LoopConstraintBase) – The LoopConstraintBase used to build this LoopConstraintDS.

Returns:

A LoopConstraintDS with the provided LoopConstraint information.

Return type:

LoopConstraintDS

toCutJointConstraint(mb: Karana.Dynamics.Multibody) Karana.Dynamics.LoopConstraintBase[source]#

Create a LoopConstraintBase from the LoopConstraintDS.

Parameters:

mb (Multibody) – The multibody to add this loop constraint to.

Returns:

The LoopConstraintBase created from this LoopConstraintDS.

Return type:

LoopConstraintBase

class Karana.Dynamics.SOADyn_types.LoopConstraintCutJointDS(/, **data: Any)[source]#

Bases: LoopConstraintDS

Represents a loop constraint across a hinge.

Parameters:
  • name (str) – The name of the LoopConstraintCutJoint.

  • hinge (HingeDS) – The hinge information associated with the LoopConstraintCutJoint.

  • get_oframe (dict[Literal["body","frame","node"],str]) – A dictionary that specifies how to get to the associated oframe of the LoopConstraintCutJoint. This uses body names, frame names, and node names to drill down to the correct location.

  • get_pframe (dict[Literal["body","frame","node"],str]) – A dictionary that specifies how to get to the associated pframe of the LoopConstraintCutJoint. This uses body names, frame names, and node names to drill down to the correct location.

loop_constraint_type: Literal['LoopConstraintCutJoint'] = 'LoopConstraintCutJoint'#
hinge: HingeDS#
classmethod fromLoopConstraintCutJoint(lc: Karana.Dynamics.LoopConstraintCutJoint) Self[source]#

Create a LoopConstraintCutJointDS from the provided LoopConstraintCutJoint.

Parameters:

lc (LoopConstraintCutJoint) – The LoopConstraintCutJoint used to build this LoopConstraintDS.

Returns:

A LoopConstraintDS with the provided LoopConstraintCutJoint information.

Return type:

LoopConstraintDS

toCutJointConstraintCutJoint(mb: Karana.Dynamics.Multibody) Karana.Dynamics.LoopConstraintCutJoint[source]#

Create a LoopConstraintCutJoint from the LoopConstraintDS.

Parameters:

mb (Multibody) – The multibody to add this loop constraint to.

Returns:

The LoopConstraintCutJoint created from this LoopConstraintDS.

Return type:

LoopConstraintCutJoint

class Karana.Dynamics.SOADyn_types.LoopConstraintConVelDS(/, **data: Any)[source]#

Bases: LoopConstraintDS

Represents a constant velocity loop constraint.

Parameters:
  • name (str) – The name of the LoopConstraintConVel.

  • get_oframe (dict[Literal["body","frame","node"],str]) – A dictionary that specifies how to get to the associated oframe of the LoopConstraintConVel. This uses body names, frame names, and node names to drill down to the correct location.

  • get_pframe (dict[Literal["body","frame","node"],str]) – A dictionary that specifies how to get to the associated pframe of the LoopConstraintConVel. This uses body names, frame names, and node names to drill down to the correct location.

  • unit_axis (Annotated[Vec3, normCheck(1.0)]) – The constraint unit axis

  • is_rotational (bool) – Whether the constraint is rotational or translational

loop_constraint_type: Literal['LoopConstraintConVel'] = 'LoopConstraintConVel'#
unit_axis: Annotated[Karana.KUtils.Ktyping.Vec3, normCheck(1.0)]#
is_rotational: bool#
classmethod fromLoopConstraintConVel(lc: Karana.Dynamics.LoopConstraintConVel) Self[source]#

Create a LoopConstraintConVelDS from the provided LoopConstraintConVel.

Parameters:

lc (LoopConstraintConVel) – The LoopConstraintConVel used to build this LoopConstraintConVelDS.

Returns:

A LoopConstraintConVelDS with the provided LoopConstraintConVel information.

Return type:

LoopConstraintConVelDS

toCutJointConstraintConVel(mb: Karana.Dynamics.Multibody) Karana.Dynamics.LoopConstraintConVel[source]#

Create a LoopConstraintConVel from the LoopConstraintConVelDS.

Parameters:

mb (Multibody) – The multibody to add this loop constraint to.

Returns:

The LoopConstraintConVel created from this LoopConstraintConVelDS.

Return type:

LoopConstraintConVel

class Karana.Dynamics.SOADyn_types.BodyDS(/, **data: Any)[source]#

Bases: Karana.KUtils.DataStruct.DataStruct, Karana.KUtils.DataStruct.IdMixin[Karana.Dynamics.PhysicalBody], Karana.KUtils.DataStruct.NestedBaseMixin

A DataStruct that represents a PhysicalBody.

Parameters:
  • name (str) – The name of the body.

  • sensor_nodes (list[NodeDS]) – A list of sensor nodes attached to the body.

  • force_nodes (list[NodeDS] = []) – A list of force nodes attached to the body.

  • hinge (HingeDS) – The HingeDS that describes the hinge.

  • mass (Mass) – The mass of the body.

  • body_to_cm (Length3 = np.zeros(3)) – The body-to-center-of-mass vector.

  • inertia (Inertia = np.zeros(3,3)) – The inertia of the body, given in the body frame.

  • body_to_joint (Length3 = np.zeros(3)) – The body-to-joint translation.

  • body_to_joint_quat (UnitQuaternion = UnitQuaternion(0.0, 0.0, 0.0, 1.0)) – The body-to-joint unit quaternion.

  • inb_to_joint (Length3 = np.zeros(3)) – The inboard-body-to-joint translation.

  • inb_to_joint_quat (UnitQuaternion = UnitQuaternion(0.0, 0.0, 0.0, 1.0)) – The inboard-body-to-joint unit quaternion.

  • inb_nodal_matrix (Optional[Mat6n] = None) – 6xn matrix for the inboard body nodal matrix. Should be set if the inboard body is a PhysicalModalBody. Should be None otherwise.

  • scene_parts (List[ScenePartSpecDS]) – List of import parts that make up the geometry.

  • inb_nodal_matrix – Nodal matrix for the onode of the parent body if the parent body is a PhysicalModalBody.

name: str#
sensor_nodes: list[pydantic.SerializeAsAny[NodeDS]] = []#
force_nodes: list[pydantic.SerializeAsAny[NodeDS]] = []#
constraint_nodes: list[pydantic.SerializeAsAny[NodeDS]] = []#
hinge: HingeDS#
mass: Karana.KUtils.Ktyping.Mass#
body_to_cm: Karana.KUtils.Ktyping.Length3#
inertia: Karana.KUtils.Ktyping.Inertia#
body_to_joint: Karana.KUtils.Ktyping.Length3#
body_to_joint_quat: Karana.Math.UnitQuaternion#
inb_to_joint: Karana.KUtils.Ktyping.Length3#
inb_to_joint_quat: Karana.Math.UnitQuaternion#
scene_parts: list[Karana.Scene.Scene_types.ScenePartSpecDS] = []#
inb_nodal_matrix: Karana.KUtils.Ktyping.Mat6n | None = None#
property body_to_joint_transform: Karana.Math.HomTran#

The HomTran between the body frame and the pnode of the hinge.

property inb_to_joint_transform: Karana.Math.HomTran#

The HomTran between the parent body frame and the onode of the hinge.

property spatial_inertia: Karana.Math.SpatialInertia#

The spatial inertia of the body.

classmethod fromBody(body: Karana.Dynamics.PhysicalBody) Self[source]#

Create a BodyDS from a PhysicalBody.

Parameters:

body (PhysicalBody) – The PhysicalBody used to create the BodyDS.

Returns:

The BodyDS.

Return type:

Self

toBody(parent_body: Karana.Dynamics.PhysicalBody) Karana.Dynamics.PhysicalBody[source]#

Create a body from the BodyDS.

Parameters:

parent_body (PhysicalBody) – Body to attach the new body to.

Returns:

The new body.

Return type:

PhysicalBody

toUrdf(parent_link: str) tuple[urchin.Link, urchin.Joint][source]#

Convert the BodyDS to a urchin Link and Joint. These can be used to create a URDF file.

Parameters:

parent_link (str) – The name of the parent link for the Joint.

Returns:

The Link and Joint associated with this body.

Return type:

tuple[Link, Joint]

classmethod fromUrdf(link: urchin.Link, joint: urchin.Joint) Self[source]#

Convert from a urchin Link and Joint to a BodyDS.

Parameters:
  • link (Link) – The URDF Link.

  • joint (Joint) – The URDF parent joint.

Returns:

BodyDS for the link and joint.

Return type:

Self

class Karana.Dynamics.SOADyn_types.BodyStateDS(/, **data: Any)[source]#

Bases: Karana.KUtils.DataStruct.DataStruct, Karana.KUtils.DataStruct.NestedBaseMixin

This class holds state data for a body.

Parameters:
  • name (str) – The name of the body.

  • grav_accel (Acceleration3) – The acceleration due to gravity.

  • hinge (HingeStateDS) – The state of the hinge.

  • force_node_states (list[ForceNodeStateDS] = []) – The states of the force nodes on the body.

name: str#
grav_accel: Karana.KUtils.Ktyping.Acceleration3#
hinge: HingeStateDS#
force_node_states: list[ForceNodeStateDS] = []#
classmethod fromBody(bd: Karana.Dynamics.PhysicalBody) Self[source]#

Create a BodyStateDS from the provided body.

Parameters:

bd (PhysicalBody) – The body used to create the state.

Returns:

The BodyStateDS.

Return type:

Self

toBody(bd: Karana.Dynamics.PhysicalBody) None[source]#

Set the state of the provided body.

Parameters:

bd (PhysicalBody) – The body to set the state of.

type Karana.Dynamics.SOADyn_types.LinkJointTree = list[tuple[Link, Joint, 'LinkJointTree']]#
class Karana.Dynamics.SOADyn_types.BodyWithContextDS(/, **data: Any)[source]#

Bases: Karana.KUtils.DataStruct.DataStruct

A BodyDS with context, i.e., with children that are defined by `BodyDS`s.

Parameters:
  • body (BodyDS) – The body we are defining with context.

  • children (list[BodyWithContextDS]) – The child bodies of this body, also given as `BodyWithContextDS`s.

body: pydantic.SerializeAsAny[BodyDS]#
children: list[BodyWithContextDS] = []#
toBody(parent_body: Karana.Dynamics.PhysicalBody) Karana.Dynamics.PhysicalBody[source]#

Create a body from the BodyWithContextDS.

Parameters:

parent_body (PhysicalBody) – Body to attach the new body to.

Returns:

The new body.

Return type:

PhysicalBody

classmethod fromBody(body: Karana.Dynamics.PhysicalBody, st: Karana.Dynamics.SubTree) Self[source]#

Create a BodyWithContextDS from a PhysicalBody.

Parameters:
  • body (PhysicalBody) – The PhysicalBody used to create the BodyWithContextDS.

  • st (SubTree) – The SubTree to use for context (the body’s children in the bu-tree may be a subset of the full set of physical children bodies

Returns:

The BodyWithContextDS.

Return type:

Self

toUrdf(parent_link: str) tuple[list[urchin.Link], list[urchin.Joint]][source]#

Convert this BodyWithContextDS to a list of Links and Joints. These can be used to create a URDF file.

Parameters:

parent_link (str) – The name of the parent link for the body of this BodyWithContextDS.

Returns:

The Links and Joints associated with the body and children of this BodyWithContextDS.

Return type:

tuple[list[Link], list[Joint]]

classmethod fromUrdf(link: urchin.Link, joint: urchin.Joint, children_urdf: LinkJointTree)[source]#

Convert from links and joints to BodyWithContextDS.

Parameters:
  • link (Link) – The link to use for creating the body.

  • joint (Joint) – The joint to use for creating the body.

  • children_urdf (LinkJointTree) – A LinkJointTree that defines the links and joints to use for the children. This is an arbitrarily nested list of tuples of links and joints, each of which can be used to define a body.

Returns:

An instance of BodyWithContextDS.

Return type:

Self

class Karana.Dynamics.SOADyn_types.BodyStateWithContextDS(/, **data: Any)[source]#

Bases: Karana.KUtils.DataStruct.DataStruct

A BodyStateDS with context, i.e., with children that are defined by `BodyStateDS`s.

Parameters:
  • body (BodyStateDS) – The body state we are defining with context.

  • children (list[BodyStateWithContextDS]) – The state of child bodies of this body, also given as `BodyStateWithContextDS`s.

Returns:

The BodyStateWithContextDS.

Return type:

Self

body: pydantic.SerializeAsAny[BodyStateDS]#
children: list[BodyStateWithContextDS] = []#
classmethod fromBody(bd: Karana.Dynamics.PhysicalBody, st: Karana.Dynamics.SubTree) Self[source]#

Create a BodyStateWithContextDS from the provided PhysicalBody.

This will capture the provided PhysicalBody state as a BodyStateDS in the body field and all of its children as BodyStateWithContextDSs in the children field. This happens recursively.

Parameters:
  • bd (PhysicalBody) – The body used to create the BodyStateWithContextDS.

  • st (SubTree) – The SubTree to use for context (the body’s children in the bu-tree may be a subset of the full set of physical children bodies

Returns:

An instance of BodyStateWithContextDS that represents the provided PhysicalBody.

Return type:

Self

toBody(bd: Karana.Dynamics.PhysicalBody) None[source]#

Set the state of the provided body and its children.

Parameters:

bd (PhysicalBody) – The body to set the state of.

class Karana.Dynamics.SOADyn_types.CoordinateConstraintDS(/, **data: Any)[source]#

Bases: Karana.KUtils.DataStruct.DataStruct, Karana.KUtils.DataStruct.IdMixin[Karana.Dynamics.CoordinateConstraint]

CoordinateConstraint DataStruct.

Parameters:
  • name (str) – Name of the CoordinateConstraint.

  • obody_name (str) – Name of the body whose parent hinge the osubhinge belongs to

  • osubhinge_index (int) – Index of the osubhinge within its hinge

  • pbody_name (str) – Name of the body whose parent hinge the psubhinge belongs to

  • psubhinge_index (int) – Index of the psubhinge within its hinge

  • scale_ratio (float) – The coordinate scale ratio

name: str#
obody_name: str#
osubhinge_index: int#
pbody_name: str#
psubhinge_index: int#
scale_ratio: float#
classmethod fromCoordinateConstraint(cc: Karana.Dynamics.CoordinateConstraint) Self[source]#

Create a CoordinateConstraintDS from a CoordinateConstraint.

Parameters:

cc (CoordinateConstraint) – The CoordinateConstraint used to create the CoordinateConstraintDS.

Returns:

The CoordinateConstraintDS.

Return type:

Self

toCoordinateConstraint(mbody: Karana.Dynamics.Multibody) Karana.Dynamics.CoordinateConstraint[source]#

Create a CoordinateConstraint from the CoordinateConstraintDS.

Parameters:

mbody (Multibody) – Multibody the new CoordinateConstraint will belong to

Returns:

The CoordinateConstraint.

Return type:

CoordinateConstraint

class Karana.Dynamics.SOADyn_types.MultibodyDS(/, **data: Any)[source]#

Bases: Karana.KUtils.DataStruct.DataStruct, Karana.KUtils.DataStruct.IdMixin[Karana.Dynamics.Multibody]

Multibody DataStruct.

Parameters:
  • name (str) – Name of the multibody.

  • base_bodies (list[BodyWithContextDS]) – The bodies attached to the virtual root.

  • loop_constraints (list[LoopConstraintDS]) – Loop constraints in the multibody

  • constraint_frames (list[ConstraintFrameDS]) – Extra frames that are part of constraints

  • coordinate_constraints (list[CoordinateConstraintDS]) – Coordinate constraints in the multibody

name: str#
base_bodies: list[BodyWithContextDS]#
loop_constraints: list[pydantic.SerializeAsAny[LoopConstraintDS]] = []#
constraint_frames: list[ConstraintFrameDS] = []#
coordinate_constraints: list[CoordinateConstraintDS] = []#
toMultibody(fc: Karana.Frame.FrameContainer, newtonian_frame: Karana.Frame.Frame | None = None, scene: Karana.Scene.ProxyScene | None = None) Karana.Dynamics.Multibody[source]#

Create a Multibody from this MultibodyDS.

Parameters:

fc (FrameContainer) – FrameContainer to use to create the multibody.

Returns:

The new multibody.

Return type:

Multibody

attachToBody(root_bd: Karana.Dynamics.PhysicalBody, prefix: str = '') list[Karana.Dynamics.PhysicalBody][source]#

Create the SubGraph of bodies in this DS and attach it to the specified root body.

Parameters:

root_bd (PhysicalBody) – The root body to attach to.

Returns:

List of new base_bodies for the new bodies

Return type:

list[PhysicalBody]

classmethod fromSubTree(st: Karana.Dynamics.SubTree) Self[source]#

Create a MultibodyDS from a SubTree. This will include only the bodies of the provided SubTree.

Parameters:

st (SubTree) – The SubTree used to create the MultibodyDS.

Returns:

The MultibodyDS.

Return type:

Self

classmethod fromMultibody(mb: Karana.Dynamics.Multibody) Self[source]#

Create a MultibodyDS from a Multibody.

Parameters:

mb (Multibody) – The Multibody used to create the MultibodyDS.

Returns:

The MultibodyDS.

Return type:

Self

classmethod fromSubGraph(sg: Karana.Dynamics.SubGraph) Self[source]#

Create a MultibodyDS from a SubGraph.

This will be a MultibodyDS with only the bodies and constraints included in the SubGraph.

Parameters:

sg (SubGraph) – The SubGraph used to create the MultibodyDS.

Returns:

The MultibodyDS.

Return type:

Self

toUrdf(file: pathlib.Path | str)[source]#

Convert the MultibodyDS to a URDF file.

Parameters:

file (Path | str) – The file to write the URDF to.

classmethod fromUrdf(file: pathlib.Path | str) Self[source]#

Read a URDF file and convert it to a MultibodyDS.

Parameters:

file (Path | str) – The file to write the URDF from.

Returns:

A MultibodyDS that corresponds to the URDF.

Return type:

MultibodyDS

class Karana.Dynamics.SOADyn_types.BaseDataDS(/, **data: Any)[source]#

Bases: Karana.KUtils.DataStruct.DataStruct

DataStruct for BaseData.

Parameters:
  • Q (Vec) – Position-level coordinates.

  • U (Vec) – Velocity-level coordinates.

  • Udot (Vec) – Acceleration-level coordinates.

  • T (Vec) – Force-level coordinates.

Q: Karana.KUtils.Ktyping.Vec#
U: Karana.KUtils.Ktyping.Vec#
Udot: Karana.KUtils.Ktyping.Vec#
T: Karana.KUtils.Ktyping.Vec#
toCoordBase(b: Karana.Dynamics.CoordBase)[source]#

Set the state of the provided CoordBase using this BaseDataDS.

Parameters:

b (CoordBase) – The CoordBase whose values will be set.

class Karana.Dynamics.SOADyn_types.CoordDataDS(/, **data: Any)[source]#

Bases: Karana.KUtils.DataStruct.DataStruct

DataStruct for CoordData.

Parameters:

base_data (dict[str, BaseDataDS]) – Data from the BaseData.

base_data: dict[str, BaseDataDS]#
classmethod fromCoordData(c: Karana.Dynamics.CoordData) Self[source]#

Create a CoordDataDS that represents the provided CoordData.

Parameters:

c (CoordData) – The CoordData to represent as a CoordDataDS.

Return type:

An instance of CoordDataDS that represents the provided CoordData.

toCoordData(c: Karana.Dynamics.CoordData) None[source]#

Set the state of the provided CoordData.

Parameters:

c (CoordData) – The CoordData to set the state of.

class Karana.Dynamics.SOADyn_types.SubTreeStateDS(/, **data: Any)[source]#

Bases: Karana.KUtils.DataStruct.DataStruct

SubTree State DataStruct.

Parameters:

base_bodies (list[BodyStateWithContextDS]) – The state of the bodies attached to the virtual root.

base_bodies: list[BodyStateWithContextDS]#
classmethod fromSubTree(st: Karana.Dynamics.SubTree) Self[source]#

Create a SubTreeStateDS from a SubTree.

Parameters:

st (SubTree) – The SubTree used to create the SubTreeStateDS.

Returns:

The SubTreeStateDS.

Return type:

Self

toSubTree(st: Karana.Dynamics.SubTree) None[source]#

Set the state of the provided multibody.

Parameters:

st (SubTree) – The multibody to set the state of.

class Karana.Dynamics.SOADyn_types.SubGraphStateDS(/, **data: Any)[source]#

Bases: Karana.KUtils.DataStruct.DataStruct

SubGraph State DataStruct.

Parameters:
  • sub_tree_state (SubTreeStateDS) – The state of the subtree.

  • constraint_coord_data (CoordDataDS) – The state of the constraint coordinate data.

sub_tree_state: SubTreeStateDS#
constraint_coord_data: CoordDataDS#
classmethod fromSubGraph(sg: Karana.Dynamics.SubGraph) Self[source]#

Create a SubGraphStateDS from a SubGraph.

Parameters:

sg (SubGraph) – The SubGraph used to create the SubGraphStateDS.

Returns:

The SubGraphStateDS.

Return type:

Self

toSubGraph(sg: Karana.Dynamics.SubGraph) None[source]#

Set the state of the provided multibody.

Parameters:

sg (SubGraph) – The multibody to set the state of.

Karana.Dynamics.SOADyn_types.T#
class Karana.Dynamics.SOADyn_types.KModelDS(/, **data: Any)[source]#

Bases: Karana.KUtils.DataStruct.DataStruct, Karana.KUtils.DataStruct.NestedBaseMixin, Karana.KUtils.DataStruct.IdMixin[T], Generic[T]

A base class for representing a KModel as a DataStruct.

name: str#
period: float | numpy.timedelta64#
abstract toModel(mm: Karana.Dynamics.ModelManager) Karana.Models.BaseKModel[source]#

Create an model instance from this KModelDS.

Parameters:

mm (ModelManager) – The ModelManager to associate the newly created model instance with.

Returns:

A model instance created from this KModelDS.

Return type:

BaseKModel

class Karana.Dynamics.SOADyn_types.StatePropagatorDS(/, **data: Any)[source]#

Bases: Karana.KUtils.DataStruct.DataStruct

A DataStruct that represents the StatePropagator.

Parameters:
  • integrator_type (IntegratorType) – Type of integrator used.

  • integrator_options (Optional[IntegratorOptionsDS] = None) – The options associated with the integrator.

  • solver_type (Optional[MMSolverType] = MMSolverType.UNDEFINED) – The options associated with the integrator.

  • models (list[KModelDS]) – The models registered with the StatePropagator.

integrator_type: Karana.Math.IntegratorType#
integrator_options: Karana.Math.Integrator_types.IntegratorOptionsDS | None = None#
solver_type: Karana.Dynamics.MMSolverType | None#
models: list[pydantic.SerializeAsAny[KModelDS]]#
classmethod fromStatePropagator(sp: Karana.Dynamics.StatePropagator) Self[source]#

Create a StatePropagatorDS from a StatePropagator.

Parameters:

body (StatePropagator) – The StatePropagator used to create the StatePropagatorDS.

Returns:

The StatePropagatorDS.

Return type:

Self

toStatePropagatorNoModels(st: Karana.Dynamics.SubTree) Karana.Dynamics.StatePropagator[source]#

Create a StatePropagator from the StatePropagatorDS.

This does NOT add the models to the StatePropagator. If you want the models to, use the toStatePropagator method.

Parameters:

st (SubTree) – The SubTree to use to create the StatePropagator.

Returns:

The StatePropagator associated with this StatePropagatorDS, but without any models.

Return type:

StatePropagator

toStatePropagator(st: Karana.Dynamics.SubTree) Karana.Dynamics.StatePropagator[source]#

Create a StatePropagator from the StatePropagatorDS.

Parameters:

st (SubTree) – The SubTree to associate with the StatePropagator.