Public Member Functions | Static Public Attributes | Private Member Functions | Private Attributes | List of all members
urcl::ExampleRobotWrapper Class Reference

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< DashboardClientgetDashboardClient () const
 
std::shared_ptr< primary_interface::PrimaryClientgetPrimaryClient () const
 
std::shared_ptr< UrDrivergetUrDriver () 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::DashboardClientdashboard_client_
 Dashboard client to interact with the robot. More...
 
std::unique_ptr< rtde_interface::DataPackagedata_pkg_
 
bool headless_mode_
 
comm::INotifier notifier_
 
std::shared_ptr< urcl::primary_interface::PrimaryClientprimary_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::UrDriverur_driver_
 UR driver to interact with the robot. More...
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ ExampleRobotWrapper() [1/2]

urcl::ExampleRobotWrapper::ExampleRobotWrapper ( )
delete

◆ ExampleRobotWrapper() [2/2]

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.

Parameters
robot_ipIP address of the robot to connect to
output_recipe_fileOutput recipe file for RTDE communication
input_recipe_fileInput recipe file for RTDE communication
headless_modeShould the driver be started in headless mode or not?
autostart_programProgram to start automatically after initialization when not in headless mode. This flag is ignored in headless mode.
script_fileURScript 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.

◆ ~ExampleRobotWrapper()

urcl::ExampleRobotWrapper::~ExampleRobotWrapper ( )

Definition at line 95 of file example_robot_wrapper.cpp.

Member Function Documentation

◆ clearProtectiveStop()

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.

◆ getDashboardClient()

std::shared_ptr<DashboardClient> urcl::ExampleRobotWrapper::getDashboardClient ( ) const
inline

Definition at line 172 of file example_robot_wrapper.h.

◆ getPrimaryClient()

std::shared_ptr<primary_interface::PrimaryClient> urcl::ExampleRobotWrapper::getPrimaryClient ( ) const
inline

Definition at line 176 of file example_robot_wrapper.h.

◆ getUrDriver()

std::shared_ptr<UrDriver> urcl::ExampleRobotWrapper::getUrDriver ( ) const
inline

Definition at line 180 of file example_robot_wrapper.h.

◆ handleRobotProgramState()

void urcl::ExampleRobotWrapper::handleRobotProgramState ( bool  program_running)
private

Definition at line 206 of file example_robot_wrapper.cpp.

◆ initializeRobotWithDashboard()

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.

◆ initializeRobotWithPrimaryClient()

bool urcl::ExampleRobotWrapper::initializeRobotWithPrimaryClient ( )

Definition at line 176 of file example_robot_wrapper.cpp.

◆ isHealthy()

bool urcl::ExampleRobotWrapper::isHealthy ( ) const

Definition at line 327 of file example_robot_wrapper.cpp.

◆ readDataPackage()

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.

Parameters
[out]data_pkgThe data package will be stored in that object
Returns
true on a successful read, false if no package can be read or when RTDE data is already being consumed in the background.

Definition at line 262 of file example_robot_wrapper.cpp.

◆ resendRobotProgram()

bool urcl::ExampleRobotWrapper::resendRobotProgram ( )

Depending on whether it is headless or not start autostart_program or call driver's resendRobotProgram function.

Returns
True on successful program start, false otherwise.

Definition at line 318 of file example_robot_wrapper.cpp.

◆ startConsumingRTDEData()

void urcl::ExampleRobotWrapper::startConsumingRTDEData ( )

Start consuming RTDE data in the background.

Definition at line 237 of file example_robot_wrapper.cpp.

◆ startRobotProgram()

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.

Parameters
program_file_nameFilename on the robot including the ".urp" extension.
Returns
True on successful program start, false otherwise.

Definition at line 301 of file example_robot_wrapper.cpp.

◆ startRTDECommununication()

void urcl::ExampleRobotWrapper::startRTDECommununication ( const bool  consume_data = false)

Starts RTDE communication with the robot.

Parameters
consume_dataOnce 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.

◆ stopConsumingRTDEData()

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.

◆ waitForProgramNotRunning()

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.

Parameters
millisecondsHow long to wait for a disconnection.
Returns
True on a disconnection event has been detected, false if no event could be detected before the timeout.

