$darkmode
cloe_esmini::ESMiniSimulator Class Reference
Inheritance diagram for cloe_esmini::ESMiniSimulator:
Collaboration diagram for cloe_esmini::ESMiniSimulator:

Public Member Functions

 ESMiniSimulator (const ESMiniSimulator &)=default
 
 ESMiniSimulator (ESMiniSimulator &&)=delete
 
ESMiniSimulatoroperator= (const ESMiniSimulator &)=default
 
ESMiniSimulatoroperator= (ESMiniSimulator &&)=delete
 
 ESMiniSimulator (const std::string &name, ESMiniConfiguration c)
 
void connect () final
 
void configure_ego_vehicles ()
 
void disconnect () final
 
void reset () final
 
void abort () final
 
void enroll (cloe::Registrar &r) final
 
size_t num_vehicles () const final
 
std::shared_ptr< cloe::Vehicleget_vehicle (size_t i) const final
 
std::shared_ptr< cloe::Vehicleget_vehicle (const std::string &key) const final
 
cloe::Duration process (const cloe::Sync &sync) final
 
- Public Member Functions inherited from cloe::Model
virtual ~Model () noexcept=default
 
virtual Duration resolution () const
 
virtual bool is_connected () const
 
virtual bool is_operational () const
 
virtual void start (const Sync &)
 
virtual void pause (const Sync &)
 
virtual void resume (const Sync &)
 
virtual void stop (const Sync &)
 
 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)
 

Friends

void to_json (cloe::Json &j, const ESMiniSimulator &b)
 

Additional Inherited Members

- Protected Member Functions inherited from cloe::Entity
virtual Logger logger () const
 
- Protected Attributes inherited from cloe::Model
bool connected_ {false}
 
bool operational_ {false}
 
- Protected Attributes inherited from cloe::Entity
std::string name_
 
std::string desc_
 

Detailed Description

Implementation of a cloe::Simulator specifically for ESMini.

Member Function Documentation

◆ abort()

void cloe_esmini::ESMiniSimulator::abort ( )
inlinefinalvirtual

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.

See also
cloe/core/abort.hpp

Reimplemented from cloe::Model.

◆ connect()

void cloe_esmini::ESMiniSimulator::connect ( )
inlinefinalvirtual

Initiate a connection to the model, including any initialization.

  • It should block until the connection is successfully established.
  • It should throw an exception if an unrecoverable error occurs.
  • It should react to an abort() called on the model.
  • It may throw an error if already connected.

After a successful connection, the following methods shall be callable:

  • enroll(Registrar&)
  • start(const Sync&)

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 from cloe::Model.

Here is the caller graph for this function:

◆ disconnect()

void cloe_esmini::ESMiniSimulator::disconnect ( )
inlinefinalvirtual

Tear down the connection to the model.

  • It should block until the connection is successfully closed.
  • It should throw an exception if an unrecoverable error occurs.
  • It should not throw an exception if called when not connected.

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 from cloe::Model.

Here is the caller graph for this function:

◆ enroll()

void cloe_esmini::ESMiniSimulator::enroll ( cloe::Registrar )
inlinefinalvirtual

Register any events, actions, or handlers with the registrar.

  • This may exhibit different behavior when called in a disconnected state, in order to provide the possibility for verification of triggers in offline mode.
  • It may throw an exception.

Reimplemented from cloe::Model.

◆ get_vehicle() [1/2]

std::shared_ptr<cloe::Vehicle> cloe_esmini::ESMiniSimulator::get_vehicle ( const std::string &  key) const
inlinefinalvirtual

Return a pointer to a Vehicle.

  • If a vehicle does not exist with the key, nullptr is returned.
  • Same conditions apply as for get_vehicle(size_t).

Implements cloe::Simulator.

◆ get_vehicle() [2/2]

std::shared_ptr<cloe::Vehicle> cloe_esmini::ESMiniSimulator::get_vehicle ( size_t  i) const
inlinefinalvirtual

Return a pointer to a Vehicle.

  • The argument i should be between [0, n), where n = num_vehicles().
  • If a vehicle index is accessed that is out-of-bounds, behaviour is undefined.
  • The simulator binding must manage the memory of the Vehicle.
  • The pointer to the vehicle is guaranteed to be valid for the duration of the simulation.
  • After the simulation has disconnected, the pointer is no longer guaranteed to be valid.
  • The vehicle may be modified and these modifications will be preserved for the validity of the pointer. In particular, the sensor and actuator interfaces may be replaced by proxies.

Implements cloe::Simulator.

Here is the call graph for this function:

◆ num_vehicles()

size_t cloe_esmini::ESMiniSimulator::num_vehicles ( ) const
inlinefinalvirtual

Return the number of vehicles that the simulator binding has access to.

  • It may throw an exception or return 0 if the simulator is not connected.

Implements cloe::Simulator.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ process()

cloe::Duration cloe_esmini::ESMiniSimulator::process ( const cloe::Sync )
inlinefinalvirtual

Send vehicle actuations to the simulator and retrieve the new world state.

  1. For each vehicle, actuation is sent first, to make clear that these actuations are based on the sensor information from the previous step. The new world state, at the time point where the actuations are sent is then retrieved and made available to each vehicle. Essentially, they are sent and received in parallel.
  2. The simulator is instructed to complete the next simulation cycle, if possible asynchronously.
  • This function can throw an exception, which causes the simulation to be aborted.
See also
Model::process

Implements cloe::Simulator.

Here is the call graph for this function:

◆ reset()

void cloe_esmini::ESMiniSimulator::reset ( )
inlinefinalvirtual

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 from cloe::Model.

Here is the call graph for this function:

The documentation for this class was generated from the following file: