Class robot_interfaces::RobotBackend

template<typename Action, typename Observation>
class RobotBackend

Communication link between RobotDriver and RobotData.

At each time-step, it gets the observation from the RobotDriver and writes it to RobotData, and it takes the desired_action from RobotData and applies it on the RobotDriver.

Template Parameters:
  • Action

  • Observation

Public Types

typedef std::shared_ptr<RobotBackend<Action, Observation>> Ptr
typedef std::shared_ptr<const RobotBackend<Action, Observation>> ConstPtr
typedef std::shared_ptr<RobotBackend<Action, Observation>> Ptr
typedef std::shared_ptr<const RobotBackend<Action, Observation>> ConstPtr

Public Functions

inline RobotBackend(std::shared_ptr<RobotDriver<Action, Observation>> robot_driver, std::shared_ptr<RobotData<Action, Observation>> robot_data, const bool real_time_mode = true, const double first_action_timeout = std::numeric_limits<double>::infinity(), const uint32_t max_number_of_actions = 0)
Parameters:
  • robot_driverDriver instance for the actual robot.

  • robot_data – Data is send to/retrieved from here.

  • real_time_mode – Enable/disable real-time mode. In real-time mode, the backend will repeat previous actions if the new one is not provided in time or fail with an error if the allowed number of repetitions is exceeded. In non-real-time mode, it will simply block and wait until the action is provided.

  • first_action_timeout – See RobotBackend::first_action_timeout_.

  • max_number_of_actions – See RobotBackend::max_number_of_actions_.

inline virtual ~RobotBackend()
inline uint32_t get_max_action_repetitions()
inline void set_max_action_repetitions(const uint32_t &max_action_repetitions)

Set how often an action is repeated if no new one is provided.

If the next action is due to be executed but the user did not provide one yet (i.e. there is no new action in the robot data time series), the last action will be repeated by automatically adding it to the time series again.

Use this this method to specify how often the action shall be repeated (default is 0, i.e. no repetition at all). If this limit is exceeded, the robot will be shut down and the RobotBackend stops.

Note: This is ignored in non-real-time mode.

Parameters:

max_action_repetitions

inline void initialize()
inline void request_shutdown()

Request shutdown of the backend loop.

The loop may take some time to actually terminate after calling this function. Use wait_until_terminated() to ensure it has really terminated.

inline void wait_until_first_action() const

Wait until the first desired action is received.

inline int wait_until_terminated() const

Wait until the backend loop terminates.

Returns:

Termination code (see RobotBackendTerminationReason).

inline bool is_running() const

Check if the backend loop is still running.

Returns:

True if the loop is still running.

inline int get_termination_reason() const

Get the termination reason.

inline RobotBackend(std::shared_ptr<RobotDriver<Action, Observation>> robot_driver, std::shared_ptr<RobotData<Action, Observation>> robot_data, const bool real_time_mode = true, const double first_action_timeout = std::numeric_limits<double>::infinity(), const uint32_t max_number_of_actions = 0)
Parameters:
  • robot_driverDriver instance for the actual robot.

  • robot_data – Data is send to/retrieved from here.

  • real_time_mode – Enable/disable real-time mode. In real-time mode, the backend will repeat previous actions if the new one is not provided in time or fail with an error if the allowed number of repetitions is exceeded. In non-real-time mode, it will simply block and wait until the action is provided.

  • first_action_timeout – See RobotBackend::first_action_timeout_.

  • max_number_of_actions – See RobotBackend::max_number_of_actions_.

inline virtual ~RobotBackend()
inline uint32_t get_max_action_repetitions()
inline void set_max_action_repetitions(const uint32_t &max_action_repetitions)

Set how often an action is repeated if no new one is provided.

If the next action is due to be executed but the user did not provide one yet (i.e. there is no new action in the robot data time series), the last action will be repeated by automatically adding it to the time series again.

Use this this method to specify how often the action shall be repeated (default is 0, i.e. no repetition at all). If this limit is exceeded, the robot will be shut down and the RobotBackend stops.

Note: This is ignored in non-real-time mode.

Parameters:

max_action_repetitions

inline void initialize()
inline void request_shutdown()

Request shutdown of the backend loop.

The loop may take some time to actually terminate after calling this function. Use wait_until_terminated() to ensure it has really terminated.

inline void wait_until_first_action() const

Wait until the first desired action is received.

inline int wait_until_terminated() const

Wait until the backend loop terminates.

Returns:

Termination code (see RobotBackendTerminationReason).

inline bool is_running() const

Check if the backend loop is still running.

Returns:

True if the loop is still running.

inline int get_termination_reason() const

Get the termination reason.