Probes#

#include "navground/sim/probe.h"
class Probe#

The base class for all probes.

Probes are callbacks called at the begin, at the end, and during each simulation step of an ExperimentalRun.

Concrete classes should overwrite prepare, update, and/or finalize as the base class does nothing.

Subclassed by navground::sim::GroupRecordProbe, navground::sim::RecordProbe, navground::sim::SensingProbe

Public Functions

inline virtual void prepare(ExperimentalRun *run)#

Called at the begin of a simulation run.

Parameters:

run[in] The run

inline virtual void update(ExperimentalRun *run)#

Called at each simulation step.

Parameters:

run[in] The run

inline virtual void finalize(ExperimentalRun *run)#

Called at end of a simulation run.

Parameters:

run[in] The run

class RecordProbe : public navground::sim::Probe#

Base class for probes that records numerical data on a single dataset, possibly to be saved in HDF5.

Subclasses are expected to overwrite Probe::update, get_shape and to redefine RecordProbe::Type.

Public Types

using Type = ng_float_t#

The type of data to record. Subclasses must define their own type for ExperimentalRun::add_record_probe<T> to work with them.

Public Functions

inline virtual Dataset::Shape get_shape(const World &world) const#

Gets the item shape that the record should use, see Dataset::set_item_shape.

Subclasses should overwrite it to configure their records.

Parameters:

world[in] The world being simulated

Returns:

The shape

inline std::shared_ptr<Dataset> get_data()#

Gets the data.

Returns:

The data.

class GroupRecordProbe : public navground::sim::Probe#

Base class for probes that record a group of datasets, possibly to be saved in HDF5. Records are keyed by strings.

Sub-classes are expected to override Probe::update, get_shapes and to redefine Type.

Public Types

using Type = ng_float_t#

The type of data to record. Subclasses must define their own type for ExperimentalRun::add_group_record_probe<T> to work with them.

using Factory = std::function<std::shared_ptr<Dataset>(const std::string &key)>#

Generates dataset for a given key

using ShapeMap = std::map<std::string, Dataset::Shape>#

A map of shapes.

Public Functions

inline virtual ShapeMap get_shapes(const World &world, bool use_agent_uid_as_key) const#

Gets the item shapes that the records should use, see Dataset::set_item_shape.

Subclasses should overwrite it to configure their records.

Parameters:
  • world[in] The world being simulated

  • use_agent_uid_as_key[in] Whether to use the agent uid a key. If not set, it will use the the agent index instead.

Returns:

The shapes

inline std::shared_ptr<Dataset> get_data(const std::string &key)#

Gets the recorded data, possibly after instanting a dataset if none is yet associated to the key.

Parameters:

key[in] The key

Returns:

The data.

class SensingProbe : public navground::sim::Probe#

A concrete probe to record readings from a specific sensor.

Public Types

using Data = std::map<unsigned, std::map<std::string, std::shared_ptr<Dataset>>>#

{agent index -> {field name -> Dataset}}

Public Functions

inline const Data &get_data() const#

Gets the stored sensor readings, indexed by UID or index.

Returns:

The data.