File robot_driver.hppΒΆ
-
namespace robot_interfaces
-
template<typename TAction, typename TObservation>
class RobotDriver - #include <robot_driver.hpp>
Driver for interfacing the actual robot hardware or simulation.
Interface to the robot used by the subsequent classes. Any robot (be it real or simulation) has to derive from this class and implement the functions apply_action(), get_latest_observation() and shutdown(). This Base class provides some timing logic around those three functions. It makes sure that after the first call of apply_action(), it is always called again after some specified time, otherwise the shutdown() method will be called. This Base class also makes sure that the apply_action() function itself does not take more time than expected.
- Template Parameters
Action β
Observation β
Public Functions
-
virtual void initialize() = 0
Initialize the robot.
Any initialization procedures that need to be done before sending actions to the robot should be done in this method (e.g. homing to find the absolute position).
-
virtual Action apply_action(const Action &desired_action) = 0
Apply action immediately and block until it is executed.
This method must apply the desired_action immediately when it is called, and only return once the action has been executed completely. This way we can accommodate both simulators and real robots with this interface.
- Parameters
desired_action β The action we want to apply.
- Returns
The action that was actually applied (since due to safety reasons it might not be possible to apply the desired action).
-
virtual Observation get_latest_observation() = 0
Return the latest observation immediately.
- Returns
Observation
-
virtual std::string get_error() = 0
Get error message if there is any error.
- Returns
Returns an error message or an empty string if there is no error.
-
virtual void shutdown() = 0
Shut down the robot safely.
Use this method if your robot needs to perform some action when shutting down, e.g. to move it to a defined rest position.
-
template<typename TAction, typename TObservation>