Definition at line 290 of file example_robot_wrapper.cpp.

◆ waitForProgramRunning()

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.

Parameters
millisecondsHow long to wait for a successful connection.
Returns
True on a successful connection, false if not connection could be detected before the timeout.

Definition at line 279 of file example_robot_wrapper.cpp.

Member Data Documentation

◆ autostart_program_

std::string urcl::ExampleRobotWrapper::autostart_program_
private

Definition at line 215 of file example_robot_wrapper.h.

◆ consume_rtde_packages_

std::atomic<bool> urcl::ExampleRobotWrapper::consume_rtde_packages_ = false
private

Definition at line 200 of file example_robot_wrapper.h.

◆ dashboard_client_

std::shared_ptr<urcl::DashboardClient> urcl::ExampleRobotWrapper::dashboard_client_
private

Dashboard client to interact with the robot.

Definition at line 189 of file example_robot_wrapper.h.

◆ data_pkg_

std::unique_ptr<rtde_interface::DataPackage> urcl::ExampleRobotWrapper::data_pkg_
private

Definition at line 202 of file example_robot_wrapper.h.

◆ DEFAULT_ROBOT_IP

const std::string urcl::ExampleRobotWrapper::DEFAULT_ROBOT_IP = "192.168.56.101"
inlinestatic

Definition at line 55 of file example_robot_wrapper.h.

◆ headless_mode_

bool urcl::ExampleRobotWrapper::headless_mode_
private

Definition at line 214 of file example_robot_wrapper.h.

◆ notifier_

comm::INotifier urcl::ExampleRobotWrapper::notifier_
private

Definition at line 197 of file example_robot_wrapper.h.

◆ primary_client_

std::shared_ptr<urcl::primary_interface::PrimaryClient> urcl::ExampleRobotWrapper::primary_client_
private

primary client to interact with the robot

Definition at line 192 of file example_robot_wrapper.h.

◆ program_not_running_cv_

std::condition_variable urcl::ExampleRobotWrapper::program_not_running_cv_
private

Definition at line 208 of file example_robot_wrapper.h.

◆ program_not_running_mutex_

std::mutex urcl::ExampleRobotWrapper::program_not_running_mutex_
private

Definition at line 210 of file example_robot_wrapper.h.

◆ program_running_

bool urcl::ExampleRobotWrapper::program_running_
private

Definition at line 206 of file example_robot_wrapper.h.

◆ program_running_cv_

std::condition_variable urcl::ExampleRobotWrapper::program_running_cv_
private

Definition at line 207 of file example_robot_wrapper.h.

◆ program_running_mutex_

std::mutex urcl::ExampleRobotWrapper::program_running_mutex_
private

Definition at line 209 of file example_robot_wrapper.h.

◆ read_package_mutex_

std::mutex urcl::ExampleRobotWrapper::read_package_mutex_
private

Definition at line 201 of file example_robot_wrapper.h.

◆ robot_initialized_

bool urcl::ExampleRobotWrapper::robot_initialized_ = false
private

Definition at line 204 of file example_robot_wrapper.h.

◆ rtde_communication_started_

std::atomic<bool> urcl::ExampleRobotWrapper::rtde_communication_started_ = false
private

Definition at line 199 of file example_robot_wrapper.h.

◆ rtde_consumer_thread_

std::thread urcl::ExampleRobotWrapper::rtde_consumer_thread_
private

Definition at line 212 of file example_robot_wrapper.h.

◆ SCRIPT_FILE

const std::string urcl::ExampleRobotWrapper::SCRIPT_FILE = "resources/external_control.urscript"
inlinestatic

Definition at line 56 of file example_robot_wrapper.h.

◆ ur_driver_

std::shared_ptr<urcl::UrDriver> urcl::ExampleRobotWrapper::ur_driver_
private

UR driver to interact with the robot.

Definition at line 195 of file example_robot_wrapper.h.


The documentation for this class was generated from the following files:


ur_client_library
Author(s): Thomas Timm Andersen, Simon Rasmussen, Felix Exner, Lea Steffen, Tristan Schnell
autogenerated on Mon May 26 2025 02:35:58