File robot_data.hpp

RobotData classes for both single- and multi-process applications.

License:

BSD 3-clause

Copyright

Copyright (c) 2018-2020, New York University and Max Planck Gesellschaft

namespace robot_interfaces
template<typename Action, typename Observation>
class MultiProcessRobotData : public robot_interfaces::RobotData<Action, Observation>
#include <robot_data.hpp>

RobotData instance using multi process time series.

Use this class if modules accessing the data are running in separate processes. When all modules run as threads in the same process, this class can be used as well, however, SingleProcessRobotData might be more efficient in that case.

Public Functions

inline MultiProcessRobotData(const std::string &shared_memory_id_prefix, bool is_master, size_t history_length = 1000)

Construct the time series for the robot data.

Todo:

Make this constructor protected and implement factory methods like in MultiprocessTimeSeries..

Parameters
  • shared_memory_id_prefix – Prefix for the shared memory IDs. Since each time series needs its own memory ID, the given value is used as prefix and unique suffixes are appended. Make sure to use a prefix that cannot lead to name collisions on your system.

  • is_master – If set to true, this instance will clear the shared memory on construction and destruction. Only one instance should act as master in a multi-process setup.

  • history_length – History length of the time series. Ignored if is_master == false.

template<typename Action, typename Observation>
class RobotData
#include <robot_data.hpp>

Contains all the input and output data of the robot.

This means the

  • desired_action which was requested by the robot user

  • applied_action which was actually applied and may not be and may not be identical to desired_action for safety reasons

  • observation made by the robot

  • status which keeps track of timing issues and errors.

See this graph to understand how they relate to each other precisely in terms of time:

|------ t = 0 ------|------ t = 1 ------|
|----- action0 -----|----- action1 -----|
o                   o                   o
b                   b                   b
s                   s                   s
0                   1                   2

Template Parameters
  • Action – Type of the actions.

  • Observation – Type of the observations.

Subclassed by robot_interfaces::MultiProcessRobotData< Action, Observation >, robot_interfaces::SingleProcessRobotData< Action, Observation >

Public Members

std::shared_ptr<time_series::TimeSeriesInterface<Action>> desired_action

Time series of the desired actions.

std::shared_ptr<time_series::TimeSeriesInterface<Action>> applied_action

Time series of the actually applied actions (due to safety.

std::shared_ptr<time_series::TimeSeriesInterface<Observation>> observation

Time series of the observations retrieved from the robot.

std::shared_ptr<time_series::TimeSeriesInterface<Status>> status

Time series of status messages.

Protected Functions

inline RobotData()
template<typename Action, typename Observation>
class SingleProcessRobotData : public robot_interfaces::RobotData<Action, Observation>
#include <robot_data.hpp>

RobotData instance using single process time series.

Use this class if all modules accessing the data are running in the same process. If modules run in separate processes, use MultiProcessRobotData instead.

Public Functions

inline SingleProcessRobotData(size_t history_length = 1000)

Construct the time series for the robot data.

Parameters

history_length – History length of the time series.