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, SubGraphDS 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#
DataStruct used to represent a frame that is part of a constraint. |
|
DataStruct used to represent a Node. |
|
Holds state data for a force node. |
|
Holds the state of a subhinge. |
|
Represents the state of a hinge. |
|
Represents a loop constraint. |
|
Represents a loop constraint across a hinge. |
|
Represents a constant velocity loop constraint. |
|
A DataStruct that represents a PhysicalBody. |
|
Holds state data for a body. |
|
A BodyDS with context, i.e., with children that are defined by `BodyDS`s. |
|
A BodyStateDS with context, i.e., with children that are defined by `BodyStateDS`s. |
|
CoordinateConstraint DataStruct. |
|
SubTree DataStruct. |
|
SubGraph DataStruct. |
|
DataStruct for BaseData. |
|
DataStruct for CoordData. |
|
SubTree State DataStruct. |
|
SubGraph State DataStruct. |
|
A base class for representing a KModel as a DataStruct. |
|
A base class for representing a KModel's state as a DataStruct. |
|
A DataStruct that represents MMOptions. |
|
A DataStruct that represents SpOptions. |
|
A DataStruct that represents the StatePropagator. |
|
A DataStruct used to capture information needed to setup graphics. |
|
Store setup information for the GUI. |
Functions#
|
Serialize the source/target of a LoopConstraint. |
Module Contents#
- Karana.Dynamics.SOADyn_types.HAVE_MODAL_FLEX = True#
- Karana.Dynamics.SOADyn_types.HAVE_MODAL_FLEX = True#
- class Karana.Dynamics.SOADyn_types.ConstraintFrameDS(*, name: str, translation: Karana.Math.Ktyping.Length[Karana.Math.Ktyping.Vec3] | Karana.Math.Ktyping.Vec3, unit_quaternion: Karana.Math.UnitQuaternion, parent: Literal['newtonian', 'vroot'])#
Bases:
Karana.KUtils.DataStruct.DataStruct,Karana.KUtils.DataStruct.IdMixin[Karana.Frame.Frame]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).
- translation: Karana.Math.Ktyping.Length[Karana.Math.Ktyping.Vec3]#
- 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#
Create an instance of a Frame from this ConstraintFrameDS.
- classmethod fromFrame(frame: Karana.Frame.Frame, mb: Karana.Dynamics.Multibody) Self#
Create an instance of ConstraintFrameDS from the provided Frame.
- class Karana.Dynamics.SOADyn_types.NodeDS(*, name: str, constraint_node: bool, force_node: bool, translation: Karana.Math.Ktyping.Length[Karana.Math.Ktyping.Vec3] | Karana.Math.Ktyping.Vec3 = ..., unit_quaternion: Karana.Math.UnitQuaternion = ...)#
Bases:
Karana.KUtils.DataStruct.DataStruct,Karana.KUtils.DataStruct.IdMixin[Karana.Dynamics.Node],Karana.KUtils.DataStruct.NestedBaseMixinDataStruct used to represent a Node.
- Parameters:
- translation: Karana.Math.Ktyping.Length[Karana.Math.Ktyping.Vec3]#
- 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:
- toNode(body: Karana.Dynamics.PhysicalBody) Karana.Dynamics.Node#
Create a Node from this NodeDS.
- Parameters:
body (PhysicalBody) – The body to attach the node to.
- classmethod fromNode(nd: Karana.Dynamics.Node) Self#
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)#
Bases:
Karana.KUtils.DataStruct.DataStructHolds 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.
- external_spatial_force: Karana.Math.SpatialForce#
- classmethod fromNode(force_node: Karana.Dynamics.Node) Self#
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#
Set the state of the provided node.
- Parameters:
nd (Node) – The node to set the state of.
- class Karana.Dynamics.SOADyn_types.SubhingeStateDS(/, **data: Any)#
Bases:
Karana.KUtils.DataStruct.DataStructHolds 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.Math.Ktyping.Vec#
- U: Karana.Math.Ktyping.Vec#
- Udot: Karana.Math.Ktyping.Vec#
- T: Karana.Math.Ktyping.Vec#
- classmethod fromSubhinge(sh: Karana.Dynamics.SubhingePyType) Self#
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:
- toSubhinge(sh: Karana.Dynamics.SubhingePyType) None#
Set the state of the provided subhinge.
- Parameters:
sh (SubhingeBase) – The subhinge whose state will be set using this.
- class Karana.Dynamics.SOADyn_types.HingeStateDS(/, **data: Any)#
Bases:
Karana.KUtils.DataStruct.DataStructRepresents 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#
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:
- toHinge(hge: Karana.Dynamics.HingeBase) None#
Set the state of the provided hinge using this.
- Parameters:
hge (HingeBase) – The hinge whose state will be set from this.
- Karana.Dynamics.SOADyn_types.serializeLoopConstraintNode(nd: Karana.Frame.Frame | Karana.Dynamics.ConstraintNode | Literal['newtonian'] | Literal['vroot'] | int) Literal['newtonian'] | Literal['vroot'] | int#
Serialize the source/target of a LoopConstraint.
This turns Frames into strings and ConstraintNodes into ints for serialization.
- Parameters:
nd (Frame | ConstraintNode | Literal["newtonian"] | Literal["vroot"] | int) – The incoming source or target.
- Returns:
The serialized version of the input.
- Return type:
Literal[“newtonian”] | Literal[“vroot”] | int
- class Karana.Dynamics.SOADyn_types.LoopConstraintDS(/, **data: Any)#
Bases:
Karana.KUtils.DataStruct.DataStruct,Karana.KUtils.DataStruct.NestedBaseMixinRepresents a loop constraint.
- Parameters:
name (str) – The name of the LoopConstraintCutJoint.
oframe (Frame | ConstraintNode) – The oframe of the LoopConstraint.
pframe (Frame | ConstraintNode) – The pframe of the LoopConstraint.
- oframe_raw: Annotated[Karana.Dynamics.ConstraintNode | int | Karana.Frame.Frame | Literal['vroot'] | Literal['newtonian'], BeforeValidator(serializeLoopConstraintNode), PlainSerializer(serializeLoopConstraintNode)] = None#
- pframe_raw: Annotated[Karana.Dynamics.ConstraintNode | int | Karana.Frame.Frame | Literal['vroot'] | Literal['newtonian'], BeforeValidator(serializeLoopConstraintNode), PlainSerializer(serializeLoopConstraintNode)] = None#
- property oframe: Karana.Dynamics.ConstraintNode | Karana.Frame.Frame#
Get the oframe used in the LoopConstraint’s constraint frame-to-frame.
- Returns:
The oframe used in the LoopConstraint’s constraint frame-to-frame.
- Return type:
- property pframe: Karana.Dynamics.ConstraintNode | Karana.Frame.Frame#
Get the pframe used in the LoopConstraint’s constraint frame-to-frame.
- Returns:
The pframe used in the LoopConstraint’s constraint frame-to-frame.
- Return type:
- classmethod fromLoopConstraint(lc: Karana.Dynamics.LoopConstraintBase) Self#
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:
- toCutJointConstraint(mb: Karana.Dynamics.Multibody) Karana.Dynamics.LoopConstraintBase#
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:
- class Karana.Dynamics.SOADyn_types.LoopConstraintCutJointDS(/, **data: Any)#
Bases:
LoopConstraintDSRepresents a loop constraint across a hinge.
- Parameters:
name (str) – The name of the LoopConstraintCutJoint.
hinge (PhysicalHingeParams) – The hinge information associated with the LoopConstraintCutJoint.
oframe (Frame | ConstraintNode) – The oframe of the LoopConstraint.
pframe (Frame | ConstraintNode) – The pframe of the LoopConstraint.
- loop_constraint_type: Literal['LoopConstraintCutJoint'] = 'LoopConstraintCutJoint'#
- classmethod fromLoopConstraintCutJoint(lc: Karana.Dynamics.LoopConstraintCutJoint) Self#
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:
- toCutJointConstraintCutJoint(mb: Karana.Dynamics.Multibody) Karana.Dynamics.LoopConstraintCutJoint#
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:
- class Karana.Dynamics.SOADyn_types.LoopConstraintConVelDS(/, **data: Any)#
Bases:
LoopConstraintDSRepresents a constant velocity loop constraint.
- Parameters:
name (str) – The name of the LoopConstraintConVel.
oframe (Frame | ConstraintNode) – The oframe of the LoopConstraint.
pframe (Frame | ConstraintNode) – The pframe of the LoopConstraint.
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.Math.Ktyping.Vec3, normCheck(1.0)]#
- classmethod fromLoopConstraintConVel(lc: Karana.Dynamics.LoopConstraintConVel) Self#
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:
- toCutJointConstraintConVel(mb: Karana.Dynamics.Multibody) Karana.Dynamics.LoopConstraintConVel#
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:
- class Karana.Dynamics.SOADyn_types.BodyDS(/, **data: Any)#
Bases:
Karana.KUtils.DataStruct.DataStruct,Karana.KUtils.DataStruct.IdMixin[Karana.Dynamics.PhysicalBody],Karana.KUtils.DataStruct.NestedBaseMixinA DataStruct that represents a PhysicalBody.
- Parameters:
name (str) – The name of the body.
params (PhysicalBodyParams) – The parameters for 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.
constraint_nodes (list[NodeDS] = []) – A list of constraint nodes attached to the body.
- sensor_nodes: list[pydantic.SerializeAsAny[NodeDS]] = []#
- force_nodes: list[pydantic.SerializeAsAny[NodeDS]] = []#
- constraint_nodes: list[pydantic.SerializeAsAny[NodeDS]] = []#
- classmethod fromBody(body: Karana.Dynamics.PhysicalBody) Self#
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#
Create a body from the BodyDS.
- Parameters:
parent_body (PhysicalBody) – Body to attach the new body to.
- Returns:
The new body.
- Return type:
- class Karana.Dynamics.SOADyn_types.BodyStateDS(*, name: str, grav_accel: Karana.Math.Ktyping.Acceleration[Karana.Math.Ktyping.Vec3] | Karana.Math.Ktyping.Vec3, hinge: HingeStateDS, force_node_states: list[ForceNodeStateDS] = ...)#
Bases:
Karana.KUtils.DataStruct.DataStruct,Karana.KUtils.DataStruct.NestedBaseMixinHolds state data for a body.
- Parameters:
name (str) – The name of the body.
grav_accel (Acceleration[Vec3]) – 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.
- grav_accel: Karana.Math.Ktyping.Acceleration[Karana.Math.Ktyping.Vec3]#
- hinge: HingeStateDS#
- force_node_states: list[ForceNodeStateDS] = []#
- classmethod fromBody(bd: Karana.Dynamics.PhysicalBody) Self#
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#
Set the state of the provided body.
- Parameters:
bd (PhysicalBody) – The body to set the state of.
- class Karana.Dynamics.SOADyn_types.BodyWithContextDS(/, **data: Any)#
Bases:
Karana.KUtils.DataStruct.DataStructA 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#
Create a body from the BodyWithContextDS.
- Parameters:
parent_body (PhysicalBody) – Body to attach the new body to.
- Returns:
The new body.
- Return type:
- classmethod fromBody(body: Karana.Dynamics.PhysicalBody, st: Karana.Dynamics.SubTree) Self#
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
- class Karana.Dynamics.SOADyn_types.BodyStateWithContextDS(/, **data: Any)#
Bases:
Karana.KUtils.DataStruct.DataStructA 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
- children: list[BodyStateWithContextDS] = []#
- classmethod fromBody(bd: Karana.Dynamics.PhysicalBody, st: Karana.Dynamics.SubTree) Self#
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#
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)#
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
- classmethod fromCoordinateConstraint(cc: Karana.Dynamics.CoordinateConstraint) Self#
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#
Create a CoordinateConstraint from the CoordinateConstraintDS.
- Parameters:
mbody (Multibody) – Multibody the new CoordinateConstraint will belong to
- Returns:
The CoordinateConstraint.
- Return type:
- Karana.Dynamics.SOADyn_types.SubTreeDSType#
- class Karana.Dynamics.SOADyn_types.SubTreeDS(/, **data: Any)#
Bases:
Karana.KUtils.DataStruct.DataStruct,Karana.KUtils.DataStruct.NestedBaseMixin,Karana.KUtils.DataStruct.IdMixin[SubTreeDSType],Generic[SubTreeDSType]SubTree DataStruct.
- Parameters:
name (str) – Name of the multibody.
base_bodies (list[BodyWithContextDS]) – The bodies attached to the virtual root.
- base_bodies: list[BodyWithContextDS]#
- __getstate__()#
Override __getstate__ to include _vroot_id if set.
- renameBodies(new_prefix: str, /) None#
- renameBodies(rename_fn: Callable[[str], str], /) None
Rename all the bodies in this SubTree.
See overloads for details.
- toSubTree(parent_subtree: Karana.Dynamics.SubTree, root: Karana.Dynamics.PhysicalBody) Karana.Dynamics.SubTree#
Create a new SubTree instance from this SubTreeDS.
- Parameters:
parent_subtree (SubTree) – The parent SubTree for the new SubTree instance.
root (PhysicalBody) – The root body for the new SubTree.
- Returns:
The newly created SubTree instance.
- Return type:
- classmethod fromSubTree(st: Karana.Dynamics.SubTree) Self#
Create an instance of this DataStruct from the provided SubTree.
- Parameters:
st (SubTree) – The SubTree to create a DataStruct instance for.
- Returns:
A new instance of this DataStruct.
- Return type:
Self
- toFile(file: pathlib.Path | str | IO[bytes], file_type: Literal['json', 'yaml', 'yml', 'h5', 'hdf5', 'pickle', 'pck', 'pcl'] | None = None, meta: Karana.KUtils.DataStruct.Meta | None = None) None#
- toFile(file: pathlib.Path | str, file_type: Literal['urdf'] | None = None, meta: Karana.KUtils.DataStruct.Meta | None = None) None
- toFile(g: h5py.Group, meta: Karana.KUtils.DataStruct.Meta | None = None) None
- toFile(file: pathlib.Path | str, file_type: Literal['py'] | None = None, meta: Karana.KUtils.DataStruct.Meta | None = None) None
Write the SubTreeDS to a file.
See overloads for details.
- class Karana.Dynamics.SOADyn_types.SubGraphDS#
Bases:
SubTreeDS[Karana.Dynamics.SubGraph]SubGraph 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
virtual_root_scene_part_specs (list[ScenePartSpec] = []) – ScenePartSpecs for the virtual root.
virtual_root_scene_file_obj_specs (list[SceneFileObjectSpec] = []) – SceneFileObjectSpecs for the virtual root.
- loop_constraints: list[pydantic.SerializeAsAny[LoopConstraintDS]] = []#
- constraint_frames: list[ConstraintFrameDS] = []#
- coordinate_constraints: list[CoordinateConstraintDS] = []#
- virtual_root_scene_part_specs: list[Karana.Scene.ScenePartSpec] = []#
- virtual_root_scene_file_obj_specs: list[Karana.Scene.SceneFileObjectSpec] = []#
- classmethod fromSubGraph(sg: Karana.Dynamics.SubGraph) Self#
Create a DataStruct instance from the provided SubGraph.
- Parameters:
sg (SubGraph) – The SubGraph to create a DataStruct instance for.
- Returns:
The new DataStruct instance for the provided SubGraph.
- Return type:
Self
- toSubGraph(parent_subgraph: Karana.Dynamics.SubGraph, root: Karana.Dynamics.PhysicalBody) Karana.Dynamics.SubGraph#
Create a SubGraph from this SubGraphDS.
- Parameters:
parent_subgraph (SubGraph) – The parent SubGraph to use for the new SubGraph.
root (PhysicalBody) – The PhysicalBody to use as the virtual root of the new SubGraph.
- Returns:
The new SubGraph.
- Return type:
- toMultibody(fc: Karana.Frame.FrameContainer, newtonian_frame: Karana.Frame.Frame | None = None) Karana.Dynamics.Multibody#
Create a Multibody from this SubGraphDS.
- Parameters:
fc (FrameContainer) – FrameContainer to use to create the multibody.
- Returns:
The new multibody.
- Return type:
- classmethod fromMultibody(mb: Karana.Dynamics.Multibody) Self#
Create a SubGraphDS from a Multibody.
- Parameters:
mb (Multibody) – The Multibody used to create the SubGraphDS.
- Returns:
The SubGraphDS.
- Return type:
Self
- class Karana.Dynamics.SOADyn_types.BaseDataDS(/, **data: Any)#
Bases:
Karana.KUtils.DataStruct.DataStructDataStruct 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.Math.Ktyping.Vec#
- U: Karana.Math.Ktyping.Vec#
- Udot: Karana.Math.Ktyping.Vec#
- T: Karana.Math.Ktyping.Vec#
- toCoordBase(b: Karana.Dynamics.CoordBase)#
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)#
Bases:
Karana.KUtils.DataStruct.DataStructDataStruct for CoordData.
- Parameters:
base_data (dict[str, BaseDataDS]) – Data from the BaseData.
- base_data: dict[str, BaseDataDS]#
- classmethod fromCoordData(c: Karana.Dynamics.CoordData) Self#
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#
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)#
Bases:
Karana.KUtils.DataStruct.DataStructSubTree State DataStruct.
- Parameters:
base_bodies (list[BodyStateWithContextDS]) – The state of the bodies attached to the virtual root.
- base_bodies: list[BodyStateWithContextDS]#
- renameBodies(new_prefix: str, /) None#
- renameBodies(rename_fn: Callable[[str], str], /) None
Rename all the bodies in this SubTree.
See overloads for details.
- classmethod fromSubTree(st: Karana.Dynamics.SubTree) Self#
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#
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)#
Bases:
Karana.KUtils.DataStruct.DataStructSubGraph 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#
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#
Set the state of the provided multibody.
- Parameters:
sg (SubGraph) – The multibody to set the state of.
- Karana.Dynamics.SOADyn_types.BaseKModelType#
- class Karana.Dynamics.SOADyn_types.KModelDS(/, **data: Any)#
Bases:
Karana.KUtils.DataStruct.DataStruct,Karana.KUtils.DataStruct.NestedBaseMixin,Karana.KUtils.DataStruct.IdMixin[BaseKModelType],Generic[BaseKModelType]A base class for representing a KModel as a DataStruct.
- abstract toModel(mm: Karana.Dynamics.ModelManager) Karana.Models.BaseKModel#
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:
- class Karana.Dynamics.SOADyn_types.KModelStateDS(/, **data: Any)#
Bases:
Karana.KUtils.DataStruct.DataStruct,Karana.KUtils.DataStruct.NestedBaseMixin,Karana.KUtils.DataStruct.IdMixin[BaseKModelType],Generic[BaseKModelType]A base class for representing a KModel’s state as a DataStruct.
- class Karana.Dynamics.SOADyn_types.MMOptionsDS(/, **data: Any)#
Bases:
Karana.KUtils.DataStruct.DataStructA DataStruct that represents MMOptions.
- Parameters:
- classmethod fromMMOptions(mm_opts: Karana.Dynamics.MMOptions) Self#
Create a MMOptionsDS from a MMOptions.
- Parameters:
mm_opts (MMOptions) – The MMOptions used to create the MMOptionsDS.
- Returns:
The MMOptionsDS.
- Return type:
Self
- toMMOptions() Karana.Dynamics.MMOptions#
Create a MMOptions from the MMOptionsDS.
- class Karana.Dynamics.SOADyn_types.SpOptionsDS(/, **data: Any)#
Bases:
MMOptionsDSA DataStruct that represents SpOptions.
- Parameters:
baumgarte_alpha (float) – The Baumgarte damping coefficient
baumgarte_beta (float) – The Baumgarte stiffness coefficient
max_step_size (float = 0.0) – Define the step size that advanceTo() should use to break up the overall time advancement into sub-steps. This is especially useful for fixed-step integrators to ensure that integrator steps are not too large. Also for cases where external interactions and data logging needs to be done at fixed step intervals.
update_state_derivatives_hop_end (bool = False) – If true, then update the multibody state derivatives with the integrator states at the end of each hop.
- classmethod fromSpOptions(sp_opts: Karana.Dynamics.SpOptions) Self#
Create an SpOptionsDS from a SpOptions.
- Parameters:
sp_opts (SpOptions) – The SpOptions used to create the SpOptionsDS.
- Returns:
The SpOptionsDS.
- Return type:
Self
- toSpOptions() Karana.Dynamics.SpOptions#
Create an SpOptions from the SpOptionsDS.
- class Karana.Dynamics.SOADyn_types.StatePropagatorDS(/, **data: Any)#
Bases:
Karana.KUtils.DataStruct.DataStruct,Karana.KUtils.DataStruct.IdMixin[Karana.Dynamics.StatePropagator]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.
state_propagator_options (Optional[SpOptionsDS] = None) – Options for the StatePropagator.
models (list[KModelDS]) – The models registered with the StatePropagator.
- integrator_type: Karana.Integrators.IntegratorType#
- integrator_options: pydantic.SerializeAsAny[Karana.Integrators.Integrator_types.IntegratorOptionsDS] | None = None#
- solver_type: Karana.Dynamics.MMSolverType#
- state_propagator_options: SpOptionsDS | None = None#
- models: list[pydantic.SerializeAsAny[KModelDS]]#
- classmethod fromStatePropagator(sp: Karana.Dynamics.StatePropagator) Self#
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#
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:
- toStatePropagator(st: Karana.Dynamics.SubTree) Karana.Dynamics.StatePropagator#
Create a StatePropagator from the StatePropagatorDS.
- Parameters:
st (SubTree) – The SubTree to associate with the StatePropagator.
- toFile(file: pathlib.Path | str | IO[bytes], file_type: Literal['json', 'yaml', 'yml', 'h5', 'hdf5', 'pickle', 'pck', 'pcl'] | None = None, meta: Karana.KUtils.DataStruct.Meta | None = None) None#
- toFile(g: h5py.Group, meta: Karana.KUtils.DataStruct.Meta | None = None) None
- toFile(file: pathlib.Path | str, file_type: Literal['py'] | None = None, meta: Karana.KUtils.DataStruct.Meta | None = None) None
Write the SubTreeDS to a file.
See overloads for details.
- class Karana.Dynamics.SOADyn_types.GraphicsSetupDS(/, **data: Any)#
Bases:
Karana.KUtils.DataStruct.DataStructA DataStruct used to capture information needed to setup graphics.
- Parameters:
port (int) – Port to bind the WebUI server to. Use 0 to request an arbitrary unused port.
axes (float) – Length of axes visualization on root frame.
client_type (Literal["auto", "electron", "notebook", "webbrowser", "selenium"] | None) –
- Policy for launching a client.
”auto”: pick the best option for the environment and OS “electron”: always launch the electron client “notebook”: always open an IFrame in IPython “webbrowser”: always open a browser tab “selenium”: always open a chrome driver using selenium None: don’t automatically open a client
origin_frame (Optional[Frame]) – Frame to use as the world origin for the graphics scene. If None, use the Multibody’s virtualRoot.
wait_for_clients (int) – Number of client connections to wait for before continuing.
wait_for_clients_timeout (float) – Number of seconds to wait before raising an error if wait_for_clients is positive.
stick_parts (Literal["auto", "always", "never"] = "auto") –
- Policy for creating stick parts. Defaults to “auto”.
”auto”: create stick parts if the ProxyScene is empty “always”: unconditionally create stick parts “never”: unconditionally don’t create stick parts
proxy_scene_id (int | None = None) – Integer to associate with proxy_scene after setting up graphics. This value is only used for DataStruct-based bookkeeping, and should not be set directly.
graphics_type (Literal["graphics"] = "graphics") – Discriminator used by pydantic.
- origin_frame: Karana.Frame.Frame | None = None#
- stick_parts: Literal['auto', 'always', 'never'] = 'auto'#
- graphics_type: Literal['graphics'] = 'graphics'#
- setupGraphics(mb: Karana.Dynamics.Multibody) tuple[Callable[[], None], Karana.Scene.WebScene]#
Set up graphics.
- class Karana.Dynamics.SOADyn_types.GuiSetupDS(/, **data: Any)#
Bases:
Karana.KUtils.DataStruct.DataStructStore setup information for the GUI.
- Parameters:
port (int) – Port to bind the WebUI server to. Use 0 to request an arbitrary unused port. Defaults to 29534.
client_type (Literal["auto", "electron", "notebook", "webbrowser", "selenium"] | None) –
- Policy for launching a client.
”auto”: pick the best option for the environment and OS “electron”: always launch the electron client “notebook”: always open an IFrame in IPython “webbrowser”: always open a browser tab “selenium”: always open a chrome driver using selenium None: don’t automatically open a client
Defaults to “auto”.
wait_for_clients (int) – Number of client connections to wait for before continuing. Defaults to 0.
wait_for_clients_timeout (float) – Number of seconds to wait before raising an error if wait_for_clients is positive. Defaults to 0.
graphics_origin_frame (Optional[Frame]) – If given, and the GUI needs to setup graphics, use this as the origin frame instead of the multibody virtual root.
stick_parts (Literal["auto", "always", "never"] = "auto") –
- Policy for creating stick parts. Defaults to “auto”.
”auto”: create stick parts if the ProxyScene is empty “always”: unconditionally create stick parts “never”: unconditionally don’t create stick parts
stick_parts_config (StickPartsConfig | None) – Configuration parameters for the stick parts.
name_to_label_map (dict[str, str] | None) – Dictionary defining the labels to use for each body in the visjs graphs display
sp (StatePropagator | None) – The state propagator to use if available.
time_display_period (float | None) – If not None and sp is given, add a time display refreshing with this period in simulation time. Defaults to 0.01.
graphics_type (Literal["gui"] = "gui") – Discriminator used by pydantic.
- stick_parts: Literal['auto', 'always', 'never'] = 'auto'#
- stick_parts_config: Karana.Dynamics.StickPartsConfig | None = None#
- sp_raw: Annotated[Karana.Dynamics.StatePropagator | int | None, *SerializeAsId(allow_int=True, allow_None=True)] = None#
- graphics_origin_frame: Karana.Frame.Frame | None = None#
- graphics_type: Literal['gui'] = 'gui'#
- property sp: Karana.Dynamics.StatePropagator | None#
Return the StatePropagator.
- Returns:
The StatePropagator if set. Otherwise, returns None.
- Return type:
StatePropagator | None
- setupGui(mb: Karana.Dynamics.Multibody, sim: Sim | None, setup_graphics_first: Literal[False] = False) Karana.KUtils.MultibodyWebUI.MultibodyWebUI#
- setupGui(mb: Karana.Dynamics.Multibody, sim: Sim | None, setup_graphics_first: Literal[True]) tuple[Karana.KUtils.MultibodyWebUI.MultibodyWebUI, Callable[[], None], Karana.Scene.WebScene]
Set up the GUI.
- Parameters:
- Return type:
The return depends on the arguments supplied. See overloads for details.
- setupGraphicsOnly(mb: Karana.Dynamics.Multibody, no_client: bool, print_connection_info: bool) tuple[Callable[[], None], Karana.Scene.WebScene]#
Set up the graphics only.
This will disregard the port and use port 0.
- Parameters:
- Returns:
A tuple containing the a cleanup callable and the graphics scene.
- Return type: