Class robot_interfaces::RobotFrontend¶
-
template<typename Action, typename Observation>
class RobotFrontend¶ Communication link between RobotData and the user.
Takes care of communication between the RobotData and the user. It is just a thin wrapper around RobotData to facilitate interaction and also to make sure the user cannot use RobotData in incorrect ways.
- Template Parameters:
Action –
Observation –
Subclassed by robot_interfaces::Robot< Action, Observation, Driver, Data >, robot_interfaces::Robot< Action, Observation, Driver, Data >
Public Types
-
typedef std::shared_ptr<RobotFrontend<Action, Observation>> Ptr¶
-
typedef std::shared_ptr<const RobotFrontend<Action, Observation>> ConstPtr¶
-
typedef time_series::Timestamp TimeStamp¶
-
typedef std::shared_ptr<RobotFrontend<Action, Observation>> Ptr
-
typedef std::shared_ptr<const RobotFrontend<Action, Observation>> ConstPtr
-
typedef time_series::Timestamp TimeStamp
Public Functions
-
inline Observation get_observation(const TimeIndex &t) const¶
Get observation of time step t.
- Parameters:
t – Index of the time step. If t is in the future, this method will block and wait.
- Throws:
std::invalid_argument – if t is too old and not in the time series buffer anymore.
- Returns:
The observation of time step t.
-
inline Action get_desired_action(const TimeIndex &t) const¶
Get the desired action of time step t.
The desired action is the action as it is passed by the user in append_desired_action.
- Parameters:
t – Index of the time step. If t is in the future, this method will block and wait.
- Throws:
std::invalid_argument – if t is too old and not in the time series buffer anymore.
- Returns:
The desired action of time step t.
-
inline Action get_applied_action(const TimeIndex &t) const¶
Get the applied action of time step t.
The applied action is the one that was actually applied to the robot based on the desired action of that time step. It may differ from the desired one e.g. due to some safety checks which limit the maximum torque. If and how the action is modified depends on the implementation of the RobotDriver.
- Parameters:
t – Index of the time step. If t is in the future, this method will block and wait.
- Throws:
std::invalid_argument – if t is too old and not in the time series buffer anymore.
- Returns:
The applied action of time step t.
-
inline TimeStamp get_timestamp_ms(const TimeIndex &t) const¶
Get the timestamp of time step t.
- Parameters:
t – Index of the time step. If t is in the future, this method will block and wait.
- Throws:
std::invalid_argument – if t is too old and not in the time series buffer anymore.
- Returns:
Timestamp of time step t.
-
inline TimeIndex get_current_timeindex() const¶
Get the current time index.
- Returns:
The latest time index for which observations are available.
-
inline TimeIndex append_desired_action(const Action &desired_action)¶
Append a desired action to the action time series.
This will append an action to the “desired actions” time series. Note that this does not block until the action is actually executed. The time series acts like a queue from which the RobotBackend takes the actions one by one to send them to the actual robot. It is possible to call this method multiple times in a row to already provide actions for the next time steps.
The time step at which the given action will be applied is returned by this method.
- Parameters:
desired_action – The action that shall be applied on the robot. Note that the actually applied action might be different depending on the implementation of the RobotDriver (see get_applied_action).
- Returns:
Time step at which the action will be applied.
-
inline void wait_until_timeindex(const TimeIndex &t) const¶
Wait until the specified time step is reached.
- Parameters:
t – Time step until which is waited.
- Throws:
std::invalid_argument – if t is too old and not in the time series buffer anymore.
-
inline RobotFrontend(std::shared_ptr<RobotData<Action, Observation>> robot_data)
-
inline Observation get_observation(const TimeIndex &t) const
Get observation of time step t.
- Parameters:
t – Index of the time step. If t is in the future, this method will block and wait.
- Throws:
std::invalid_argument – if t is too old and not in the time series buffer anymore.
- Returns:
The observation of time step t.
-
inline Action get_desired_action(const TimeIndex &t) const
Get the desired action of time step t.
The desired action is the action as it is passed by the user in append_desired_action.
- Parameters:
t – Index of the time step. If t is in the future, this method will block and wait.
- Throws:
std::invalid_argument – if t is too old and not in the time series buffer anymore.
- Returns:
The desired action of time step t.
-
inline Action get_applied_action(const TimeIndex &t) const
Get the applied action of time step t.
The applied action is the one that was actually applied to the robot based on the desired action of that time step. It may differ from the desired one e.g. due to some safety checks which limit the maximum torque. If and how the action is modified depends on the implementation of the RobotDriver.
- Parameters:
t – Index of the time step. If t is in the future, this method will block and wait.
- Throws:
std::invalid_argument – if t is too old and not in the time series buffer anymore.
- Returns:
The applied action of time step t.
-
inline TimeStamp get_timestamp_ms(const TimeIndex &t) const
Get the timestamp of time step t.
- Parameters:
t – Index of the time step. If t is in the future, this method will block and wait.
- Throws:
std::invalid_argument – if t is too old and not in the time series buffer anymore.
- Returns:
Timestamp of time step t.
-
inline TimeIndex get_current_timeindex() const
Get the current time index.
- Returns:
The latest time index for which observations are available.
-
inline TimeIndex append_desired_action(const Action &desired_action)
Append a desired action to the action time series.
This will append an action to the “desired actions” time series. Note that this does not block until the action is actually executed. The time series acts like a queue from which the RobotBackend takes the actions one by one to send them to the actual robot. It is possible to call this method multiple times in a row to already provide actions for the next time steps.
The time step at which the given action will be applied is returned by this method.
- Parameters:
desired_action – The action that shall be applied on the robot. Note that the actually applied action might be different depending on the implementation of the RobotDriver (see get_applied_action).
- Returns:
Time step at which the action will be applied.
-
inline void wait_until_timeindex(const TimeIndex &t) const
Wait until the specified time step is reached.
- Parameters:
t – Time step until which is waited.
- Throws:
std::invalid_argument – if t is too old and not in the time series buffer anymore.