Class PrimaryClient

Class Documentation

class PrimaryClient

Public Functions

PrimaryClient() = delete
PrimaryClient(const std::string &robot_ip, comm::INotifier &notifier)
~PrimaryClient()
void addPrimaryConsumer(std::shared_ptr<comm::IConsumer<PrimaryPackage>> primary_consumer)

Adds a primary consumer to the list of consumers.

Parameters:

primary_consumer – Primary consumer that should be added to the list

void removePrimaryConsumer(std::shared_ptr<comm::IConsumer<PrimaryPackage>> primary_consumer)

Remove a primary consumer from the list of consumers.

Parameters:

primary_consumer – Primary consumer that should be removed from the list

void start(const size_t max_connection_attempts = 0, const std::chrono::milliseconds reconnection_timeout = urcl::comm::TCPSocket::DEFAULT_RECONNECTION_TIME)
void stop()
std::deque<ErrorCode> getErrorCodes()

Retrieves previously raised error codes from PrimaryClient. After calling this, recorded errors will be deleted.

bool sendScript(const std::string &program)

Sends a custom script program to the robot.

The given code must be valid according the UR Scripting Manual.

Parameters:

program – URScript code that shall be executed by the robot.

Returns:

true on successful upload, false otherwise.

bool sendScriptBlocking(const std::string &program, std::string script_name = "", std::chrono::milliseconds start_timeout = std::chrono::seconds(1), bool fail_on_warnings = true)

Send a custom script program to the robot, and wait for the execution result.

The given code must be valid according the UR Scripting Manual. The given script code will be automatically wrapped in a function definition, if it is not already. Secondary programs can also be passed to this function, but must be fully defined as a secondary program when calling. Secondary programs create no feedback, so this function will return true as soon as the program is uploaded successfully to the robot (same as the sendScript function).

Parameters:
  • program – URScript code that shall be executed by the robot.

  • script_name – Name of the script to be executed. This will be ignored, if the given script already defines a function name. The script name will be used in log messages in both the client library and in the robot logs. If no name is defined in any way, the script will be given a generic, but unique, name.

  • start_timeout – Amount of time to allow before the robot must have confirmed that the script has been started. If timeout is 0, it will be ignored. Default value: 1 second

  • fail_on_warnings – Whether or not the function should report a failure, if the robot reports a warning-level error during execution. Default true

Throws:
  • urcl::ScriptCodeSyntaxException – if the given script code has syntax errors, which are checked here.

  • urcl::UrException – if the stop command cannot be sent to the robot.

  • urcl::TimeoutException – if the robot doesn’t stop the program within the given timeout.

Returns:

true on successful execution of the script, false otherwise

bool checkCalibration(const std::string &checksum)
void commandPowerOn(const bool validate = true, const std::chrono::milliseconds timeout = std::chrono::seconds(30))

Commands the robot to power on.

Parameters:
  • validate – If true, the function will block until the robot is powered on or the timeout passed by.

  • timeout – The maximum time to wait for the robot to confirm the power on command.

Throws:
  • urcl::UrException – if the command cannot be sent to the robot.

  • urcl::TimeoutException – if the robot doesn’t power on within the given timeout.

void commandPowerOff(const bool validate = true, const std::chrono::milliseconds timeout = std::chrono::seconds(30))

Commands the robot to power off.

Parameters:
  • validate – If true, the function will block until the robot is powered off or the timeout passed by.

  • timeout – The maximum time to wait for the robot to confirm the power off command.

Throws:
  • urcl::UrException – if the command cannot be sent to the robot.

  • urcl::TimeoutException – if the robot doesn’t power off within the given timeout.

void commandBrakeRelease(const bool validate = true, const std::chrono::milliseconds timeout = std::chrono::seconds(30))

Commands the robot to release the brakes.

Parameters:
  • validate – If true, the function will block until the robot is running or the timeout passed by.

  • timeout – The maximum time to wait for the robot to confirm it is running.

Throws:
  • urcl::UrException – if the command cannot be sent to the robot.

  • urcl::TimeoutException – if the robot doesn’t release the brakes within the given timeout.

void commandUnlockProtectiveStop(const bool validate = true, const std::chrono::milliseconds timeout = std::chrono::milliseconds(5000))

Commands the robot to unlock the protective stop.

Parameters:
  • validate – If true, the function will block until the protective stop is released or the timeout passed by.

  • timeout – The maximum time to wait for the robot to confirm it is no longer protective stopped.

Throws:
  • urcl::UrException – if the command cannot be sent to the robot.

  • urcl::TimeoutException – if the robot doesn’t unlock the protective stop within the given timeout.

void commandStop(const bool validate = true, const std::chrono::milliseconds timeout = std::chrono::seconds(2))

/brief Stop execution of a running or paused program

Parameters:
  • validate – If true, the function will block until the robot has stopped or the timeout passed by.

  • timeout – The maximum time to wait for the robot to stop the program.

Throws:
  • urcl::UrException – if the command cannot be sent to the robot.

  • urcl::TimeoutException – if the robot doesn’t stop the program within the given timeout.

inline RobotMode getRobotMode()

Get the latest robot mode.

The robot mode will be updated in the background. This will always show the latest received robot mode independent of the time that has passed since receiving it.

std::shared_ptr<VersionInformation> getRobotVersion(bool wait_for_message = true, const std::chrono::milliseconds timeout = std::chrono::seconds(2))

Get the robot’s software version as Major.Minor.Bugfix.

This function by default blocks until a VersionMessage has been received and returns that version information. If there is an older version message that has been received, this is returned directly.

Parameters:
  • blocking – If true, the function will block until there is a valid version information received by the client or the timeout passed by.

  • timeout – The maximum time to wait for a valid version message.

Throws:

urcl::TimeoutException – if no message was received until the given timeout passed by.

inline std::shared_ptr<RobotModeData> getRobotModeData()

Get the latest robot mode data.

The robot’s mode data will be updated in the background. This will always show the latest received state independent of the time that has passed since receiving it. The return value of this will be a nullptr if no data has been received yet.

inline std::shared_ptr<SafetyModeMessage> getSafetyModeMessage()

Get the latest safety mode message.

The safety mode will be updated in the background. This will always show the latest received state independent of the time that has passed since receiving it. The return value of this will be a nullptr if no data has been received yet.

inline SafetyMode getSafetyMode()

Get the latest safety mode.

The safety mode will be updated in the background. This will always show the latest received robot mode independent of the time that has passed since receiving it.

inline bool isRobotProtectiveStopped()

Query if the robot is protective stopped.

The robot’s protective_stop state will be updated in the background. This will always show the latest received state independent of the time that has passed since receiving it.

Throws:

UrException – when no robot mode data has been received, yet.

inline std::shared_ptr<ConfigurationData> getConfigurationData()

Get the latest configuration data.

The configuration data will be updated in the background. This will always show the latest received configuration data independent of the time that has passed since receiving it. If no configuration data has been received yet, this will return a nullptr.

inline std::shared_ptr<KinematicsInfo> getKinematicsInfo()

Get the latest kinematics info.

The kinematics info contains the controller’s calibrated DH parameters: the nominal model combined with the per-arm calibration deltas, plus the calibration checksum/status. It will be updated in the background. This will always show the latest received kinematics info independent of the time that has passed since receiving it. If no kinematics info has been received yet, this will return a nullptr.

RobotType getRobotType()

Get the Robot type.

If no robot type data has been received yet, this will return UNDEFINED.

RobotSeries getRobotSeries()

Get the Robot series.

If no robot type data has been received yet, this will return UNDEFINED.

bool safetyModeAllowsExecution()