Class BaseKModel#
Defined in File KModel.h
Inheritance Relationships#
Base Type#
public Karana::Core::LockingBase(Class LockingBase)
Derived Types#
public Karana::Models::KModel< ComputedTorque >(Template Class KModel)public Karana::Models::KModel< DataLogger, DataLoggerParams >(Template Class KModel)public Karana::Models::KModel< GraphicalSceneMovie, GraphicalSceneMovieParams >(Template Class KModel)public Karana::Models::KModel< PID, PIDParams >(Template Class KModel)public Karana::Models::KModel< PenaltyContact >(Template Class KModel)public Karana::Models::KModel< PinJointLimits, PinJointLimitsParams >(Template Class KModel)public Karana::Models::KModel< PointMassGravity, PointMassGravityParams >(Template Class KModel)public Karana::Models::KModel< ProjectConstraintError, ProjectConstraintErrorParams >(Template Class KModel)public Karana::Models::KModel< SpringDamper, SpringDamperParams, SpringDamperScratch >(Template Class KModel)public Karana::Models::KModel< SubhingeForceLimits, SubhingeForceLimitsParams >(Template Class KModel)public Karana::Models::KModel< SubhingeSpringDamper, SubhingeSpringDamperParams >(Template Class KModel)public Karana::Models::KModel< SyncRealTime >(Template Class KModel)public Karana::Models::KModel< TimeDisplay, TimeDisplayParams >(Template Class KModel)public Karana::Models::KModel< UniformGravity, UniformGravityParams >(Template Class KModel)public Karana::Models::KModel< UpdateProxyScene >(Template Class KModel)public Karana::Models::KModel< T, P, Sc, S, C >(Template Class KModel)
Class Documentation#
-
class BaseKModel : public Karana::Core::LockingBase#
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 curiously-recurring template pattern (CRTP) and in Python we use object attributes. See the.
KModel component models section for more discussion about the KModel class.
Subclassed by Karana::Models::KModel< ComputedTorque >, Karana::Models::KModel< DataLogger, DataLoggerParams >, Karana::Models::KModel< GraphicalSceneMovie, GraphicalSceneMovieParams >, Karana::Models::KModel< PID, PIDParams >, Karana::Models::KModel< PenaltyContact >, Karana::Models::KModel< PinJointLimits, PinJointLimitsParams >, Karana::Models::KModel< PointMassGravity, PointMassGravityParams >, Karana::Models::KModel< ProjectConstraintError, ProjectConstraintErrorParams >, Karana::Models::KModel< SpringDamper, SpringDamperParams, SpringDamperScratch >, Karana::Models::KModel< SubhingeForceLimits, SubhingeForceLimitsParams >, Karana::Models::KModel< SubhingeSpringDamper, SubhingeSpringDamperParams >, Karana::Models::KModel< SyncRealTime >, Karana::Models::KModel< TimeDisplay, TimeDisplayParams >, Karana::Models::KModel< UniformGravity, UniformGravityParams >, Karana::Models::KModel< UpdateProxyScene >, Karana::Models::KModel< T, P, Sc, S, C >
Public Functions
-
BaseKModel(std::string_view name, const kc::ks_ptr<kd::StatePropagator> &sp)#
BaseKModel constructor. The constructor is not meant to be called directly. Please use the create(…) method instead to create an instance.
- Parameters:
name – - The name of the model
sp – - The StatePropagator associated with the model.
-
virtual std::optional<km::Ktime> getNextModelStepTime(const km::Ktime &t) = 0#
Get the next step time assuming that the provided time t is a time the model has a step at.
- Parameters:
t – - A time the model has a step at.
- Returns:
The next step time. If std::nullopt, then the model has no more step times.
-
virtual km::Ktime getPeriod() = 0#
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.
-
virtual void setPeriod(const km::Ktime &t) = 0#
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 begin/postModelStep methods will run every time a simulation hop happens.
The period is non-zero. In this case, the begin/postModelStep methods will run at the specified period.
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.
- Parameters:
t – - The new model period.
-
virtual void stdDebugMsg(std::string_view msg)#
Print a standard debug message.
This creates json with debug information and passes it to the debug logger.
- Parameters:
msg – The message to log.
Public Members
-
bool debug_model = false#
debug_model is a member variable used to enable/disable debug statements for this model.
Protected Functions
-
virtual void _registerModel() = 0#
Register the model with StatePropagator.
-
virtual void _unregisterModel() = 0#
Unregister the model with the StatePropagator.
-
virtual const Eigen::Ref<const km::Vec> _getContinuousStates() const = 0#
-
virtual const Eigen::Ref<const km::Vec> _getContinuousStatesDeriv() = 0#
Get the derivative of the continuous states. Overridden by KModel if appropriate.
- Returns:
The model’s continuous states’ derivatives.
-
virtual void _setContinuousStates(const Eigen::Ref<const km::Vec> x) = 0#
Set the continuous model states.
- Parameters:
x – The new continuous model states.
Protected Attributes
-
km::Ktime _period = {0}#
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 begin/postModelStep methods will run every time a simulation hop happens.
The period is non-zero. In this case, the begin/postModelStep methods will run at the specified period.
The period is 0 and a nextModelStepTime method is defined. In this case, the nextModelStepTime defines when these methods will run.
-
bool _registered = false#
Boolean to track whether this model has been registered or not.
-
bool _has_continuous_states = false#
Boolean to track whether this model has continuous states or not. This is set in _registerModel.
Friends
- friend class kd::StatePropagator
-
BaseKModel(std::string_view name, const kc::ks_ptr<kd::StatePropagator> &sp)#