Class MovementDetector

Nested Relationships

Nested Types

Class Documentation

class MovementDetector

Holds MovementDetectorPlugin objects and polls them to determine a MovementStatus consensus.

Public Functions

void add_plugin(const std::string &id, not_null<std::shared_ptr<MovementDetectorPlugin>> plugin, const double weight = 1.0, const double stale_time = 1.0)

Add plugin to internal list of movement detection algorithm plugins.

Parameters
  • id – Identifier for this plugin instance.

  • plugin – A movement-detecting plugin. It is recommended that the plugin gracefully handle unexpected data types to avoid errors in the process() function.

  • weight – Relative weight assigned to this plugin. Must be positive. See get_status() for how weights affect results.

  • stale_time – Amount of time (seconds) allowed to have elapsed between this plugin’s MovementDetectorPlugin::get_time result and the latest MovementDetectorPlugin::get_time result from all plugins before treating the status from this plugin as temporarily invalid.

Throws

std::invalid_argument – if weight <= 0, or stale_time < 0.

void remove_plugin(const std::string &id)

Remove plugin by id/key.

Parameters

id – The id of the plugin to be removed.

Throws

std::invalid_argument – If no plugin tagged with id is present and GLOBAL_ERROR_MODE is ErrorMode::DIE.

void process(not_null<std::shared_ptr<aspn_xtensor::AspnBase>> data)

Attempt to process the provided data with all available plugins.

If any plugin is likely to react poorly upon receiving unexpected data types or multiple data sources of the same data type need to be routed to specific plugins, use MovementDetector::process(const std::vector<std::string>&, not_null<std::shared_ptr<aspn_xtensor::AspnBase>>).

Parameters

data – Data to process.

void process(const std::vector<std::string> &ids, not_null<std::shared_ptr<aspn_xtensor::AspnBase>> data)

Process the provided data only with specified plugins.

Parameters
  • ids – All ids for the plugins to pass data to.

  • data – Data for the specified algorithm.

Throws

std::invalid_argument – If any of the plugins referenced by ids are not available, and the global error mode is ErrorMode::DIE (accesible with navtk::get_global_error_mode()).

MovementStatus get_status()

Poll all plugins and calculate the current status consensus.

Returns

Estimated status. The returned status is determined by selecting the status that has the maximum weight assigned after removing plugins that are stale or return INVALID. In other words \( status = \max(\sum \omega_{MOVING}, \sum\omega_{NOT\_MOVING}, \sum\omega_{POSSIBLY\_MOVING}) \). In the case of ties MovementStatus::POSSIBLY_MOVING is returned. MovementStatus::INVALID is returned only if all plugins return an INVALID status or are deemed stale, or no plugins have been supplied.

std::unordered_map<std::string, MovementDetectorPluginStat> plugin_info() const

Get information on existing plugins.

Returns

Map keyed by plugin id containing info. See MovementDetectorPluginStat.