Class DashboardClient
Defined in File dashboard_client.h
Inheritance Relationships
Base Type
public urcl::comm::TCPSocket
(Class TCPSocket)
Class Documentation
-
class DashboardClient : public urcl::comm::TCPSocket
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
Public Functions
-
DashboardClient(const std::string &host)
Constructor that shall be used by default.
- Parameters:
host – IP address of the robot
-
DashboardClient() = delete
-
virtual ~DashboardClient() = default
-
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
- 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
- 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
-
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
-
bool commandBrakeRelease()
Send Brake release command.
- Returns:
True succeeded
-
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
-
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
-
bool commandPlay()
Send Play program command.
- Returns:
True succeeded
-
bool commandPause()
Send Pause program command.
- Returns:
True succeeded
-
bool commandStop()
Send Stop program command.
- Returns:
True succeeded
-
bool commandClosePopup()
Send Close popup command.
- Returns:
True succeeded
-
bool commandCloseSafetyPopup()
Send Close safety popup command.
- Returns:
True succeeded
-
bool commandRestartSafety()
Send Restart Safety command.
- Returns:
True succeeded
-
bool commandUnlockProtectiveStop()
Send Unlock Protective stop popup command.
- Returns:
True succeeded
-
bool commandShutdown()
Send Shutdown command.
- Returns:
True succeeded
-
bool commandQuit()
Send Quit command.
- Returns:
True succeeded
-
bool commandRunning()
Send Running command.
- Returns:
True succeeded
-
bool commandIsProgramSaved()
Send “Is program saved” request command.
- Returns:
True if the program is saved correctly
-
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
-
bool commandPopup(const std::string &popup_text)
Send popup command.
- Parameters:
popup_text – The text to be shown in the popup
- Returns:
True succeeded
-
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
-
bool commandPolyscopeVersion(std::string &polyscope_version)
Get Polyscope version.
- Parameters:
polyscope_version – The string for the polyscope version number returned
- Returns:
True succeeded
-
bool commandGetRobotModel(std::string &robot_model)
Get Robot model.
- Parameters:
robot_model – The string for the robot model returned
- Returns:
True succeeded
-
bool commandGetSerialNumber(std::string &serial_number)
Get Serial number.
- Parameters:
serial_number – The serial number of the robot returned
- Returns:
True succeeded
-
bool commandRobotMode(std::string &robot_mode)
Get Robot mode.
- Parameters:
robot_mode – The mode of the robot returned
- Returns:
True succeeded
-
bool commandGetLoadedProgram(std::string &loaded_program)
Get Loaded Program.
- Parameters:
loaded_program – The path to the loaded program
- Returns:
True succeeded
-
bool commandSafetyMode(std::string &safety_mode)
Get Safety mode.
- Parameters:
safety_mode – The safety mode of the robot returned
- Returns:
True succeeded
-
bool commandSafetyStatus(std::string &safety_status)
Get Safety status.
- Parameters:
safety_status – The safety status of the robot returned
- Returns:
True succeeded
-
bool commandProgramState(std::string &program_state)
Get Program state.
- Parameters:
program_state – The program state of the robot returned
- Returns:
True succeeded
-
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
-
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
-
bool commandClearOperationalMode()
Send Clear operational mode command.
- Throws:
an – UrException when called on CB3 robots
- Returns:
True succeeded
-
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
-
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
-
bool commandGenerateFlightReport(const std::string &report_type)
Send Generate flight report command.
- Parameters:
report_type – The report type to set for the flight report
- Returns:
True succeeded
-
bool commandGenerateSupportFile(const std::string &dir_path)
Send Generate support file command.
- 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
-
bool commandSaveLog()
Flush the polyscope log to the log_history.txt file.
- Returns:
True succeeded
Public Static Attributes
-
static constexpr int DASHBOARD_SERVER_PORT = 29999