Class ExampleRobotWrapper
Defined in File example_robot_wrapper.h
Class Documentation
-
class ExampleRobotWrapper
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!
Public Functions
-
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.
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_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.
-
~ExampleRobotWrapper()
-
bool 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.
-
void startRTDECommununication(const bool consume_data = false)
Starts RTDE communication with the robot.
- Parameters:
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.
-
void startConsumingRTDEData()
Start consuming RTDE data in the background.
-
void stopConsumingRTDEData()
Stop consuming RTDE data in the background. Note that data has to be consumed manually using readDataPackage().
-
bool 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:
data_pkg – [out] The 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.
-
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.
- Parameters:
milliseconds – How long to wait for a successful connection.
- Returns:
True on a successful connection, false if not connection could be detected before the timeout.
-
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.
- Parameters:
milliseconds – How 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.
-
bool 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.
-
bool 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_name – Filename on the robot including the “.urp” extension.
- Returns:
True on successful program start, false otherwise.
-
bool 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.
-
bool isHealthy() const
Public Members
-
std::shared_ptr<urcl::DashboardClient> dashboard_client_
Dashboard client to interact with the robot
-
ExampleRobotWrapper() = delete