AUTh-ARL Core Stack
0.7
|
An abstract class which implements a robot controller. More...
#include <controller.h>
Public Types | |
enum | Timing { FIXED, DYNAMIC } |
Public Member Functions | |
Controller (std::shared_ptr< Robot > r, const std::string &name, Timing timing=FIXED) | |
Constructor which initializes the robot controller. More... | |
~Controller () | |
bool | run () |
The main function that runs the controller. More... | |
bool | runRT () |
Runs the controller with real time priority. More... | |
void | setExternalStop (bool arg) |
Sets an external stop to the controller. Another external thread can use this function to stop the controller. More... | |
std::string | getName () |
Returns the name of the controller. More... | |
double | getTime () const |
Returns the current time since the start of the controller in seconds. More... | |
virtual void | enableLogging (const std::string &log_path="/home/user/autharl_logfiles/") |
Enables the logging by opening files for log benchmarking times and data. More... | |
virtual void | reference (const arma::mat &ref) |
Protected Member Functions | |
virtual void | init () |
Initializes the controller. More... | |
virtual bool | stop () |
Implements the stopping condition of your controller. More... | |
virtual bool | success () |
Implements the success condition of your controller. More... | |
virtual void | measure () |
Measures the desired data. More... | |
virtual void | command () |
Commands the robot. More... | |
virtual void | update ()=0 |
Performs the necessary calculations of the controller. More... | |
virtual void | waitNextCycle () |
Sets a new reference for the controller. More... | |
Protected Attributes | |
std::string | name |
The name of the controller. More... | |
bool | external_stop |
The external stopped setted by Controller::setExternalStop() More... | |
std::shared_ptr< Robot > | robot |
The pointer to the robot to be controlled. More... | |
double | t |
The current time t, with t = 0 when the controller is created. Alternatively the user can initialize time durint the init() function of its derived controller. More... | |
double | dt |
The cycle time of the control loop, obtained by the robot. More... | |
bool | stop_flag_ |
utils::Timer | timer |
Used for measuring the current time of the controller. More... | |
utils::Timer | benchmark_total_timer_ |
utils::Timer | benchmark_timer_ |
io::Logger | benchmark_logger_ |
io::Logger | logger_ |
Timing | timing_ |
An abstract class which implements a robot controller.
This class defines an interface for implementing a robot controller. You can create your own robot controller by inherit this class and implement the different functionalities like:
|
explicit |
Constructor which initializes the robot controller.
r | A pointer to the robot to be controlled. |
name | The name of your controller. |
arl::robot::Controller::~Controller | ( | ) |
|
protectedvirtual |
Commands the robot.
Implemented according to your controller needs. Basically makes calls to functions of the Robot class, like sending new desired joint torques or joint positions. These desired signals can be stored in internal variables and should have been calculated based on the measurements of the Controller::measure() and the calculations of the Controller::update()
Reimplemented in arl::viz::RosStatePublisher, arl::controller::GravityCompensation, arl::controller::JointTrajectory, arl::controller::CartesianAdmittance, arl::controller::CartesianImpedance, arl::controller::Clik, and arl::bhand::controller::JointAdmittance.
|
virtual |
Enables the logging by opening files for log benchmarking times and data.
log_path | The path for the files to store. |
Exception | if the files cannot be opened (the directory is not exists) |
Reimplemented in arl::controller::Clik.
std::string arl::robot::Controller::getName | ( | ) |
Returns the name of the controller.
double arl::robot::Controller::getTime | ( | ) | const |
Returns the current time since the start of the controller in seconds.
|
protectedvirtual |
Initializes the controller.
Implemented according to your controller needs. Common use cases involve sending a the robot in an initial configuration, setting the robot mode (to position or torque control) or setting the paramters and gains of your controller.
Reimplemented in arl::controller::GravityCompensation, arl::controller::JointTrajectory, arl::controller::CartesianAdmittance, arl::controller::CartesianImpedance, arl::controller::Clik, and arl::bhand::controller::JointAdmittance.
|
protectedvirtual |
Measures the desired data.
Implemented according to your controller needs. Basically makes calls to functions of the Robot class and store them to internal variables, like the joint positions of the robot, the task pose of a robotic arm etc.
Reimplemented in arl::viz::RosStatePublisher, arl::controller::CartesianAdmittance, arl::controller::CartesianImpedance, arl::controller::Clik, and arl::bhand::controller::JointAdmittance.
|
virtual |
bool arl::robot::Controller::run | ( | ) |
The main function that runs the controller.
This function is the main thread of the controller. What is basically do is that first initializes the controller by calling the Controller::init() and then runs the control loop which stops if the Controller::stop() returns true. In each loop the function measures by calling Controller::measure(), perform calculations by calling Controller::update(), commands the robot by calling Controller::command() and finally waits for the next cycle of the given robot by calling Robot::waitNextCycle(). After the loop ends it will return the result of the Controller::success().
bool arl::robot::Controller::runRT | ( | ) |
Runs the controller with real time priority.
It actually runs arl::robot::Controller::run() in a seperate thread with RT priority (99).
void arl::robot::Controller::setExternalStop | ( | bool | arg | ) |
Sets an external stop to the controller. Another external thread can use this function to stop the controller.
arg | Set True to stop the controller. |
|
protectedvirtual |
Implements the stopping condition of your controller.
Implemented according to your controller needs. Common use cases involve stopping conditions like your robot has zero velocity, the robot hardware signals an error or dangerous movements indicates the immediate stop.
Reimplemented in arl::viz::RosStatePublisher, arl::controller::GravityCompensation, arl::controller::JointTrajectory, arl::controller::CartesianAdmittance, arl::controller::CartesianImpedance, and arl::controller::Clik.
|
protectedvirtual |
Implements the success condition of your controller.
Implemented according to your controller needs. Did your controller deliver the task appropriantly?
|
protectedpure virtual |
Performs the necessary calculations of the controller.
Implemented according to your controller needs. The calculations can use the measurements from the Controller::measure() which is stored in internal variables and store the results for the Controller::command() to use.
Implemented in arl::viz::RosStatePublisher, arl::controller::GravityCompensation, arl::controller::JointTrajectory, arl::controller::CartesianAdmittance, arl::controller::CartesianImpedance, arl::controller::Clik, and arl::bhand::controller::JointAdmittance.
|
protectedvirtual |
Sets a new reference for the controller.
Implemented according to your controller needs. The data has the form of an armadillo matrix which can contain any reference signal.
ref | The data reference in the form of a matrix |
Reimplemented in arl::viz::RosStatePublisher.
|
protected |
|
protected |
|
protected |
|
protected |
The cycle time of the control loop, obtained by the robot.
|
protected |
The external stopped setted by Controller::setExternalStop()
|
protected |
|
protected |
The name of the controller.
|
protected |
The pointer to the robot to be controlled.
|
protected |
|
protected |
The current time t, with t = 0 when the controller is created. Alternatively the user can initialize time durint the init() function of its derived controller.
|
protected |
Used for measuring the current time of the controller.
|
protected |