Karana.Models#
General models used in a variety of simulations.
Submodules#
Attributes#
Classes#
BaseClass for the model parameters of Python models. |
|
Class indicating there are no model params. |
|
Class indicating there is no model scratch. |
|
Class indicating there are no model discrete states. |
|
Class indicating there are no model continuous states. |
|
Base class for all Python models. |
|
@class BaseKModel This BaseKModel serves as the base for all models. |
|
@class KModelContinuousStates A base class for continuous model |
|
@class KModelDiscreteStates A base class for discrete model states. |
|
@class KModelContinuousStates A base class for continuous model |
|
@class KModelDiscreteStates A base class for discrete model states. |
|
@class KModelScratch A scratchpad to store model information. This is |
|
KModel<T,P,Sc,S,C> uses the curiously recurring template pattern |
|
@class ComputedTorque Limits the generalized force that can be applied |
|
@class DataLogger The DataLogger model updates the visualization at |
|
@class DataLoggerParams Parameters for the DataLogger model. |
|
@class GraphicalSceneMovie The GraphicalSceneMovie model updates the |
|
@class GraphicalSceneMovieParams Parameters for the |
|
@class PID Simple PID controller model. |
|
@class PIDParams Parameters for the PID model. |
|
@class PinJointLimits Model that adds joint limits to a pin hinge. |
|
@class PinJointLimitsParams Parameters for the PinJointLimits model. |
|
@class PointMassGravity Model to compute and apply uniform gravity |
|
@class PointMassGravityParams Parameters for the PointMassGravity |
|
@class ProjectConstraintError The ProjectConstraintError model updates |
|
@class ProjectConstraintErrorParams Parameters for the |
|
@class SpringDamper Adds a spring-damper between two nodes. |
|
@class SpringDamperParams Parameters for the SpringDamper model. |
|
@class SpringDamperScratch Scratch variables for the SpringDamper |
|
@class SubhingeForceLimits Limits the generalized force that can be |
|
@class SubhingeForceLimitsParams Paramters for the SubhingeForceLimits |
|
@class SubhingeSpringDamper Adds a spring damper to the provided |
|
@class SubhingeSpringDamperParams Parameters for the |
|
@class SyncRealTime Limits sim speed to a multiple of real time. |
|
@class TimeDisplay The TimeDisplay model updates the visualization at |
|
@class TimeDisplayParams Parameters for the TimeDisplay KModel. |
|
@class UniformGravity Apply uniform gravitational acceleration to each |
|
@class UniformGravityParams Parameters for the UniformGravity class. |
|
@class UpdateProxyScene The UpdateProxyScene model updates the |
|
DataPlotter model. |
|
@class PenaltyContact Model applying penalty contact forces to |
|
Package Contents#
- class Karana.Models.KModelParams(/, **data: Any)#
Bases:
Karana.KUtils.DataStruct.DataStructBaseClass for the model parameters of Python models.
For a new model parameter class, simply derive from this class and add class variables just like you would do for any other DataStruct. Users should override the isFinalized if applicable to ensure that all model parameters have been defined.
- dumpString(prefix: str, options: Karana.Core.DumpOptionsBase | None = None) str[source]#
Dump the parameters as a string.
- Parameters:
prefix (str) – The prefix for the string.
options (_DumpOptionsBase | None) – Options for the string.
- Returns:
The parameters as a string.
- Return type:
str
- class Karana.Models.NoParams(/, **data: Any)#
Bases:
KModelParamsClass indicating there are no model params.
- class Karana.Models.NoScratch#
Bases:
KModelScratchClass indicating there is no model scratch.
- class Karana.Models.NoDiscreteStates#
Bases:
KModelDiscreteStatesClass indicating there are no model discrete states.
- class Karana.Models.NoContinuousStates#
Bases:
KModelContinuousStatesClass indicating there are no model continuous states.
- Karana.Models.P#
- Karana.Models.Sc#
- Karana.Models.S#
- Karana.Models.C#
- class Karana.Models.KModel(name: str, sp: Karana.Dynamics.StatePropagator)#
Bases:
Generic[P,Sc,S,C],PyKModelBaseBase class for all Python models.
This is the base class for all Python models. To create a new model, simply create a class that derives from this one.
If the model has parameters, then create a parameter class that derives from KModelParams. In addition, add
` params: MyDerivedParamClass `as a class variable to ensure type-hinting works as intended.
Users can override the pre/postDeriv, pre/postHop, and pre/PostModelStep to run model functions at various points throught the dynamics. For details on these methods and models, see the model documentation.
- params: P#
- scratch: Sc#
- discrete_states: S#
- continuous_states: C#
- typeString() str[source]#
Return the type string (class name) of the KModel.
- Returns:
The class name of the KModel.
- Return type:
str
- dumpString(prefix: str = '', options: Karana.Core.DumpOptionsBase | None = None) str[source]#
Return information about the KModel as a string.
- Parameters:
prefix (str) – A string to use as prefix for each output line.
options (_DumpOptionsBase | None) – Class with options to tailor the output
- Returns:
Information about the KModel as a string.
- Return type:
str
- class Karana.Models.BaseKModel#
Bases:
Karana.Core.LockingBase@class BaseKModel This BaseKModel serves as the base for all models. It implements common logic, methods, etc. for both C++ and Python models. Determining which methods have been overloaded is handled by the KModel classes. In C++ this is uses the curiuosly-recurring template pattern (CRTP) and in Python we use object attributes. See the KModel component models section for more discussion about the KModel class.
- debug_model: bool#
- state_propagator: Karana.Dynamics.StatePropagator#
- stdDebugMsg(msg: str) None#
Print a standard debug message.
This creates json with debug information and passes it to the debug logger.
- Parameter
msg: The message to log.
- Parameter
- class Karana.Models.CppKModelContinuousStates#
Bases:
Karana.Core.Base@class KModelContinuousStates A base class for continuous model states. Derive from this and add any continuous states for your model.
Override the isFinalized method to check whether the continuous states are set. Override the setX and getX to set and get the model continuous states. Whenever the number of continuous states changes (the length of the vector from getX changes), you MUST re-register the model. Neglecting to do so leads to undefined behavior. See the Continuous states section for more discussion about the KModel class.
- getX() Annotated[numpy.typing.NDArray[numpy.float64], [m, 1]]#
Get the continous model states.
- Returns:
The continuous model states.
- getdX() Annotated[numpy.typing.NDArray[numpy.float64], [m, 1]]#
Get the deriviative of the continous model states.
- Returns:
The continuous model states’ derivatives.
- setX(x: Annotated[numpy.typing.NDArray[numpy.float64], [m, 1]]) None#
Set the continous model states.
- Parameter
x: The new continuous model states.
- Parameter
- class Karana.Models.CppKModelDiscreteStates(name: str)#
Bases:
Karana.Core.Base@class KModelDiscreteStates A base class for discrete model states. Derive from this and add any parameters for your model. Override the isFinalized method to check whether the discrete states are set. See the Discrete states section for more discussion about the KModel class.
- class Karana.Models.CppKModelScratch(name: str)#
Bases:
Karana.Core.Base
- class Karana.Models.KModelContinuousStates(name: str)#
Bases:
CppKModelContinuousStates@class KModelContinuousStates A base class for continuous model states. Derive from this and add any continuous states for your model.
Override the isFinalized method to check whether the continuous states are set. Override the setX and getX to set and get the model continuous states. Whenever the number of continuous states changes (the length of the vector from getX changes), you MUST re-register the model. Neglecting to do so leads to undefined behavior. See the Continuous states section for more discussion about the KModel class.
- class Karana.Models.KModelDiscreteStates(name: str)#
Bases:
CppKModelDiscreteStates@class KModelDiscreteStates A base class for discrete model states. Derive from this and add any parameters for your model. Override the isFinalized method to check whether the discrete states are set. See the Discrete states section for more discussion about the KModel class.
- class Karana.Models.KModelScratch(name: str)#
Bases:
CppKModelScratch@class KModelScratch A scratchpad to store model information. This is primarily used for debugging purposes. See the Model scratch section for more discussion about the KModel class.
- class Karana.Models.PyKModelBase(name: str, sp: Karana.Dynamics.StatePropagator)#
Bases:
BaseKModelKModel<T,P,Sc,S,C> uses the curiously recurring template pattern (CRTP) to determine what methods the derived class has, and make the appropriate calls. All C++ models should derive from this. Python models will have a different class to derive from. See the KModel component models section for more discussion about the KModel class.
- debug_model: bool#
- state_propagator: Karana.Dynamics.StatePropagator#
- dumpString(prefix: str, options: Karana.Core.DumpOptionsBase = None) str#
Return a string with the current model information.
- Parameters:
prefix (str) – The prefix to use in front of each line in the dump string.
options (BaseDumpOptions) – The options used to create the dump string.
- Returns:
A string representing the current model information.
- Return type:
str
- getPeriod() numpy.timedelta64#
If a nextModelStepTime method exists, then this returns a warning. A model period and nextModelStepTime cannot both be defined for a model.
- Returns:
The model’s period.
- nextModelStepTime(t: float | numpy.timedelta64) numpy.timedelta64 | None#
- The model_period defines the period at which the model runs. There are a few cases to consider:
The period is 0 and no nextStepEndTime method is defined. In this case, the pre/postModelStep methods will run every time a simulation hop happens.
The period is non-zero. In this case, the pre/postModelStep methods will run at the specified period.
The period is 0 and a nextStepEndTime method is defined. In this case, the nextStepEndTime defines when these methods will run.
- Parameters:
t (KTime) – The current time.
- Returns:
The next time this model should run.
- Return type:
KTime
- postDeriv(t: float | numpy.timedelta64, x: Annotated[numpy.typing.ArrayLike, numpy.float64, [m, 1]]) None#
The postDeriv method runs after the multibody derivative.
- postHop(t: float | numpy.timedelta64, x: Annotated[numpy.typing.ArrayLike, numpy.float64, [m, 1]]) None#
The postHop runs after each simulation hop.
- postModelStep(t: float | numpy.timedelta64, x: Annotated[numpy.typing.ArrayLike, numpy.float64, [m, 1]]) None#
The postModelStep runs after the model’s step. See nextStepEndTime for information on when this happens.
- preDeriv(t: float | numpy.timedelta64, x: Annotated[numpy.typing.ArrayLike, numpy.float64, [m, 1]]) None#
The preDeriv method runs before the multibody derivative.
- preHop(t: float | numpy.timedelta64, x: Annotated[numpy.typing.ArrayLike, numpy.float64, [m, 1]]) None#
The preHop runs before each simulation hop.
- preModelStep(t: float | numpy.timedelta64, x: Annotated[numpy.typing.ArrayLike, numpy.float64, [m, 1]]) None#
The preModelStep runs before the model’s step. See nextStepEndTime for information on when this happens.
- setPeriod(arg0: float | numpy.timedelta64) None#
The model_period defines the period at which the model runs. There are a few cases to consider: 1. The period is 0 and no nextModelStepTime method is defined. In this case, the begin/postModelStep methods will run every time a simulation hop happens. 2. The period is non-zero. In this case, the begin/postModelStep methods will run at the specified period. 3. The period is 0 and a nextModelStepTime method is defined. In this case, the nextModelStepTime defines when these methods will run. A model period and nextModelStepTime cannot both be defined for a model. If one tries to set a model period for a model which has a nextModelStepTime, then an error will be thrown.
- Parameter
t: The new model period.
- Parameter
- class Karana.Models.ComputedTorque(name: str, sp: Karana.Dynamics.StatePropagator, st: Karana.Dynamics.SubTree, set_accels_fn: collections.abc.Callable[[float | numpy.timedelta64, Annotated[numpy.typing.ArrayLike, numpy.float64, [m, 1]]], None])#
Bases:
ComputedTorqueKModel@class ComputedTorque Limits the generalized force that can be applied to a subhinge.
- static create(name: str, sp: Karana.Dynamics.StatePropagator, st: Karana.Dynamics.SubTree, set_accels_fn: collections.abc.Callable[[float | numpy.timedelta64, Annotated[numpy.typing.ArrayLike, numpy.float64, [m, 1]]], None]) ComputedTorque#
Constructor.
The user-supplied set_accels_fn should set the accelerations on the provided SubGraph. Then, the model uses Algorithms.evalComputedTorque to calculate the corresponding torques and apply them to the SubTree.
- Parameter
name: The name of the model.
- Parameter
sp: The StatePropagator to register this model with.
- Parameter
st: The SubTree to apply the torques to.
- Parameter
set_accels_fn: The function that sets the accelerations for the computed torque to compute torques for.
- Returns:
A ks_ptr to the newly created instance of the ComputedTorque model.
- Parameter
- preDeriv(t: float | numpy.timedelta64, x: Annotated[numpy.typing.ArrayLike, numpy.float64, [m, 1]]) None#
Calculate and apply the torques.
- Parameter
t: Current time. This is passed to the user-supplied set_accels_fn.
- Parameter
x: Current state. This is passed to the user-supplied set_accels_fn.
- Parameter
- class Karana.Models.ComputedTorqueKModel#
Bases:
Karana.Models.BaseKModel- debug_model: bool#
- state_propagator: Karana.Dynamics.StatePropagator#
- getNextModelStepTime(t: float | numpy.timedelta64) numpy.timedelta64 | None#
Get the next step time assuming the provided time t is a time the model has a step at.
- Parameters:
t (Ktime) – A time the model has a step at.
- Returns:
The next model step time.
- Return type:
Ktime
- getPeriod() numpy.timedelta64#
Get the period of the model.
If a nextModelStepTime method exists, this returns a warning. A model period and nextModelStepTime cannot both be defined for a model.
- Returns:
The model’s period.
- Return type:
Ktime
- isFinalized() bool#
Checks whether the model is finalized.
- Returns:
Returns false if the params pointer is emtpy or if the parameters are not finalize. Returns true otherwise.
- Return type:
bool
- setPeriod(t: float | numpy.timedelta64) None#
Set the model period.
The model period defines the period at which the model runs. There are a few cases to consider:
The period is 0 and no nextModelStepTime method is defined. In this case, the preModelStep/postModelStep methods will run every time a simulation hop happens.
The period is non-zero. In this case, those methods will run at the specified period.
The period is 0 and a nextModelStepTime method is defined. Then, that method defines when the steps will run.
A model period and nextModelStepTime cannot both be defined for a model. An error will be thrown if a model with nextModelStepTime has its period set.
- Parameters:
t (Ktime) – The new model period.
- class Karana.Models.DataLogger(name: str, sp: Karana.Dynamics.StatePropagator, h5_writer: Karana.KUtils.H5Writer)#
Bases:
DataLoggerKModel@class DataLogger The DataLogger model updates the visualization at each postHop.
- static create(name: str, sp: Karana.Dynamics.StatePropagator, h5_writer: Karana.KUtils.H5Writer) DataLogger#
Constructor.
- Parameter
name: The name of the DataLogger model.
- Parameter
sp: The StatePropagator to register this model with.
- Parameter
h5_writer: The H5Writer to use for logging.
- Returns:
A ks_ptr to the newly created instance of the DataLogger model.
- Parameter
- getH5Writer() Karana.KUtils.H5Writer#
Get the H5Writer used by the model.
This can be used to enable/disable various tables of the H5Writer.
- Returns:
The H5Write that this model uses for logging.
- postModelStep(t: float | numpy.timedelta64, x: Annotated[numpy.typing.ArrayLike, numpy.float64, [m, 1]]) None#
Perform data logging.
- Parameter
t: Current time. Not used.
- Parameter
x: Current state. Not used.
- Parameter
- class Karana.Models.DataLoggerKModel#
Bases:
Karana.Models.BaseKModel- debug_model: bool#
- params: DataLoggerParams#
- state_propagator: Karana.Dynamics.StatePropagator#
- getNextModelStepTime(t: float | numpy.timedelta64) numpy.timedelta64 | None#
Get the next step time assuming the provided time t is a time the model has a step at.
- Parameters:
t (Ktime) – A time the model has a step at.
- Returns:
The next model step time.
- Return type:
Ktime
- getPeriod() numpy.timedelta64#
Get the period of the model.
If a nextModelStepTime method exists, this returns a warning. A model period and nextModelStepTime cannot both be defined for a model.
- Returns:
The model’s period.
- Return type:
Ktime
- isFinalized() bool#
Checks whether the model is finalized.
- Returns:
Returns false if the params pointer is emtpy or if the parameters are not finalize. Returns true otherwise.
- Return type:
bool
- setPeriod(t: float | numpy.timedelta64) None#
Set the model period.
The model period defines the period at which the model runs. There are a few cases to consider:
The period is 0 and no nextModelStepTime method is defined. In this case, the preModelStep/postModelStep methods will run every time a simulation hop happens.
The period is non-zero. In this case, those methods will run at the specified period.
The period is 0 and a nextModelStepTime method is defined. Then, that method defines when the steps will run.
A model period and nextModelStepTime cannot both be defined for a model. An error will be thrown if a model with nextModelStepTime has its period set.
- Parameters:
t (Ktime) – The new model period.
- class Karana.Models.DataLoggerParams#
@class DataLoggerParams Parameters for the DataLogger model.
- isFinalized() bool#
Used to ensure the params are finalized.
- Returns:
true if the params are finalized, `false otherwise.
- property log_first_step: bool#
If true, then log the first step.
- class Karana.Models.GraphicalSceneMovie(name: str, sp: Karana.Dynamics.StatePropagator, scene: Karana.Scene.ProxyScene)#
Bases:
GraphicalSceneMovieKModel@class GraphicalSceneMovie The GraphicalSceneMovie model updates the visualization at each postHop.
- static create(name: str, sp: Karana.Dynamics.StatePropagator, scene: Karana.Scene.ProxyScene) GraphicalSceneMovie#
Constructor.
- Parameter
name: The name of the GraphicalSceneMovie model.
- Parameter
sp: The StatePropagator to register this model with.
- Parameter
scene: The ProxyScene whose graphics() scene’s frames will be rendered to create a movie.
- Returns:
A ks_ptr to the newly created instance of the GraphicalSceneMovie model.
- Parameter
- getFfmpegCommand() str#
Get the ffmpeg command you should run to turn the images into a movie.
- Returns:
The ffmpeg command you should run to turn the images into a movie as a string.
- postModelStep(t: float | numpy.timedelta64, x: Annotated[numpy.typing.ArrayLike, numpy.float64, [m, 1]]) None#
Update the GraphicalScene.
- Parameter
t: Current time. Not used.
- Parameter
x: Current state. Not used.
- Parameter
- class Karana.Models.GraphicalSceneMovieKModel#
Bases:
Karana.Models.BaseKModel- debug_model: bool#
- params: GraphicalSceneMovieParams#
- state_propagator: Karana.Dynamics.StatePropagator#
- getNextModelStepTime(t: float | numpy.timedelta64) numpy.timedelta64 | None#
Get the next step time assuming the provided time t is a time the model has a step at.
- Parameters:
t (Ktime) – A time the model has a step at.
- Returns:
The next model step time.
- Return type:
Ktime
- getPeriod() numpy.timedelta64#
Get the period of the model.
If a nextModelStepTime method exists, this returns a warning. A model period and nextModelStepTime cannot both be defined for a model.
- Returns:
The model’s period.
- Return type:
Ktime
- isFinalized() bool#
Checks whether the model is finalized.
- Returns:
Returns false if the params pointer is emtpy or if the parameters are not finalize. Returns true otherwise.
- Return type:
bool
- setPeriod(t: float | numpy.timedelta64) None#
Set the model period.
The model period defines the period at which the model runs. There are a few cases to consider:
The period is 0 and no nextModelStepTime method is defined. In this case, the preModelStep/postModelStep methods will run every time a simulation hop happens.
The period is non-zero. In this case, those methods will run at the specified period.
The period is 0 and a nextModelStepTime method is defined. Then, that method defines when the steps will run.
A model period and nextModelStepTime cannot both be defined for a model. An error will be thrown if a model with nextModelStepTime has its period set.
- Parameters:
t (Ktime) – The new model period.
- class Karana.Models.GraphicalSceneMovieParams#
@class GraphicalSceneMovieParams Parameters for the GraphicalSceneMovie model.
- isFinalized() bool#
Used to ensure the params are finalized.
- Returns:
true if the params are finalized, `false otherwise.
- property dir: str#
Directory where the renders will be saved.
- property filename_prefix: str#
Filename prefix for each individual file
- class Karana.Models.PID(name: str, sp: Karana.Dynamics.StatePropagator, sh: Karana.Dynamics.PhysicalSubhinge, q_traj: collections.abc.Callable[[float | numpy.timedelta64], Annotated[numpy.typing.NDArray[numpy.float64], [m, 1]]], u_traj: collections.abc.Callable[[float | numpy.timedelta64], Annotated[numpy.typing.NDArray[numpy.float64], [m, 1]]])#
Bases:
PIDKModel@class PID Simple PID controller model.
- static create(name: str, sp: Karana.Dynamics.StatePropagator, sh: Karana.Dynamics.PhysicalSubhinge, q_traj: collections.abc.Callable[[float | numpy.timedelta64], Annotated[numpy.typing.NDArray[numpy.float64], [m, 1]]], u_traj: collections.abc.Callable[[float | numpy.timedelta64], Annotated[numpy.typing.NDArray[numpy.float64], [m, 1]]]) PID#
Constructor. The PID model adds force to a subhinge. The model uses the incoming function as the desired trajectory. The output of this function should be the desired Q values of the subhinge.
- Parameter
name: The name of the model.
- Parameter
sp: The StatePropagator to register this model with.
- Parameter
sh: The Subhinge to apply the forces calculated by the PID controller to.
- Parameter
q_traj: A function that defines the reference trajectory for Q.
- Parameter
u_traj: A function that defines the reference trajectory for U.
- Returns:
A ks_ptr to the newly created instance of the PID model.
- Parameter
- preDeriv(t: float | numpy.timedelta64, x: Annotated[numpy.typing.ArrayLike, numpy.float64, [m, 1]]) None#
Calculate and apply the output of the PID model to the subhinge.
- Parameter
t: Current time.
- Parameter
x: Current state. Not used.
- Parameter
- preModelStep(t: float | numpy.timedelta64, x: Annotated[numpy.typing.ArrayLike, numpy.float64, [m, 1]]) None#
Calculate the contribution of integral control.
- Parameter
t: Current time.
- Parameter
x: Current state. Not used.
- Parameter
- class Karana.Models.PIDKModel#
Bases:
Karana.Models.BaseKModel- debug_model: bool#
- state_propagator: Karana.Dynamics.StatePropagator#
- getNextModelStepTime(t: float | numpy.timedelta64) numpy.timedelta64 | None#
Get the next step time assuming the provided time t is a time the model has a step at.
- Parameters:
t (Ktime) – A time the model has a step at.
- Returns:
The next model step time.
- Return type:
Ktime
- getPeriod() numpy.timedelta64#
Get the period of the model.
If a nextModelStepTime method exists, this returns a warning. A model period and nextModelStepTime cannot both be defined for a model.
- Returns:
The model’s period.
- Return type:
Ktime
- isFinalized() bool#
Checks whether the model is finalized.
- Returns:
Returns false if the params pointer is emtpy or if the parameters are not finalize. Returns true otherwise.
- Return type:
bool
- setPeriod(t: float | numpy.timedelta64) None#
Set the model period.
The model period defines the period at which the model runs. There are a few cases to consider:
The period is 0 and no nextModelStepTime method is defined. In this case, the preModelStep/postModelStep methods will run every time a simulation hop happens.
The period is non-zero. In this case, those methods will run at the specified period.
The period is 0 and a nextModelStepTime method is defined. Then, that method defines when the steps will run.
A model period and nextModelStepTime cannot both be defined for a model. An error will be thrown if a model with nextModelStepTime has its period set.
- Parameters:
t (Ktime) – The new model period.
- class Karana.Models.PIDParams#
@class PIDParams Parameters for the PID model.
- isFinalized() bool#
Used to ensure the params are finalized.
- Returns:
true if the params are finalized, `false otherwise.
- property kd: float#
Derivative gain
- property ki: float#
Integral gain
- property kp: float#
Proportional gain
- class Karana.Models.PinJointLimits(name: str, sp: Karana.Dynamics.StatePropagator, pin: Karana.Dynamics.PinSubhinge)#
Bases:
PinJointLimitsKModel@class PinJointLimits Model that adds joint limits to a pin hinge.
- static create(name: str, sp: Karana.Dynamics.StatePropagator, pin: Karana.Dynamics.PinSubhinge) PinJointLimits#
Constructor.
- Parameter
name: The name of the model.
- Parameter
sp: The StatePropagator to register this model with.
- Parameter
pin: The pin subhinge to apply joint limits to.
- Returns:
A ks_ptr to the newly created instance of the PinJointLimits model.
- Parameter
- preDeriv(t: float | numpy.timedelta64, x: Annotated[numpy.typing.ArrayLike, numpy.float64, [m, 1]]) None#
Calculate and apply the restoring force to mimic joint limits.
- Parameter
t: Current time. Not used.
- Parameter
x: Current state. Not used.
- Parameter
- class Karana.Models.PinJointLimitsKModel#
Bases:
Karana.Models.BaseKModel- debug_model: bool#
- params: PinJointLimitsParams#
- state_propagator: Karana.Dynamics.StatePropagator#
- getNextModelStepTime(t: float | numpy.timedelta64) numpy.timedelta64 | None#
Get the next step time assuming the provided time t is a time the model has a step at.
- Parameters:
t (Ktime) – A time the model has a step at.
- Returns:
The next model step time.
- Return type:
Ktime
- getPeriod() numpy.timedelta64#
Get the period of the model.
If a nextModelStepTime method exists, this returns a warning. A model period and nextModelStepTime cannot both be defined for a model.
- Returns:
The model’s period.
- Return type:
Ktime
- isFinalized() bool#
Checks whether the model is finalized.
- Returns:
Returns false if the params pointer is emtpy or if the parameters are not finalize. Returns true otherwise.
- Return type:
bool
- setPeriod(t: float | numpy.timedelta64) None#
Set the model period.
The model period defines the period at which the model runs. There are a few cases to consider:
The period is 0 and no nextModelStepTime method is defined. In this case, the preModelStep/postModelStep methods will run every time a simulation hop happens.
The period is non-zero. In this case, those methods will run at the specified period.
The period is 0 and a nextModelStepTime method is defined. Then, that method defines when the steps will run.
A model period and nextModelStepTime cannot both be defined for a model. An error will be thrown if a model with nextModelStepTime has its period set.
- Parameters:
t (Ktime) – The new model period.
- class Karana.Models.PinJointLimitsParams#
@class PinJointLimitsParams Parameters for the PinJointLimits model.
- isFinalized() bool#
Used to ensure the params are finalized.
- Returns:
true if the params are finalized, `false otherwise.
- property d: float#
Damping constant for the restoring force
- property k: float#
Spring constant for the restoring force
- property lower_limit: float#
Pin joint lower limit
- property upper_limit: float#
Pin joint upper limit
- class Karana.Models.PointMassGravity(name: str, sp: Karana.Dynamics.StatePropagator, st: Karana.Dynamics.SubTree, central_body: Karana.Frame.Frame)#
Bases:
PointMassGravityKModel@class PointMassGravity Model to compute and apply uniform gravity accelearation from a point mass central body to all the bodies in the multibody system.
- static create(name: str, sp: Karana.Dynamics.StatePropagator, st: Karana.Dynamics.SubTree, central_body: Karana.Frame.Frame) PointMassGravity#
Constructor.
- Parameter
name: The name of the model.
- Parameter
sp: The StatePropagator to register this model with.
- Parameter
st: The SubTree to apply gravity to.
- Parameter
central_body: The point mass central body applying the gravitational force
- Returns:
A ks_ptr to the newly created instance of the PointMassGravity model.
- Parameter
- getObjIds() list[int]#
Get node IDs for DataStruct.
This method retrieves the IDs of the multibody and central body. This is designed primarily for use with the PointMassGravityDS DataStruct.
- Returns:
mbody and central body IDs.
- preDeriv(t: float | numpy.timedelta64, x: Annotated[numpy.typing.ArrayLike, numpy.float64, [m, 1]]) None#
Calculate and apply the aerodynamic force.
- Parameter
t: Current time. Not used.
- Parameter
x: Current state. Not used.
- Parameter
- class Karana.Models.PointMassGravityKModel#
Bases:
Karana.Models.BaseKModel- debug_model: bool#
- params: PointMassGravityParams#
- state_propagator: Karana.Dynamics.StatePropagator#
- getNextModelStepTime(t: float | numpy.timedelta64) numpy.timedelta64 | None#
Get the next step time assuming the provided time t is a time the model has a step at.
- Parameters:
t (Ktime) – A time the model has a step at.
- Returns:
The next model step time.
- Return type:
Ktime
- getPeriod() numpy.timedelta64#
Get the period of the model.
If a nextModelStepTime method exists, this returns a warning. A model period and nextModelStepTime cannot both be defined for a model.
- Returns:
The model’s period.
- Return type:
Ktime
- isFinalized() bool#
Checks whether the model is finalized.
- Returns:
Returns false if the params pointer is emtpy or if the parameters are not finalize. Returns true otherwise.
- Return type:
bool
- setPeriod(t: float | numpy.timedelta64) None#
Set the model period.
The model period defines the period at which the model runs. There are a few cases to consider:
The period is 0 and no nextModelStepTime method is defined. In this case, the preModelStep/postModelStep methods will run every time a simulation hop happens.
The period is non-zero. In this case, those methods will run at the specified period.
The period is 0 and a nextModelStepTime method is defined. Then, that method defines when the steps will run.
A model period and nextModelStepTime cannot both be defined for a model. An error will be thrown if a model with nextModelStepTime has its period set.
- Parameters:
t (Ktime) – The new model period.
- toDS() Karana.Models.GeneralKModels_types.PointMassGravityDS#
Create a PointMassGravityDS from this PointMassGravity model.
- Returns:
PointMassGravityDS
A PointMassGravityDS instance with values set to match this model.
- class Karana.Models.PointMassGravityParams#
@class PointMassGravityParams Parameters for the PointMassGravity model.
- isFinalized() bool#
Used to ensure the params are finalized.
- Returns:
true if the params are finalized, `false otherwise.
- property mu: float#
m^3/(kg s^2) )
- Type:
Gravitational constant (units
- class Karana.Models.ProjectConstraintError(name: str, sp: Karana.Dynamics.StatePropagator, sg: Karana.Dynamics.SubGraph, integrator: Karana.Math.Integrator, cks: Karana.Dynamics.ConstraintKinematicsSolver)#
Bases:
ProjectConstraintErrorKModel@class ProjectConstraintError The ProjectConstraintError model updates the visualization at each postHop.
- static create(name: str, sp: Karana.Dynamics.StatePropagator, sg: Karana.Dynamics.SubGraph, integrator: Karana.Math.Integrator, cks: Karana.Dynamics.ConstraintKinematicsSolver) ProjectConstraintError#
Constructor.
- Parameter
name: The name of the ProjectConstraintError model.
- Parameter
sp: The StatePropagator to register this model with.
- Parameter
sg: The SubGraph whose coordinates will be projected.
- Parameter
cks: The ConstraintKinematicsSolver used to do the projection.
- Parameter
integrator: The integrator to soft-reset when doing a projection.
- Returns:
A ks_ptr to the newly created instance of the ProjectConstraintError model.
- Parameter
- postModelStep(t: float | numpy.timedelta64, x: Annotated[numpy.typing.ArrayLike, numpy.float64, [m, 1]]) None#
Project the coordinates to satisfy the constraints if the current error is larger than the tolerance.
- Parameter
t: Current time. Unused.
- Parameter
x: Current state. Unused.
- Parameter
- class Karana.Models.ProjectConstraintErrorKModel#
Bases:
Karana.Models.BaseKModel- debug_model: bool#
- params: ProjectConstraintErrorParams#
- state_propagator: Karana.Dynamics.StatePropagator#
- getNextModelStepTime(t: float | numpy.timedelta64) numpy.timedelta64 | None#
Get the next step time assuming the provided time t is a time the model has a step at.
- Parameters:
t (Ktime) – A time the model has a step at.
- Returns:
The next model step time.
- Return type:
Ktime
- getPeriod() numpy.timedelta64#
Get the period of the model.
If a nextModelStepTime method exists, this returns a warning. A model period and nextModelStepTime cannot both be defined for a model.
- Returns:
The model’s period.
- Return type:
Ktime
- isFinalized() bool#
Checks whether the model is finalized.
- Returns:
Returns false if the params pointer is emtpy or if the parameters are not finalize. Returns true otherwise.
- Return type:
bool
- setPeriod(t: float | numpy.timedelta64) None#
Set the model period.
The model period defines the period at which the model runs. There are a few cases to consider:
The period is 0 and no nextModelStepTime method is defined. In this case, the preModelStep/postModelStep methods will run every time a simulation hop happens.
The period is non-zero. In this case, those methods will run at the specified period.
The period is 0 and a nextModelStepTime method is defined. Then, that method defines when the steps will run.
A model period and nextModelStepTime cannot both be defined for a model. An error will be thrown if a model with nextModelStepTime has its period set.
- Parameters:
t (Ktime) – The new model period.
- class Karana.Models.ProjectConstraintErrorParams#
@class ProjectConstraintErrorParams Parameters for the ProjectConstraintError model.
- isFinalized() bool#
Used to ensure the params are finalized.
- Returns:
true if the params are finalized, `false otherwise.
- property tol: float#
Directory where the renders will be saved.
- class Karana.Models.SpringDamper(name: str, sp: Karana.Dynamics.StatePropagator, nd1: Karana.Dynamics.Node, nd2: Karana.Dynamics.Node)#
Bases:
SpringDamperKModel@class SpringDamper Adds a spring-damper between two nodes.
- static create(name: str, sp: Karana.Dynamics.StatePropagator, nd1: Karana.Dynamics.Node, nd2: Karana.Dynamics.Node) SpringDamper#
Constructor. The SpringDamper model applies an equal and opposing force to two nodes based on their current distance apart.
- Parameter
name: The name of the model.
- Parameter
sp: The StatePropagator to register this model with.
- Parameter
nd1: The first node in the spring damper model.
- Parameter
nd2: The second node in the spring damper model.
- Returns:
A ks_ptr to the newly created instance of the SpringDamper model.
- Parameter
- getNodeIds() list[int]#
Get node IDs for DataStruct.
This method retrieves the IDs of the two nodes. This is designed primarily for use with the SpringDamperDS DataStruct.
- Returns:
Nodes’ IDs.
- preDeriv(t: float | numpy.timedelta64, x: Annotated[numpy.typing.ArrayLike, numpy.float64, [m, 1]]) None#
Calculate and apply the spring/damper force.
- Parameter
t: Current time. Not used.
- Parameter
x: Current state. Not used.
- Parameter
- sourceNode() Karana.Dynamics.Node#
Get the first node of the spring-damper
- Returns:
The node
- targetNode() Karana.Dynamics.Node#
Get the second node of the spring-damper
- Returns:
The node
- toDS() Karana.Models.GeneralKModels_types.SpringDamperDS#
Create a SpringDamperDS from this SpringDamper model.
- Returns:
SpringDamperDS
A SpringDamperDS instance with values set to match this model.
- class Karana.Models.SpringDamperKModel#
Bases:
Karana.Models.BaseKModel- debug_model: bool#
- params: SpringDamperParams#
- scratch: SpringDamperScratch#
- state_propagator: Karana.Dynamics.StatePropagator#
- getNextModelStepTime(t: float | numpy.timedelta64) numpy.timedelta64 | None#
Get the next step time assuming the provided time t is a time the model has a step at.
- Parameters:
t (Ktime) – A time the model has a step at.
- Returns:
The next model step time.
- Return type:
Ktime
- getPeriod() numpy.timedelta64#
Get the period of the model.
If a nextModelStepTime method exists, this returns a warning. A model period and nextModelStepTime cannot both be defined for a model.
- Returns:
The model’s period.
- Return type:
Ktime
- isFinalized() bool#
Checks whether the model is finalized.
- Returns:
Returns false if the params pointer is emtpy or if the parameters are not finalize. Returns true otherwise.
- Return type:
bool
- setPeriod(t: float | numpy.timedelta64) None#
Set the model period.
The model period defines the period at which the model runs. There are a few cases to consider:
The period is 0 and no nextModelStepTime method is defined. In this case, the preModelStep/postModelStep methods will run every time a simulation hop happens.
The period is non-zero. In this case, those methods will run at the specified period.
The period is 0 and a nextModelStepTime method is defined. Then, that method defines when the steps will run.
A model period and nextModelStepTime cannot both be defined for a model. An error will be thrown if a model with nextModelStepTime has its period set.
- Parameters:
t (Ktime) – The new model period.
- class Karana.Models.SpringDamperParams#
@class SpringDamperParams Parameters for the SpringDamper model.
- isFinalized() bool#
Used to ensure the params are finalized.
- Returns:
true if the params are finalized, `false otherwise.
- property d: float#
Damper constant
- property k: float#
Spring constant
- property unsprung_length: float#
Unsprung length
- class Karana.Models.SpringDamperScratch#
@class SpringDamperScratch Scratch variables for the SpringDamper model.
- property damping_force: Annotated[numpy.typing.NDArray[numpy.float64], [3, 1]]#
Linear force due to spring damping
- property offset: Annotated[numpy.typing.NDArray[numpy.float64], [3, 1]]#
Translation from node1 to node2
- property position_error: float#
Signed length offset from the unsprung length
- property stiffness_force: float#
Signed scalar force due to spring stiffness
- property total_force: Annotated[numpy.typing.NDArray[numpy.float64], [3, 1]]#
Total linear spring force
- property velocity_error: Annotated[numpy.typing.NDArray[numpy.float64], [3, 1]]#
Relative linear velocity across the spring
- class Karana.Models.SubhingeForceLimits(name: str, sp: Karana.Dynamics.StatePropagator, sh: Karana.Dynamics.PhysicalSubhinge)#
Bases:
SubhingeForceLimitsKModel@class SubhingeForceLimits Limits the generalized force that can be applied to a subhinge.
- static create(name: str, sp: Karana.Dynamics.StatePropagator, sh: Karana.Dynamics.PhysicalSubhinge) SubhingeForceLimits#
Constructor. The SubhingeForceLimits models actuator saturation limits for a subhinge. This clamps the generalized force of the subhinge using a lower bound and upper bound defined by lower_limits and upper_limits in the param.
- Parameter
name: The name of the model.
- Parameter
sp: The StatePropagator to register this model with.
- Parameter
sh: The subhinge to add the force limits to.
- Returns:
A ks_ptr to the newly created instance of the SubhingeForceLimits model.
- Parameter
- preDeriv(t: float | numpy.timedelta64, x: Annotated[numpy.typing.ArrayLike, numpy.float64, [m, 1]]) None#
Calculate and apply the spring/damper force.
- Parameter
t: Current time. Not used.
- Parameter
x: Current state. Not used.
- Parameter
- class Karana.Models.SubhingeForceLimitsKModel#
Bases:
Karana.Models.BaseKModel- debug_model: bool#
- params: SubhingeForceLimitsParams#
- state_propagator: Karana.Dynamics.StatePropagator#
- getNextModelStepTime(t: float | numpy.timedelta64) numpy.timedelta64 | None#
Get the next step time assuming the provided time t is a time the model has a step at.
- Parameters:
t (Ktime) – A time the model has a step at.
- Returns:
The next model step time.
- Return type:
Ktime
- getPeriod() numpy.timedelta64#
Get the period of the model.
If a nextModelStepTime method exists, this returns a warning. A model period and nextModelStepTime cannot both be defined for a model.
- Returns:
The model’s period.
- Return type:
Ktime
- isFinalized() bool#
Checks whether the model is finalized.
- Returns:
Returns false if the params pointer is emtpy or if the parameters are not finalize. Returns true otherwise.
- Return type:
bool
- setPeriod(t: float | numpy.timedelta64) None#
Set the model period.
The model period defines the period at which the model runs. There are a few cases to consider:
The period is 0 and no nextModelStepTime method is defined. In this case, the preModelStep/postModelStep methods will run every time a simulation hop happens.
The period is non-zero. In this case, those methods will run at the specified period.
The period is 0 and a nextModelStepTime method is defined. Then, that method defines when the steps will run.
A model period and nextModelStepTime cannot both be defined for a model. An error will be thrown if a model with nextModelStepTime has its period set.
- Parameters:
t (Ktime) – The new model period.
- class Karana.Models.SubhingeForceLimitsParams#
@class SubhingeForceLimitsParams Paramters for the SubhingeForceLimits model.
- isFinalized() bool#
Used to ensure the params are finalized.
- Returns:
true if the params are finalized, `false otherwise.
- property lower_limits: Annotated[numpy.typing.NDArray[numpy.float64], [m, 1]]#
Lower bound for the force limit
- property upper_limits: Annotated[numpy.typing.NDArray[numpy.float64], [m, 1]]#
Upper bound for the force limit
- class Karana.Models.SubhingeSpringDamper(name: str, sp: Karana.Dynamics.StatePropagator, sh: Karana.Dynamics.PhysicalSubhinge)#
Bases:
SubhingeSpringDamperKModel@class SubhingeSpringDamper Adds a spring damper to the provided subhinge.
- static create(name: str, sp: Karana.Dynamics.StatePropagator, sh: Karana.Dynamics.PhysicalSubhinge) SubhingeSpringDamper#
Constructor. The SubhingeSpringDamper model a spring damper force to a subhinge based on a given setpoint.
- Parameter
name: The name of the model.
- Parameter
sp: The StatePropagator to register this model with.
- Parameter
sh: The subhinge to add the spring damper to.
- Returns:
A ks_ptr to the newly created instance of the SubhingeSpringDamper model.
- Parameter
- preDeriv(t: float | numpy.timedelta64, x: Annotated[numpy.typing.ArrayLike, numpy.float64, [m, 1]]) None#
Calculate and apply the spring/damper force.
- Parameter
t: Current time. Not used.
- Parameter
x: Current state. Not used.
- Parameter
- class Karana.Models.SubhingeSpringDamperKModel#
Bases:
Karana.Models.BaseKModel- debug_model: bool#
- params: SubhingeSpringDamperParams#
- state_propagator: Karana.Dynamics.StatePropagator#
- getNextModelStepTime(t: float | numpy.timedelta64) numpy.timedelta64 | None#
Get the next step time assuming the provided time t is a time the model has a step at.
- Parameters:
t (Ktime) – A time the model has a step at.
- Returns:
The next model step time.
- Return type:
Ktime
- getPeriod() numpy.timedelta64#
Get the period of the model.
If a nextModelStepTime method exists, this returns a warning. A model period and nextModelStepTime cannot both be defined for a model.
- Returns:
The model’s period.
- Return type:
Ktime
- isFinalized() bool#
Checks whether the model is finalized.
- Returns:
Returns false if the params pointer is emtpy or if the parameters are not finalize. Returns true otherwise.
- Return type:
bool
- setPeriod(t: float | numpy.timedelta64) None#
Set the model period.
The model period defines the period at which the model runs. There are a few cases to consider:
The period is 0 and no nextModelStepTime method is defined. In this case, the preModelStep/postModelStep methods will run every time a simulation hop happens.
The period is non-zero. In this case, those methods will run at the specified period.
The period is 0 and a nextModelStepTime method is defined. Then, that method defines when the steps will run.
A model period and nextModelStepTime cannot both be defined for a model. An error will be thrown if a model with nextModelStepTime has its period set.
- Parameters:
t (Ktime) – The new model period.
- class Karana.Models.SubhingeSpringDamperParams#
@class SubhingeSpringDamperParams Parameters for the SubhingeSpringDamper model.
- isFinalized() bool#
Used to ensure the params are finalized.
- Returns:
true if the params are finalized, `false otherwise.
- property d: float#
Damper constant
- property k: float#
Spring constant
- property setpoint: Annotated[numpy.typing.NDArray[numpy.float64], [m, 1]]#
Setpoint for the subhinge
- class Karana.Models.SyncRealTime(name: str, sp: Karana.Dynamics.StatePropagator, rt_speed: SupportsFloat = 1.0)#
Bases:
SyncRealTimeKModel@class SyncRealTime Limits sim speed to a multiple of real time.
- static create(name: str, sp: Karana.Dynamics.StatePropagator, rt_speed: SupportsFloat = 1.0) SyncRealTime#
Constructor.
- Parameter
name: The name of the model.
- Parameter
sp: The StatePropagator to register this model with.
- Parameter
rt_speed: The multiple of real time to limit to.
- Returns:
A ks_ptr to the newly created instance of the SyncRealTime model.
- Parameter
- postHop(t: float | numpy.timedelta64, x: Annotated[numpy.typing.ArrayLike, numpy.float64, [m, 1]]) None#
Sleep as needed to sync to real time.
- Parameter
t: Current time.
- Parameter
x: Current state. Not used.
- Parameter
- preHop(t: float | numpy.timedelta64, x: Annotated[numpy.typing.ArrayLike, numpy.float64, [m, 1]]) None#
Record the start-hop time.
- Parameter
t: Current time.
- Parameter
x: Current state. Not used.
- Parameter
- class Karana.Models.SyncRealTimeKModel#
Bases:
Karana.Models.BaseKModel- debug_model: bool#
- state_propagator: Karana.Dynamics.StatePropagator#
- getNextModelStepTime(t: float | numpy.timedelta64) numpy.timedelta64 | None#
Get the next step time assuming the provided time t is a time the model has a step at.
- Parameters:
t (Ktime) – A time the model has a step at.
- Returns:
The next model step time.
- Return type:
Ktime
- getPeriod() numpy.timedelta64#
Get the period of the model.
If a nextModelStepTime method exists, this returns a warning. A model period and nextModelStepTime cannot both be defined for a model.
- Returns:
The model’s period.
- Return type:
Ktime
- isFinalized() bool#
Checks whether the model is finalized.
- Returns:
Returns false if the params pointer is emtpy or if the parameters are not finalize. Returns true otherwise.
- Return type:
bool
- setPeriod(t: float | numpy.timedelta64) None#
Set the model period.
The model period defines the period at which the model runs. There are a few cases to consider:
The period is 0 and no nextModelStepTime method is defined. In this case, the preModelStep/postModelStep methods will run every time a simulation hop happens.
The period is non-zero. In this case, those methods will run at the specified period.
The period is 0 and a nextModelStepTime method is defined. Then, that method defines when the steps will run.
A model period and nextModelStepTime cannot both be defined for a model. An error will be thrown if a model with nextModelStepTime has its period set.
- Parameters:
t (Ktime) – The new model period.
- class Karana.Models.TimeDisplay(name: str, sp: Karana.Dynamics.StatePropagator, scene: Karana.Scene.GraphicalScene)#
Bases:
TimeDisplayKModel@class TimeDisplay The TimeDisplay model updates the visualization at each postHop.
- static create(name: str, sp: Karana.Dynamics.StatePropagator, scene: Karana.Scene.GraphicalScene) TimeDisplay#
Constructor.
- Parameter
name: The name of the model.
- Parameter
sp: The StatePropagator to register this model with.
- Parameter
scene: The GraphicalScene to display the time in.
- Returns:
A ks_ptr to the newly created instance of the TimeDisplay model.
- Parameter
- postModelStep(t: float | numpy.timedelta64, x: Annotated[numpy.typing.ArrayLike, numpy.float64, [m, 1]]) None#
Update the time display
- Parameter
t: Current time. Not used.
- Parameter
x: Current state. Not used.
- Parameter
- class Karana.Models.TimeDisplayKModel#
Bases:
Karana.Models.BaseKModel- debug_model: bool#
- params: TimeDisplayParams#
- state_propagator: Karana.Dynamics.StatePropagator#
- getNextModelStepTime(t: float | numpy.timedelta64) numpy.timedelta64 | None#
Get the next step time assuming the provided time t is a time the model has a step at.
- Parameters:
t (Ktime) – A time the model has a step at.
- Returns:
The next model step time.
- Return type:
Ktime
- getPeriod() numpy.timedelta64#
Get the period of the model.
If a nextModelStepTime method exists, this returns a warning. A model period and nextModelStepTime cannot both be defined for a model.
- Returns:
The model’s period.
- Return type:
Ktime
- isFinalized() bool#
Checks whether the model is finalized.
- Returns:
Returns false if the params pointer is emtpy or if the parameters are not finalize. Returns true otherwise.
- Return type:
bool
- setPeriod(t: float | numpy.timedelta64) None#
Set the model period.
The model period defines the period at which the model runs. There are a few cases to consider:
The period is 0 and no nextModelStepTime method is defined. In this case, the preModelStep/postModelStep methods will run every time a simulation hop happens.
The period is non-zero. In this case, those methods will run at the specified period.
The period is 0 and a nextModelStepTime method is defined. Then, that method defines when the steps will run.
A model period and nextModelStepTime cannot both be defined for a model. An error will be thrown if a model with nextModelStepTime has its period set.
- Parameters:
t (Ktime) – The new model period.
- class Karana.Models.TimeDisplayParams#
@class TimeDisplayParams Parameters for the TimeDisplay KModel.
- isFinalized() bool#
Used to ensure the params are finalized.
- Returns:
true if the params are finalized, false otherwise.
- property color: Karana.Scene.Color#
Color of the time text
- class Karana.Models.UniformGravity(name: str, sp: Karana.Dynamics.StatePropagator, st: Karana.Dynamics.SubTree)#
Bases:
UniformGravityKModel@class UniformGravity Apply uniform gravitational acceleration to each body in the provided multibody.
- static create(name: str, sp: Karana.Dynamics.StatePropagator, st: Karana.Dynamics.SubTree) UniformGravity#
Constructor.
- Parameter
name: The name of the model.
- Parameter
sp: The StatePropagator to register this model with.
- Parameter
st: The SubTree to apply uniform gravity to.
- Returns:
A ks_ptr to the newly created instance of the UniformGravity model.
- Parameter
- preDeriv(t: float | numpy.timedelta64, x: Annotated[numpy.typing.ArrayLike, numpy.float64, [m, 1]]) None#
Calculate and apply the aerodynamic force.
- Parameter
t: Current time. Not used.
- Parameter
x: Current state. Not used.
- Parameter
- class Karana.Models.UniformGravityKModel#
Bases:
Karana.Models.BaseKModel- debug_model: bool#
- params: UniformGravityParams#
- state_propagator: Karana.Dynamics.StatePropagator#
- getNextModelStepTime(t: float | numpy.timedelta64) numpy.timedelta64 | None#
Get the next step time assuming the provided time t is a time the model has a step at.
- Parameters:
t (Ktime) – A time the model has a step at.
- Returns:
The next model step time.
- Return type:
Ktime
- getPeriod() numpy.timedelta64#
Get the period of the model.
If a nextModelStepTime method exists, this returns a warning. A model period and nextModelStepTime cannot both be defined for a model.
- Returns:
The model’s period.
- Return type:
Ktime
- isFinalized() bool#
Checks whether the model is finalized.
- Returns:
Returns false if the params pointer is emtpy or if the parameters are not finalize. Returns true otherwise.
- Return type:
bool
- setPeriod(t: float | numpy.timedelta64) None#
Set the model period.
The model period defines the period at which the model runs. There are a few cases to consider:
The period is 0 and no nextModelStepTime method is defined. In this case, the preModelStep/postModelStep methods will run every time a simulation hop happens.
The period is non-zero. In this case, those methods will run at the specified period.
The period is 0 and a nextModelStepTime method is defined. Then, that method defines when the steps will run.
A model period and nextModelStepTime cannot both be defined for a model. An error will be thrown if a model with nextModelStepTime has its period set.
- Parameters:
t (Ktime) – The new model period.
- class Karana.Models.UniformGravityParams#
@class UniformGravityParams Parameters for the UniformGravity class.
- isFinalized() bool#
Used to ensure the params are finalized.
- Returns:
true if the params are finalized, `false otherwise.
- property g: Annotated[numpy.typing.NDArray[numpy.float64], [3, 1]]#
Gravity vector
- class Karana.Models.UpdateProxyScene(name: str, sp: Karana.Dynamics.StatePropagator, scene: Karana.Scene.ProxyScene)#
Bases:
UpdateProxySceneKModel@class UpdateProxyScene The UpdateProxyScene model updates the visualization at each postHop.
- static create(name: str, sp: Karana.Dynamics.StatePropagator, scene: Karana.Scene.ProxyScene) UpdateProxyScene#
Constructor.
- Parameter
name: The name of the model.
- Parameter
sp: The StatePropagator to register this model with.
- Parameter
scene: The ProxyScene to call update on.
- Returns:
A ks_ptr to the newly created instance of the UpdateProxyScene model.
- Parameter
- postHop(t: float | numpy.timedelta64, x: Annotated[numpy.typing.ArrayLike, numpy.float64, [m, 1]]) None#
Update the ProxyScene.
- Parameter
t: Current time. Not used.
- Parameter
x: Current state. Not used.
- Parameter
- class Karana.Models.UpdateProxySceneKModel#
Bases:
Karana.Models.BaseKModel- debug_model: bool#
- state_propagator: Karana.Dynamics.StatePropagator#
- getNextModelStepTime(t: float | numpy.timedelta64) numpy.timedelta64 | None#
Get the next step time assuming the provided time t is a time the model has a step at.
- Parameters:
t (Ktime) – A time the model has a step at.
- Returns:
The next model step time.
- Return type:
Ktime
- getPeriod() numpy.timedelta64#
Get the period of the model.
If a nextModelStepTime method exists, this returns a warning. A model period and nextModelStepTime cannot both be defined for a model.
- Returns:
The model’s period.
- Return type:
Ktime
- isFinalized() bool#
Checks whether the model is finalized.
- Returns:
Returns false if the params pointer is emtpy or if the parameters are not finalize. Returns true otherwise.
- Return type:
bool
- setPeriod(t: float | numpy.timedelta64) None#
Set the model period.
The model period defines the period at which the model runs. There are a few cases to consider:
The period is 0 and no nextModelStepTime method is defined. In this case, the preModelStep/postModelStep methods will run every time a simulation hop happens.
The period is non-zero. In this case, those methods will run at the specified period.
The period is 0 and a nextModelStepTime method is defined. Then, that method defines when the steps will run.
A model period and nextModelStepTime cannot both be defined for a model. An error will be thrown if a model with nextModelStepTime has its period set.
- Parameters:
t (Ktime) – The new model period.
- class Karana.Models.DataPlotter(name: str, sp: Karana.Dynamics.StatePropagator)[source]#
Bases:
Karana.Models.KModelDataPlotter model.
This model updates a DashApp at the specified interval.
- params: DataPlotterParams#
- class Karana.Models.PenaltyContact(name: str, sp: Karana.Dynamics.StatePropagator, st: Karana.Dynamics.SubTree, colliders: collections.abc.Sequence[Karana.Collision.FrameCollider], default_contact_force_model: Karana.Collision.ContactForceBase)#
Bases:
PenaltyContactKModel@class PenaltyContact Model applying penalty contact forces to collisions from the provided FrameColliders.
This model takes the provided FrameCollider(s) and passes their colliding pairs to the provided ContactForceBase to calculate and apply contact forces.
See Collision dynamics for more discussion on contact and collision dynamics.
- static create(name: str, sp: Karana.Dynamics.StatePropagator, st: Karana.Dynamics.SubTree, colliders: collections.abc.Sequence[Karana.Collision.FrameCollider], default_contact_force_model: Karana.Collision.ContactForceBase) PenaltyContact#
Create a PenaltyContact model.
- Parameter
name: The name of the model.
- Parameter
sp: The StatePropagator to register this model with.
- Parameter
st: The SubTree that this model is operating on.
- Parameter
colliders: Helpers to generate body contacts.
- Parameter
contact_force_model: The model used for computing contact forces.
- Returns:
The created PenaltyContact model.
- Parameter
- preDeriv(name: float | numpy.timedelta64, collider: Annotated[numpy.typing.ArrayLike, numpy.float64, [m, 1]]) None#
Apply penalty contact forces.
- Parameter
t: Current time. Not used.
- Parameter
x: Current state. Not used.
- Parameter
- class Karana.Models.PenaltyContactKModel#
Bases:
Karana.Models.BaseKModel- debug_model: bool#
- state_propagator: Karana.Dynamics.StatePropagator#
- getNextModelStepTime(t: float | numpy.timedelta64) numpy.timedelta64 | None#
Get the next step time assuming the provided time t is a time the model has a step at.
- Parameters:
t (Ktime) – A time the model has a step at.
- Returns:
The next model step time.
- Return type:
Ktime
- getPeriod() numpy.timedelta64#
Get the period of the model.
If a nextModelStepTime method exists, this returns a warning. A model period and nextModelStepTime cannot both be defined for a model.
- Returns:
The model’s period.
- Return type:
Ktime
- isFinalized() bool#
Checks whether the model is finalized.
- Returns:
Returns false if the params pointer is emtpy or if the parameters are not finalize. Returns true otherwise.
- Return type:
bool
- setPeriod(t: float | numpy.timedelta64) None#
Set the model period.
The model period defines the period at which the model runs. There are a few cases to consider:
The period is 0 and no nextModelStepTime method is defined. In this case, the preModelStep/postModelStep methods will run every time a simulation hop happens.
The period is non-zero. In this case, those methods will run at the specified period.
The period is 0 and a nextModelStepTime method is defined. Then, that method defines when the steps will run.
A model period and nextModelStepTime cannot both be defined for a model. An error will be thrown if a model with nextModelStepTime has its period set.
- Parameters:
t (Ktime) – The new model period.