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

RobotType getRobotType()

Get the Robot type.

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