PrimaryClient
The Primary Client serves as an interface to the robot’s primary interface, present on port 30001.
The PrimaryClient class supports, among other things, sending URScript code for execution on the robot through the primary interface. Currently it offers two methods of script execution: sendScript and sendScriptBlocking.
Connection timeout
When the robot is switched off, it neither accepts nor refuses connection requests, and each connection attempt of start() waits until the operating system gives up. In some cases on Linux this can take about two minutes.
To give up earlier, set a connect timeout with setConnectTimeout() before calling start(). It applies to each single connection attempt, including automatic reconnects.
By default, the connect timeout is disabled and the operating system’s timeout applies.
Script execution without feedback
Method signature:
bool sendScript(std::string program);
The sendScript method will accept valid URScript code, and send it to the robot through the primary interface. This is a non-blocking method, as it will return as soon as the program has been transferred to the robot. It returns true when the program is successfully transferred to the robot, and false otherwise.
There is no feedback on whether the program is actually executed on the robot.
Script execution with feedback
Method signature:
bool sendScriptBlocking(
const std::string& program,
const std::string& script_name = "",
const std::chrono::milliseconds start_timeout = std::chrono::seconds(1),
const bool fail_on_warnings = true,
const bool retry_on_readonly_interface = true
);
sendScriptBlocking method will also accept valid URScript code, but blocks until the execution result of the given program is available.start_timeout, the method throws an exception.fail_on_warnings is true, it will also throw an exception, if the robot reports a warning during program execution. Note: protective stops are reported as warnings by the robot.retry_on_readonly_interface is true, the method will restart the primary interface and retry sending the program, if the primary interface is read-only. It will retry once, and if the interface is still read-only, an exception will be thrown. If false, the exception will be thrown, without restarting/retrying.sendScript method in those cases, except for the pre-transfer checks.