Class DashboardClient
Defined in File dashboard_client.h
Class Documentation
-
class DashboardClient
This class is a wrapper around the dashboard server.
For every Dashboard command there exists a wrapper function that will send the request and wait for the server’s response.
For documentation about the dashboard server, please see
https://www.universal-robots.com/articles/ur/dashboard-server-cb-series-port-29999/
https://www.universal-robots.com/articles/ur/dashboard-server-e-series-port-29999/
Public Functions
-
DashboardClient(const std::string &host, const ClientPolicy client_policy = ClientPolicy::G5)
Constructor that shall be used by default.
- Parameters:
host – IP address of the robot
-
DashboardClient() = delete
-
virtual ~DashboardClient() = default
-
virtual bool connect(const size_t max_num_tries = 0, const std::chrono::milliseconds reconnection_time = std::chrono::seconds(10))
Opens a connection to the dashboard server on the host as specified in the constructor.
- Parameters:
max_num_tries – Maximum number of connection attempts before counting the connection as failed. Unlimited number of attempts when set to 0.
reconnection_time – time in between connection attempts to the server
- Returns:
True on successful connection, false otherwise.
-
void disconnect()
Makes sure no connection to the dashboard server is held inside the object.
-
std::string sendAndReceive(const std::string &command)
Sends a command through the socket and waits for an answer.
- Parameters:
command – Command that will be sent to the server.
- Throws:
UrException – if no response was read from the dashboard server
- Returns:
Answer as received by the server cut off any trailing newlines.
-
bool sendRequest(const std::string &command, const std::string &expected = "")
Sends command and compare it with the expected answer.
- Parameters:
command – Command that will be sent to the server.
expected – Expected response as a regex string
- Returns:
True if the reply to the command is as expected
-
std::string sendRequestString(const std::string &command, const std::string &expected)
Sends command and compare it with the expected answer.
- Parameters:
command – Command that will be sent to the server.
expected – Expected response as a regex string
- Throws:
UrException – if the received answer does not match the expected one.
- Returns:
Answer string as received by the server
-
bool waitForReply(const std::string &command, const std::string &expected, std::chrono::duration<double> timeout = std::chrono::seconds(30))
brief Sends a command and wait until it returns the expected answer
- Parameters:
command – Command that will be sent to the server
expected – Expected replay
timeout – Timeout to wait before the command is considered failed.
- Returns:
True if the reply was as expected within the timeout time
-
bool retryCommand(const std::string &requestCommand, const std::string &requestExpectedResponse, const std::string &waitRequest, const std::string &waitExpectedResponse, const std::chrono::duration<double> timeout, const std::chrono::duration<double> retry_period = std::chrono::seconds(1))
Keep Sending the requesting Command and wait until it returns the expected answer.
- Parameters:
requestCommand – Request command that will be sent to the server
requestExpectedResponse – The expected reply to the request
waitRequest – The status request
waitExpectedResponse – The expected reply on the status
timeout – Timeout before the command is ultimately considered failed
retry_period – Retries will be done with this period
- Returns:
True when both the requested command was receive with the expected reply as well as the resulting status also is as expected within the timeout time
-
bool commandPowerOff()
Send Power off command.
- Returns:
True succeeded
-
DashboardResponse commandPowerOffWithResponse()
Send Power off command.
-
bool commandPowerOn(const std::chrono::duration<double> timeout = std::chrono::seconds(300))
Send Power on command.
- Parameters:
timeout – Timeout in seconds - The robot might take some time to boot before this call can be made successfully.
- Returns:
True succeeded
-
DashboardResponse commandPowerOnWithResponse(const std::chrono::duration<double> timeout = std::chrono::seconds(300))
Send Power on command.
- Parameters:
timeout – Timeout in seconds - The robot might take some time to boot before this call can be made successfully.
-
bool commandBrakeRelease()
Send Brake release command.
- Returns:
True succeeded
-
DashboardResponse commandBrakeReleaseWithResponse()
Send Brake release command.
-
bool commandLoadProgram(const std::string &program_file_name)
Send Load program command.
- Parameters:
program_file_name – The urp program file name with the urp extension
- Returns:
True succeeded
-
DashboardResponse commandLoadProgramWithResponse(const std::string &program_file_name)
Send Load program command and wait for a response.
Stores the following entries in the data field:
‘program_name’: std::string
- Parameters:
program_file_name – The urp program file name with the urp extension
-
bool commandLoadInstallation(const std::string &installation_file_name)
Send Load installation command.
- Parameters:
installation_file_name – The installation file name with the installation extension
- Returns:
True succeeded
-
DashboardResponse commandLoadInstallationWithResponse(const std::string &installation_file_name)
Send Load installation command.
- Parameters:
installation_file_name – The installation file name with the installation extension
-
bool commandPlay()
Send Play program command.
- Returns:
True succeeded
-
DashboardResponse commandPlayWithResponse()
Send Play program command.
-
bool commandPause()
Send Pause program command.
- Returns:
True succeeded
-
DashboardResponse commandPauseWithResponse()
Send Pause program command.
-
bool commandResume()
Send resume command.
This does only exist for PolyScope X, for e-Series robots “play” is used also for resuming a paused program.
- Returns:
True succeeded
-
DashboardResponse commandResumeWithResponse()
Send resume command.
This does only exist for PolyScope X, for e-Series robots “play” is used also for resuming a paused program.
-
bool commandStop()
Send Stop program command.
- Returns:
True succeeded
-
DashboardResponse commandStopWithResponse()
Send Stop program command.
-
bool commandClosePopup()
Send Stop program command.
- Returns:
True succeeded
-
DashboardResponse commandClosePopupWithResponse()
Send Close popup command.
-
bool commandCloseSafetyPopup()
Send Close safety popup command.
- Returns:
True succeeded
-
DashboardResponse commandCloseSafetyPopupWithResponse()
Send Close safety popup command.
-
bool commandRestartSafety()
Send Restart Safety command.
- Returns:
True succeeded
-
DashboardResponse commandRestartSafetyWithResponse()
Send Restart Safety command.
-
bool commandUnlockProtectiveStop()
Send Unlock Protective stop popup command.
- Returns:
True succeeded
-
DashboardResponse commandUnlockProtectiveStopWithResponse()
Send Unlock Protective stop popup command.
-
bool commandShutdown()
Send Shutdown command.
- Returns:
True succeeded
-
DashboardResponse commandShutdownWithResponse()
Send Shutdown command.
-
bool commandQuit()
Send Quit command.
- Returns:
True succeeded
-
DashboardResponse commandQuitWithResponse()
Send Quit command.
-
bool commandRunning()
Send Running command.
- Returns:
True succeeded
-
DashboardResponse commandRunningWithResponse()
Send Running command.
Stores the following entries in the data field:
‘running’: bool
-
bool commandIsProgramSaved()
Send “Is program saved” request command.
- Returns:
True if the program is saved correctly
-
DashboardResponse commandIsProgramSavedWithResponse()
Send “Is program saved” request command.
Stores the following entries in the data field:
‘saved’: bool
’program_name’: std::string (PolyScope 5 only)
-
bool commandIsInRemoteControl()
Send “Is in remote control” query command.
- Throws:
an – UrException when called on CB3 robots
- Returns:
True if the robot is currently in remote control
-
DashboardResponse commandIsInRemoteControlWithResponse()
Send “Is in remote control” query command.
Stores the following entries in the data field:
‘remote_control’: bool
-
bool commandPopup(const std::string &popup_text)
Send popup command.
- Parameters:
popup_text – The text to be shown in the popup
- Returns:
True succeeded
-
DashboardResponse commandPopupWithResponse(const std::string &popup_text)
Send popup command.
-
bool commandAddToLog(const std::string &log_text)
Send text to log.
- Parameters:
log_text – The text to be sent to the log
- Returns:
True succeeded
-
DashboardResponse commandAddToLogWithResponse(const std::string &log_text)
Send text to log.
- Parameters:
log_text – The text to be sent to the log
-
bool commandPolyscopeVersion(std::string &polyscope_version)
Get Polyscope version.
- Parameters:
polyscope_version – The string for the polyscope version number returned
- Returns:
True succeeded
-
DashboardResponse commandPolyscopeVersionWithResponse()
Get Polyscope version.
Stores the following entries in the data field:
‘polyscope_version’: std::string
-
bool commandGetRobotModel(std::string &robot_model)
Get Robot model.
- Parameters:
robot_model – The string for the robot model returned
- Returns:
True succeeded
-
DashboardResponse commandGetRobotModelWithResponse()
Get Robot model.
Stores the following entries in the data field:
‘robot_model’: std::string
-
bool commandGetSerialNumber(std::string &serial_number)
Get Serial number.
- Parameters:
serial_number – The serial number of the robot returned
- Returns:
True succeeded
-
DashboardResponse commandGetSerialNumberWithResponse()
Get Serial number.
Stores the following entries in the data field:
‘serial_number’: std::string
-
bool commandRobotMode(std::string &robot_mode)
Get Robot mode.
- Parameters:
robot_mode – The mode of the robot returned
- Returns:
True succeeded
-
DashboardResponse commandRobotModeWithResponse()
Get Robot mode.
Stores the following entries in the data field:
‘robot_mode’: std::string
-
bool commandGetLoadedProgram(std::string &loaded_program)
Get Loaded Program.
- Parameters:
loaded_program – The path to the loaded program
- Returns:
True succeeded
-
DashboardResponse commandGetLoadedProgramWithResponse()
Get Loaded Program.
Stores the following entries in the data field:
‘program_name’: std::string
-
bool commandSafetyMode(std::string &safety_mode)
Get Safety mode.
- Parameters:
safety_mode – The safety mode of the robot returned
- Returns:
True succeeded
-
DashboardResponse commandSafetyModeWithResponse()
Get Safety mode.
Stores the following entries in the data field:
‘safety_mode’: std::string
-
bool commandSafetyStatus(std::string &safety_status)
Get Safety status.
- Parameters:
safety_status – The safety status of the robot returned
- Returns:
True succeeded
-
DashboardResponse commandSafetyStatusWithResponse()
Get Safety status.
Stores the following entries in the data field:
‘safety_status’: std::string
-
bool commandProgramState(std::string &program_state)
Get Program state.
- Parameters:
program_state – The program state of the robot returned
- Returns:
True succeeded
-
DashboardResponse commandProgramStateWithResponse()
Get Program state.
Stores the following entries in the data field:
‘program_state’: std::string
’program_name’: std::string
-
bool commandGetOperationalMode(std::string &operational_mode)
Get Operational mode.
- Parameters:
operational_mode – The operational mode of the robot returned (Only available for e-series)
- Throws:
an – UrException when called on CB3 robots
- Returns:
True succeeded
-
DashboardResponse commandGetOperationalModeWithResponse()
Get Operational mode.
Stores the following entries in the data field:
‘operational_mode’: std::string
-
bool commandSetOperationalMode(const std::string &operational_mode)
Send Set operational mode command (Only available for e-series)
- Parameters:
operational_mode – The operational mode to set on the robot
- Throws:
an – UrException when called on CB3 robots
- Returns:
True succeeded
-
DashboardResponse commandSetOperationalModeWithResponse(const std::string &operational_mode)
Send Set operational mode command (Only available for e-series)
- Parameters:
operational_mode – The operational mode to set on the robot
-
bool commandClearOperationalMode()
Send Clear operational mode command.
- Throws:
an – UrException when called on CB3 robots
- Returns:
True succeeded
-
DashboardResponse commandClearOperationalModeWithResponse()
Send Clear operational mode command.
- Throws:
an – UrException when called on CB3 robots
-
bool commandSetUserRole(const std::string &user_role)
Send Set user role command (Only available for CB3)
- Parameters:
user_role – The user role to set on the robot
- Throws:
an – UrException when called on e-series robots
- Returns:
True succeeded
-
DashboardResponse commandSetUserRoleWithResponse(const std::string &user_role)
Send Set user role command (Only available for CB3)
- Throws:
an – UrException when called on e-series robots
-
bool commandGetUserRole(std::string &user_role)
Send Get user role command (Only available for CB3)
- Parameters:
user_role – The user role on the robot
- Throws:
an – UrException when called on e-series robots
- Returns:
True succeeded
-
DashboardResponse commandGetUserRoleWithResponse()
Send Get user role command (Only available for CB3)
Stores the following entries in the data field:
‘user_role’: std::string
- Throws:
an – UrException when called on e-series robots
-
bool commandGenerateFlightReport(const std::string &report_type)
Send Generate flight report command.
Note
This may take a long time to run.
- Parameters:
report_type – The report type to set for the flight report
- Returns:
True succeeded
-
DashboardResponse commandGenerateFlightReportWithResponse(const std::string &report_type)
Send Generate flight report command.
Note
This may take a long time to run.
- Parameters:
report_type – The report type to set for the flight report
-
bool commandGenerateSupportFile(const std::string &dir_path)
Send Generate support file command.
Note
This may take a long time to run.
- Parameters:
dir_path – The path to the directory of an already existing directory location inside the programs directory, where the support file is saved
- Returns:
True succeeded
-
DashboardResponse commandGenerateSupportFileWithResponse(const std::string &dir_path)
Send Generate support file command.
Note
This may take a long time to run.
- Parameters:
dir_path – The path to the directory of an already existing directory location inside the programs directory, where the support file is saved
-
bool commandSaveLog()
Flush the polyscope log to the log_history.txt file.
- Returns:
True succeeded
-
DashboardResponse commandSaveLogWithResponse()
Flush the polyscope log to the log_history.txt file.
-
DashboardResponse commandGetProgramListWithResponse()
Get the list of programs on the robot.
Stores the following entries in the data field:
‘programs’: std::vector<ProgramInformation>
-
DashboardResponse commandUploadProgramWithResponse(const std::string &file_path)
Upload a new program to the robot.
Stores the following entries in the data field:
‘program_name’: std::string
- Parameters:
file_path – The path to the program file on the machine where the dashboard client is running. The file will be uploaded to the root of the programs directory on the robot.
-
DashboardResponse commandUpdateProgramWithResponse(const std::string &file_path)
Update an existing program on the robot.
Stores the following entries in the data field:
‘program_name’: std::string
- Parameters:
file_path – The path to the program file on the machine where the dashboard client is running. The file will be uploaded to the root of the programs directory on the robot and override an already existing file with the same name.
-
DashboardResponse commandDownloadProgramWithResponse(const std::string &filename, const std::string &save_path)
Download a program from the robot.
- Parameters:
filename – The name of the program file on the robot. This is the name as returned by commandGetProgramListWithResponse.
save_path – The path where the program file should be saved on the machine where the dashboard client is running.
-
void assertVersion(const std::string &e_series_min_ver, const std::string &cb3_min_ver, const std::string &required_call)
Makes sure that the dashboard_server’s version is above the required version.
- Parameters:
e_series_min_ver – SW version for e-Series
cb3_min_ver – SW version for cb3
required_call – The dashboard call that should be checked
- Throws:
UrException – if the robot’s version isn’t large enough
-
timeval getConfiguredReceiveTimeout() const
Gets the configured receive timeout. If receive timeout is unconfigured “normal” socket timeout of 1 second will be returned.
- Returns:
configured receive timeout
-
void setReceiveTimeout(const timeval &timeout)
Setup Receive timeout used for this socket.
- Parameters:
timeout – Timeout used for setting things up
Protected Attributes
-
std::shared_ptr<DashboardClientImpl> impl_