$darkmode
cloe::VehicleStateModel Class Reference
Inheritance diagram for cloe::VehicleStateModel:
Collaboration diagram for cloe::VehicleStateModel:

Public Member Functions

virtual void set_vehicle_state (const Object &obj)
 
const boost::optional< Object > & vehicle_state ()
 
bool is_vehicle_state ()
 
void register_vehicle_state_callback (const std::function< void(void)> &c)
 
fable::Json active_state () const override
 
Duration process (const Sync &sync) override
 
void reset () override
 
 Component (const std::string &name, const std::string &description="")
 
 Component (std::string &&name, std::string &&description="")
 
- Public Member Functions inherited from cloe::Component
 Component (const std::string &name, const std::string &description="")
 
 Component (std::string &&name, std::string &&description="")
 
uint64_t id () const
 
template<typename T >
T * as ()
 
Duration process (const Sync &sync) override
 
void reset () override
 
void abort () override
 
- 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 connect ()
 
virtual void disconnect ()
 
virtual void enroll (Registrar &)
 
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)
 

Protected Attributes

boost::optional< Objectvehicle_state_
 
std::function< void(void)> vehicle_state_callback_
 
- Protected Attributes inherited from cloe::Model
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
 

Member Function Documentation

◆ active_state()

fable::Json cloe::VehicleStateModel::active_state ( ) const
inlineoverridevirtual

Write the JSON representation of the vehicle state into j.

Currently, the API is unstable, because we don't have access to any real data.

Implements cloe::Component.

◆ is_vehicle_state()

bool cloe::VehicleStateModel::is_vehicle_state ( )
inline

Return true if set_vehicle_state was called for the current step. Note that is_vehicle_state() may invoke set_vehicle_state() by calling vehicle_state_callback_().

Here is the caller graph for this function:

◆ process()

Duration cloe::VehicleStateModel::process ( const Sync )
inlineoverridevirtual

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.

  • Method is_operational() should return true.
  • It may throw an exception. Those derived from ModelError are more likely to be correctly handled, however. The simulation may handle it by a) removing or replacing the model, b) stopping the simulation, or c) ignoring the exception. In the last case, this method will be called again in the next simulation step. In any case, assume that the simulation will print a message to the logs or the console.
  • It should return the current simulation duration from the model's time domain, which is expected to be less or equal to sync.time().

Implements cloe::Model.

Here is the call graph for this function:

◆ register_vehicle_state_callback()

void cloe::VehicleStateModel::register_vehicle_state_callback ( const std::function< void(void)> &  c)
inline

Register callback function that will invoke set_vehicle_state().

◆ reset()

void cloe::VehicleStateModel::reset ( )
inlineoverridevirtual

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.

Reimplemented in vtd::VtdExternalEgoModel.

Here is the call graph for this function:

◆ set_vehicle_state()

virtual void cloe::VehicleStateModel::set_vehicle_state ( const Object obj)
inlinevirtual

Set the ego vehicle state corresponding to the end of the current step.

◆ vehicle_state()

const boost::optional<Object>& cloe::VehicleStateModel::vehicle_state ( )
inline

Get the ego vehicle state at the end of the current step. Note that vehicle_state() may invoke set_vehicle_state() by calling vehicle_state_callback_().

Member Data Documentation

◆ vehicle_state_

boost::optional<Object> cloe::VehicleStateModel::vehicle_state_
protected

Vehicle state determined by a vehicle dynamics model.

Contains object pose, velocity, acceleration, angular_velocity in world coordinates.

◆ vehicle_state_callback_

std::function<void(void)> cloe::VehicleStateModel::vehicle_state_callback_
protected

Callback function that is invoked when access to the ego vehicle target state is requested (by calling is_vehicle_state() or vehicle_state()).

The main use case for the callback is to update the ego vehicle state using an actuator and/or vehicle dynamics model external of the simulator. Then, the callback could implement the following:

Note that the callback function must ensure that repeated invocation within the same time step does not lead to unintended behavior.


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