Class DashboardClientImplX
Defined in File dashboard_client_implementation_x.h
Inheritance Relationships
Base Type
public urcl::DashboardClientImpl(Class DashboardClientImpl)
Class Documentation
-
class DashboardClientImplX : public urcl::DashboardClientImpl
Public Functions
-
DashboardClientImplX() = delete
-
DashboardClientImplX(const std::string &host)
-
~DashboardClientImplX() override
-
virtual std::string sendAndReceive(const std::string &command) override
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.
-
virtual bool connect(const size_t max_num_tries = 0, const std::chrono::milliseconds reconnection_time = std::chrono::seconds(10)) override
Checks whether there is a Robot API endpoint at the configured IP address.
To determine this, this function makes a test call to the “/system/v1/system-time/” endpoint. If the given IP address doesn’t correspond to a robot with the minimal required software version, this call will fail.
Note: Calling this isn’t required for making dashboard calls for a PolyScope X robot.
- Returns:
True on successful test call
-
virtual void disconnect() override
This function call is effectively not doing anything.
-
virtual timeval getConfiguredReceiveTimeout() const override
This function call is effectively not doing anything.
-
virtual bool sendRequest(const std::string &command, const std::string &expected_response_pattern = "", const std::string &payload = "") override
Sends command and verifies that a valid answer is received.
- Parameters:
command – Command that will be sent to the server.
expected_response_pattern – Expected response as a regex string.
payload – Optional payload to be sent with the command.
- Returns:
True if the reply to the command is as expected
-
virtual std::string sendRequestString(const std::string &command, const std::string &expected = "", const std::string &payload = "") override
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
payload – Optional payload to be sent with the command.
- 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
-
virtual DashboardResponse commandAddToLog(const std::string &log_text) override
Send text to log.
- Parameters:
log_text – The text to be sent to the log
-
virtual DashboardResponse commandBrakeRelease() override
Send Brake release command.
-
virtual DashboardResponse commandClearOperationalMode() override
Send Clear operational mode command.
- Throws:
an – UrException when called on CB3 robots
-
virtual DashboardResponse commandClosePopup() override
Send Close popup command.
-
virtual DashboardResponse commandCloseSafetyPopup() override
Send Close safety popup command.
-
virtual DashboardResponse commandGenerateFlightReport(const std::string &report_type) override
Send Generate flight report command.
- Parameters:
report_type – The report type to set for the flight report
-
virtual DashboardResponse commandGenerateSupportFile(const std::string &dir_path) override
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
-
virtual DashboardResponse commandGetLoadedProgram() override
Get Loaded Program.
Stores the following entries in the data field:
‘program_name’: std::string
-
virtual DashboardResponse commandGetOperationalMode() override
Get Operational mode.
Stores the following entries in the data field:
‘operational_mode’: std::string
- Throws:
an – UrException when called on CB3 robots
-
virtual DashboardResponse commandGetRobotModel() override
Get Robot model.
Stores the following entries in the data field:
‘robot_model’: std::string
-
virtual DashboardResponse commandGetSerialNumber() override
Get Serial number.
Stores the following entries in the data field:
‘serial_number’: std::string
-
virtual DashboardResponse commandGetUserRole() override
Send Get user role command (Only available for CB3)
- Throws:
an – UrException when called on e-series robots
-
virtual DashboardResponse commandIsInRemoteControl() override
Send “Is in remote control” query command.
Stores the following entries in the data field:
‘remote_control’: bool
- Throws:
an – UrException when called on CB3 robots
-
virtual DashboardResponse commandIsProgramSaved() override
Send “Is program saved” request command.
Stores the following entries in the data field:
‘saved’: bool
-
virtual DashboardResponse commandLoadInstallation(const std::string &installation_file_name) override
Send Load installation command.
Stores the following entries in the data field:
‘installation_name’: std::string
- Parameters:
installation_file_name – The installation file name with the installation extension
-
virtual DashboardResponse commandLoadProgram(const std::string &program_file_name) override
Send Load program command.
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
-
virtual DashboardResponse commandPause() override
Send Pause program command.
-
virtual DashboardResponse commandResume() override
Send resume command.
This does only exist for PolyScope X, for e-Series robots “play” is used also for resuming a paused program.
-
virtual DashboardResponse commandPlay() override
Send Play program command.
-
virtual DashboardResponse commandPolyscopeVersion() override
Get Polyscope version.
Stores the following entries in the data field:
‘polyscope_version’: std::string
-
virtual DashboardResponse commandPopup(const std::string &popup_text) override
Send popup command.
- Parameters:
popup_text – The text to be shown in the popup
-
virtual DashboardResponse commandPowerOff() override
Send Power off command.
-
virtual DashboardResponse commandPowerOn(const std::chrono::duration<double> timeout = std::chrono::seconds(300)) override
Send Power on command.
- Parameters:
timeout – Timeout in seconds - The robot might take some time to boot before this call can be made successfully.
-
virtual DashboardResponse commandProgramState() override
Get Program state.
Stores the following entries in the data field:
‘program_state’: std::string
’program_name’: std::string
-
virtual DashboardResponse commandQuit() override
Send Quit command.
-
virtual DashboardResponse commandRestartSafety() override
Send Restart Safety command.
-
virtual DashboardResponse commandRobotMode() override
Get Robot mode.
Stores the following entries in the data field:
‘robot_mode’: std::string
-
virtual DashboardResponse commandRunning() override
Send Running command.
Stores the following entries in the data field:
‘running’: bool
-
virtual DashboardResponse commandSafetyMode() override
Get Safety mode.
Stores the following entries in the data field:
‘safety_mode’: std::string
-
virtual DashboardResponse commandSafetyStatus() override
Get Safety status.
Stores the following entries in the data field:
‘safety_status’: std::string
-
virtual DashboardResponse commandSaveLog() override
Flush the polyscope log to the log_history.txt file.
-
virtual DashboardResponse commandSetOperationalMode(const std::string &operational_mode) override
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
-
virtual DashboardResponse commandSetUserRole(const std::string &user_role) override
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
-
virtual DashboardResponse commandShutdown() override
Send Shutdown command.
-
virtual DashboardResponse commandStop() override
Send Stop program command.
-
virtual DashboardResponse commandUnlockProtectiveStop() override
Send Unlock Protective stop popup command.
-
inline virtual void setReceiveTimeout(const timeval &timeout) override
Sets the receive timeout for the socket.
- Parameters:
timeout – The timeout to be set
Public Static Attributes
-
static constexpr int DASHBOARD_SERVER_PORT = 29999
Protected Functions
-
DashboardResponse put(const std::string &endpoint, const std::string &json_data)
-
DashboardResponse get(const std::string &endpoint)
-
virtual VersionInformation queryPolyScopeVersion()
-
virtual void assertHasCommand(const std::string &command) const override
-
DashboardClientImplX() = delete