$darkmode
#include <model.hpp>
Public Member Functions | |
| virtual | ~Model () noexcept=default |
| virtual Duration | resolution () const |
| virtual bool | is_connected () const |
| virtual bool | is_operational () const |
| virtual void | connect () |
| virtual void | disconnect () |
| virtual void | enroll (Registrar &) |
| virtual void | start (const Sync &) |
| virtual Duration | process (const Sync &)=0 |
| virtual void | pause (const Sync &) |
| virtual void | resume (const Sync &) |
| virtual void | stop (const Sync &) |
| virtual void | reset () |
| virtual void | abort () |
| Entity (std::string name) | |
| Entity (std::string name, std::string desc) | |
Public Member Functions inherited from cloe::Entity | |
| Entity (std::string name) | |
| Entity (std::string name, std::string desc) | |
| const std::string & | name () const |
| void | set_name (std::string name) |
| const std::string & | description () const |
| void | set_description (std::string desc) |
Protected Attributes | |
| bool | connected_ {false} |
| bool | operational_ {false} |
Protected Attributes inherited from cloe::Entity | |
| std::string | name_ |
| std::string | desc_ |
Additional Inherited Members | |
Protected Member Functions inherited from cloe::Entity | |
| virtual Logger | logger () const |
The Model class serves as an interface which Controller and Simulator can inherit from.
The following flow diagram shows how the methods of a Model are called in a typical simulation. The nominal flow is rendered in solid lines, while irregular situations are rendered in dashed lines.
┌──────────────────────┐
│ Model() │
└──────────────────────┘
│
▼
┌──────────────────────┐
+------------------------ │ connect() │
| └──────────────────────┘
| │
| ▼
| ┌──────────────────────┐
| │ enroll(Registrar&) │
| └──────────────────────┘
| │
| ▼
| ┌──────────────────────┐
| │ start(const Sync&) │ <-----------+
| └──────────────────────┘ |
| +---------------+ │ |
| | resume(...) | ----------+ │ |
| +---------------+ | │ |
| ^ v ▼ |
| | ┌──────────────────────┐ |
| +---------------+ │ │ ◀──┐ |
| | pause(...) | <--- │ │ │ |
| +---------------+ │ process(const Sync&) │ │ |
| | │ │ │ |
| | +--------- │ │ ───┘ |
| | | └──────────────────────┘ |
| | | │ |
| v v ▼ |
| +-----------+ ┌──────────────────────┐ +-----------+
+---> | abort() | ----> │ stop(const Sync&) │ ----> | reset() |
+-----------+ └──────────────────────┘ +-----------+
| │
| ▼
| ┌──────────────────────┐
+-----------> │ disconnect() │
└──────────────────────┘
│
▼
┌──────────────────────┐
│ ~Model() │
└──────────────────────┘
Note that not all of the methods of a Model are presented in the above diagram. For example, the methods resolution() and is_connected() are expected to be callable at all times. The edges present cover roughly 95% of all expected use-cases, but not all. For example, it is conceivable that a Model will be destructed before connect() is called.
|
virtualdefaultnoexcept |
Destroy a model.
Destruction must handle everything that must be torn down after a disconnect or possibly even before a connect has occurred.
|
inlinevirtual |
Signal an abort to model processing.
This method is called asynchronously. It is highly recommended to make use of a std::atomic_bool for purposes of making the abortion request known to other parts of the model. This method is called when the user requests the simulation to be aborted, e.g., by sending the SIGINT signal.
An abort will be followed by a stop if the simulation was started.
The default implementation will throw an error. This will be caught and possibly ignored. Otherwise, the simulation will be killed.
Reimplemented in cloe::Vehicle, cloe::Component, cloe::controller::Virtue, demo::DemoStuck, demo::DemoPrinter, cloe::controller::GndTruthExtractor, cloe::frustum_culling_plugin::ObjectFrustumCulling, cloe::frustum_culling_plugin::LaneBoundaryFrustumCulling, cloe::component::LaneBoundaryClothoidFit, cloe::controller::basic::BasicController, external::ExternalPrinter, cloe::plugins::NopSimulator, cloe::plugins::NopController, cloe::ObjectSensorFilterMap, cloe::ObjectSensorFilter, cloe::LaneBoundarySensorFilter, minimator::MinimatorSimulator, cloe_esmini::ESMiniSimulator, and vtd::VtdBinding.
|
inlinevirtual |
Initiate a connection to the model, including any initialization.
After a successful connection, the following methods shall be callable:
When implementing this method, e.g. via override or final, make sure to call this method:
void MySuperModel::connect() final { // Your connection code Model::connect(); }
Reimplemented in cloe::Vehicle, cloe::plugins::NopSimulator, minimator::MinimatorSimulator, cloe_esmini::ESMiniSimulator, and vtd::VtdBinding.
|
inlinevirtual |
Tear down the connection to the model.
After successful disconnection, it is not expected that the model should be able to connect again.
When implementing this method, e.g. via override or final, make sure to call this method:
void MySuperModel::disconnect() final { // Your disconnection code Model::disconnect(); }
Reimplemented in cloe::Vehicle, minimator::MinimatorSimulator, cloe_esmini::ESMiniSimulator, and vtd::VtdBinding.
|
inlinevirtual |
Register any events, actions, or handlers with the registrar.
Reimplemented in cloe::Vehicle, cloe::controller::Virtue, cloe::frustum_culling_plugin::ObjectFrustumCulling, cloe::frustum_culling_plugin::LaneBoundaryFrustumCulling, cloe::component::LaneBoundaryClothoidFit, cloe::controller::basic::BasicController, cloe::plugins::NopSimulator, Speedometer, demo::DemoStuck, minimator::MinimatorSimulator, cloe_esmini::ESMiniSimulator, and vtd::VtdBinding.
|
inlineexplicit |
Construct a model.
Construction must specify a name and optionally a description. The name must adhere to the regulations laid down in the Entity class.
A model should be considered disconnected after construction, that is is_connected() should return false.
|
inline |
Construct a model.
Construction must specify a name and optionally a description. The name must adhere to the regulations laid down in the Entity class.
A model should be considered disconnected after construction, that is is_connected() should return false.
|
inlinevirtual |
Return whether the model is successfully connected.
|
inlinevirtual |
Return whether the model can continue processing.
|
inlinevirtual |
Perform any work for transitioning into a paused state.
The passed Sync interface should return the step and time that will be passed to the next resume and process calls.
Perform model processing given the simulation context.
In particular, the model may read and write information from and to data it has, in particular any vehicles.
is_operational() should return true.sync.time(). Implemented in cloe::Vehicle, cloe::Component, cloe::controller::Virtue, cloe::controller::GndTruthExtractor, cloe::frustum_culling_plugin::ObjectFrustumCulling, cloe::frustum_culling_plugin::LaneBoundaryFrustumCulling, cloe::component::LaneBoundaryClothoidFit, cloe::controller::basic::BasicController, cloe::plugins::NopSimulator, cloe::plugins::NopController, cloe::VehicleStateModel, cloe::ObjectSensorFilterMap, cloe::ObjectSensorFilter, cloe::LatLongActuator, cloe::LaneBoundarySensorFilter, cloe::NopDriverRequest, cloe::Actuator< T >, cloe::Actuator< double >, cloe::Actuator< PedalRequest >, cloe::Actuator< SteeringRequest >, cloe::Actuator< GearboxRequest >, cloe::Simulator, Speedometer, demo::DemoPrinter, cloe_esmini::ESMiniEgoControl, vtd::VtdLatLongActuator, external::ExternalPrinter, minimator::MinimatorSimulator, minimator::MinimatorVehicle, cloe_esmini::ESMiniVehicle, cloe_esmini::ESMiniSimulator, vtd::VtdBinding, and demo::DemoStuck.
|
inlinevirtual |
Reset the model state.
This is called when Cloe is asked to reset the whole simulation to time 0. This can be the case when the simulator or a controller asks us to recover from a temporary problem without repeating the whole simulation setup.
The default implementation will raise an error. So if your model is not able to re-initialize, the simulation will be aborted.
Reimplemented in cloe::Vehicle, cloe::Component, demo::DemoStuck, demo::DemoPrinter, minimator::MinimatorEgoSensor, cloe::controller::GndTruthExtractor, cloe::frustum_culling_plugin::ObjectFrustumCulling, cloe::frustum_culling_plugin::LaneBoundaryFrustumCulling, cloe_esmini::ESMiniEgoControl, cloe::component::LaneBoundaryClothoidFit, vtd::VtdExternalEgoModel, vtd::VtdLatLongActuator, external::ExternalPrinter, cloe::plugins::NopSimulator, cloe::plugins::NopController, cloe::NopWheelSensor, cloe::VehicleStateModel, cloe::NopSteeringSensor, cloe::NopPowertrainSensor, cloe::ObjectSensorFilterMap, cloe::ObjectSensorFilter, cloe::NopObjectSensor, cloe::LatLongActuator, cloe::LaneBoundarySensorFilter, cloe::NopEgoSensor, cloe::NopDriverRequest, cloe::NopBrakeSensor, cloe::Actuator< T >, cloe::Actuator< double >, cloe::Actuator< PedalRequest >, cloe::Actuator< SteeringRequest >, cloe::Actuator< GearboxRequest >, minimator::MinimatorSimulator, cloe_esmini::ESMiniSimulator, vtd::VtdBinding, and vtd::VtdVehicle.
|
virtual |
Return the time resolution of the model.
This is how much time each process call is expected to advance. Zero may be returned if the model does not have an intrinsic time resolution. (This would imply that calling process(const Sync&) will advance the models time to exactly Sync::time().
|
inlinevirtual |
Perform any work when resuming from a paused state.
The passed Sync interface should return the step and time that will be passed to the next process call.
|
inlinevirtual |
Perform model setup for the simulation.
The passed Sync interface should return a step and time of zero.
process(const Sync&) is called.is_operational() should return true after this. Reimplemented in cloe::controller::Virtue, cloe::controller::GndTruthExtractor, and vtd::VtdBinding.
|
inlinevirtual |
Perform final work that may throw an exception.
This is called after the last process call when the simulation is through. It is possible after a call to stop, that a reset will be called, followed by a further start. Nominally, however, it will be followed by a disconnect.
is_operational() should return false after this. Reimplemented in cloe::controller::GndTruthExtractor, and vtd::VtdBinding.