Namespace robot_interfaces::exampleΒΆ
-
namespace example
-
class Action : public robot_interfaces::Loggable, public robot_interfaces::Loggable
- #include <example.hpp>
Actions to be performed by robot, will be received by Driver.
An action simply encapsulate two desired position value, one for each DOF.
Public Functions
-
inline void print(bool backline)
-
template<class Archive>
inline void serialize(Archive &archive)
-
inline virtual std::vector<std::string> get_name()
-
inline virtual std::vector<std::vector<double>> get_data()
-
inline void print(bool backline)
-
template<class Archive>
inline void serialize(Archive &archive)
-
inline virtual std::vector<std::string> get_name()
-
inline virtual std::vector<std::vector<double>> get_data()
Public Members
-
int values[2]
-
inline void print(bool backline)
-
class Observation : public robot_interfaces::Loggable, public robot_interfaces::Loggable
- #include <example.hpp>
Observation read from the robot by Driver.
An observation is the current position for each DOF.
Public Functions
-
inline void print(bool backline)
-
template<class Archive>
inline void serialize(Archive &archive)
-
inline virtual std::vector<std::string> get_name()
-
inline virtual std::vector<std::vector<double>> get_data()
-
inline void print(bool backline)
-
template<class Archive>
inline void serialize(Archive &archive)
-
inline virtual std::vector<std::string> get_name()
-
inline virtual std::vector<std::vector<double>> get_data()
Public Members
-
int values[2]
-
inline void print(bool backline)
-
class Driver : public robot_interfaces::RobotDriver<Action, Observation>, public robot_interfaces::RobotDriver<Action, Observation>
- #include <example.hpp>
Send command to the robot and read observation from the robot. The DOF positions simply becomes the ones set by the latest action, capped between a min and a max value.
Public Functions
-
inline Driver(int min, int max)
-
inline virtual void initialize()
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).
-
inline virtual Action apply_action(const Action &action_to_apply)
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).
-
inline virtual Observation get_latest_observation()
Return the latest observation immediately.
- Returns:
-
inline virtual std::optional<std::string> get_error()
Get error message if there is any error.
Uses std::optional for the return type, so an actual string only needs to be created if there is an error. This is relevant as std::string is in general not real-time safe and should thus be avoided. In case of an error this does not matter, as the control loop will be stopped anyway.
- Returns:
Returns an error message or std::nullopt if there is no error.
-
inline virtual void shutdown()
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.
-
inline Driver(int min, int max)
-
inline virtual void initialize()
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).
-
inline virtual Action apply_action(const Action &action_to_apply)
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).
-
inline virtual Observation get_latest_observation()
Return the latest observation immediately.
- Returns:
-
inline virtual std::optional<std::string> get_error()
Get error message if there is any error.
Uses std::optional for the return type, so an actual string only needs to be created if there is an error. This is relevant as std::string is in general not real-time safe and should thus be avoided. In case of an error this does not matter, as the control loop will be stopped anyway.
- Returns:
Returns an error message or std::nullopt if there is no error.
-
inline virtual void shutdown()
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.
-
inline Driver(int min, int max)
-
class Action : public robot_interfaces::Loggable, public robot_interfaces::Loggable