This class is a high-level abstraction around UrDriver and DashboardClient. It's main purpose is to help us avoiding repetitive robot initialization code in our examples and tests. More...
#include <example_robot_wrapper.h>
Public Member Functions | |
bool | clearProtectiveStop () |
Clear protective stop on the robot. More... | |
ExampleRobotWrapper ()=delete | |
ExampleRobotWrapper (const std::string &robot_ip, const std::string &output_recipe_file, const std::string &input_recipe_file, const bool headless_mode=true, const std::string &autostart_program="", const std::string &script_file=SCRIPT_FILE) | |
Construct a new Example Robot Wrapper object. More... | |
std::shared_ptr< DashboardClient > | getDashboardClient () const |
std::shared_ptr< primary_interface::PrimaryClient > | getPrimaryClient () const |
std::shared_ptr< UrDriver > | getUrDriver () const |
bool | initializeRobotWithDashboard () |
Initializes the robot in order to be able to start a program. More... | |
bool | initializeRobotWithPrimaryClient () |
bool | isHealthy () const |
bool | readDataPackage (std::unique_ptr< rtde_interface::DataPackage > &data_pkg) |
Get the latest RTDE package. More... | |
bool | resendRobotProgram () |
Depending on whether it is headless or not start autostart_program or call driver's resendRobotProgram function. More... | |
void | startConsumingRTDEData () |
Start consuming RTDE data in the background. More... | |
bool | startRobotProgram (const std::string &program_file_name) |
Start the program program_file_name on the robot. More... | |
void | startRTDECommununication (const bool consume_data=false) |
Starts RTDE communication with the robot. More... | |
void | stopConsumingRTDEData () |
Stop consuming RTDE data in the background. Note that data has to be consumed manually using readDataPackage(). More... | |
bool | waitForProgramNotRunning (int milliseconds=100) |
Blocks until there is a disconnection event from the driver's reverse interface detected or until the timeout is hit. More... | |
bool | waitForProgramRunning (int milliseconds=100) |
Blocks until there is a robot program connected to the driver's reverse interface or until the timeout is hit. More... | |
~ExampleRobotWrapper () | |
Static Public Attributes | |
static const std::string | DEFAULT_ROBOT_IP = "192.168.56.101" |
static const std::string | SCRIPT_FILE = "resources/external_control.urscript" |
Private Member Functions | |
void | handleRobotProgramState (bool program_running) |
Private Attributes | |
std::string | autostart_program_ |
std::atomic< bool > | consume_rtde_packages_ = false |
std::shared_ptr< urcl::DashboardClient > | dashboard_client_ |
Dashboard client to interact with the robot. More... | |
std::unique_ptr< rtde_interface::DataPackage > | data_pkg_ |
bool | headless_mode_ |
comm::INotifier | notifier_ |
std::shared_ptr< urcl::primary_interface::PrimaryClient > | primary_client_ |
primary client to interact with the robot More... | |
std::condition_variable | program_not_running_cv_ |
std::mutex | program_not_running_mutex_ |
bool | program_running_ |
std::condition_variable | program_running_cv_ |
std::mutex | program_running_mutex_ |
std::mutex | read_package_mutex_ |
bool | robot_initialized_ = false |
std::atomic< bool > | rtde_communication_started_ = false |
std::thread | rtde_consumer_thread_ |
std::shared_ptr< urcl::UrDriver > | ur_driver_ |
UR driver to interact with the robot. More... | |
This class is a high-level abstraction around UrDriver and DashboardClient. It's main purpose is to help us avoiding repetitive robot initialization code in our examples and tests.
It is therefore not intended to be used in production code, but rather as a helper class for developers. If you want to use this wrapper in your own code, please make sure to understand the logic behind it and adjust it to your needs.
Since this is mainly intended for internal use, don't count on the API being stable for this class!
Definition at line 52 of file example_robot_wrapper.h.
|
delete |
urcl::ExampleRobotWrapper::ExampleRobotWrapper | ( | const std::string & | robot_ip, |
const std::string & | output_recipe_file, | ||
const std::string & | input_recipe_file, | ||
const bool | headless_mode = true , |
||
const std::string & | autostart_program = "" , |
||
const std::string & | script_file = SCRIPT_FILE |
||
) |
Construct a new Example Robot Wrapper object.
This will connect to a robot and initialize it. In headless mode the program will be running instantly, in teach pendant mode the from autostart_program
will be started.
Note: RTDE communication has to be started separately.
robot_ip | IP address of the robot to connect to |
output_recipe_file | Output recipe file for RTDE communication |
input_recipe_file | Input recipe file for RTDE communication |
headless_mode | Should the driver be started in headless mode or not? |
autostart_program | Program to start automatically after initialization when not in headless mode. This flag is ignored in headless mode. |
script_file | URScript file to send to the robot. That should be script code communicating to the driver's reverse interface and trajectory interface. |
Definition at line 39 of file example_robot_wrapper.cpp.
urcl::ExampleRobotWrapper::~ExampleRobotWrapper | ( | ) |
Definition at line 95 of file example_robot_wrapper.cpp.
bool urcl::ExampleRobotWrapper::clearProtectiveStop | ( | ) |
Clear protective stop on the robot.
This will try to clear a protective stop on the robot. If the robot is not in protective stop this call will do nothing.
Definition at line 103 of file example_robot_wrapper.cpp.
|
inline |
Definition at line 172 of file example_robot_wrapper.h.
|
inline |
Definition at line 176 of file example_robot_wrapper.h.
|
inline |
Definition at line 180 of file example_robot_wrapper.h.
|
private |
Definition at line 206 of file example_robot_wrapper.cpp.
bool urcl::ExampleRobotWrapper::initializeRobotWithDashboard | ( | ) |
Initializes the robot in order to be able to start a program.
The robot will be power-cycled once and end up switched on, breaks released.
Definition at line 134 of file example_robot_wrapper.cpp.
bool urcl::ExampleRobotWrapper::initializeRobotWithPrimaryClient | ( | ) |
Definition at line 176 of file example_robot_wrapper.cpp.
bool urcl::ExampleRobotWrapper::isHealthy | ( | ) | const |
Definition at line 327 of file example_robot_wrapper.cpp.
bool urcl::ExampleRobotWrapper::readDataPackage | ( | std::unique_ptr< rtde_interface::DataPackage > & | data_pkg | ) |
Get the latest RTDE package.
Do not call this, while RTDE data is being consumed in the background. In doubt, call stopConsumingRTDEData() before calling this function.
[out] | data_pkg | The data package will be stored in that object |
Definition at line 262 of file example_robot_wrapper.cpp.
bool urcl::ExampleRobotWrapper::resendRobotProgram | ( | ) |
Depending on whether it is headless or not start autostart_program or call driver's resendRobotProgram function.
Definition at line 318 of file example_robot_wrapper.cpp.
void urcl::ExampleRobotWrapper::startConsumingRTDEData | ( | ) |
Start consuming RTDE data in the background.
Definition at line 237 of file example_robot_wrapper.cpp.
bool urcl::ExampleRobotWrapper::startRobotProgram | ( | const std::string & | program_file_name | ) |
Start the program program_file_name
on the robot.
The program has be be present on the robot, otherwise this call does not succeed. The robot needs to be in remote_control mode for this to work properly.
program_file_name | Filename on the robot including the ".urp" extension. |
Definition at line 301 of file example_robot_wrapper.cpp.
void urcl::ExampleRobotWrapper::startRTDECommununication | ( | const bool | consume_data = false | ) |
Starts RTDE communication with the robot.
consume_data | Once the RTDE client is started, it's data has to be consumed. If you don't actually care about that data, this class can silently consume RTDE data when true is passed. This can be stopped and started at any time using the startConsumingRTDEData() and stopConsumingRTDEData() methods. |
Definition at line 224 of file example_robot_wrapper.cpp.
void urcl::ExampleRobotWrapper::stopConsumingRTDEData | ( | ) |
Stop consuming RTDE data in the background. Note that data has to be consumed manually using readDataPackage().
Definition at line 250 of file example_robot_wrapper.cpp.
bool urcl::ExampleRobotWrapper::waitForProgramNotRunning | ( | int | milliseconds = 100 | ) |
Blocks until there is a disconnection event from the driver's reverse interface detected or until the timeout is hit.
milliseconds | How long to wait for a disconnection. |
Definition at line 290 of file example_robot_wrapper.cpp.
bool urcl::ExampleRobotWrapper::waitForProgramRunning | ( | int | milliseconds = 100 | ) |
Blocks until there is a robot program connected to the driver's reverse interface or until the timeout is hit.
milliseconds | How long to wait for a successful connection. |
Definition at line 279 of file example_robot_wrapper.cpp.
|
private |
Definition at line 215 of file example_robot_wrapper.h.
|
private |
Definition at line 200 of file example_robot_wrapper.h.
|
private |
Dashboard client to interact with the robot.
Definition at line 189 of file example_robot_wrapper.h.
|
private |
Definition at line 202 of file example_robot_wrapper.h.
|
inlinestatic |
Definition at line 55 of file example_robot_wrapper.h.
|
private |
Definition at line 214 of file example_robot_wrapper.h.
|
private |
Definition at line 197 of file example_robot_wrapper.h.
|
private |
primary client to interact with the robot
Definition at line 192 of file example_robot_wrapper.h.
|
private |
Definition at line 208 of file example_robot_wrapper.h.
|
private |
Definition at line 210 of file example_robot_wrapper.h.
|
private |
Definition at line 206 of file example_robot_wrapper.h.
|
private |
Definition at line 207 of file example_robot_wrapper.h.
|
private |
Definition at line 209 of file example_robot_wrapper.h.
|
private |
Definition at line 201 of file example_robot_wrapper.h.
|
private |
Definition at line 204 of file example_robot_wrapper.h.
|
private |
Definition at line 199 of file example_robot_wrapper.h.
|
private |
Definition at line 212 of file example_robot_wrapper.h.
|
inlinestatic |
Definition at line 56 of file example_robot_wrapper.h.
|
private |
UR driver to interact with the robot.
Definition at line 195 of file example_robot_wrapper.h.