This class is a wrapper around the dashboard server. More...
#include <dashboard_client.h>
Public Member Functions | |
bool | commandAddToLog (const std::string &log_text) |
Send text to log. More... | |
bool | commandBrakeRelease () |
Send Brake release command. More... | |
bool | commandClearOperationalMode () |
Send Clear operational mode command. More... | |
bool | commandClosePopup () |
Send Close popup command. More... | |
bool | commandCloseSafetyPopup () |
Send Close safety popup command. More... | |
bool | commandGenerateFlightReport (const std::string &report_type) |
Send Generate flight report command. More... | |
bool | commandGenerateSupportFile (const std::string &dir_path) |
Send Generate support file command. More... | |
bool | commandGetLoadedProgram (std::string &loaded_program) |
Get Loaded Program. More... | |
bool | commandGetOperationalMode (std::string &operational_mode) |
Get Operational mode. More... | |
bool | commandGetRobotModel (std::string &robot_model) |
Get Robot model. More... | |
bool | commandGetSerialNumber (std::string &serial_number) |
Get Serial number. More... | |
bool | commandGetUserRole (std::string &user_role) |
Send Get user role command (Only available for CB3) More... | |
bool | commandIsInRemoteControl () |
Send "Is in remote control" query command. More... | |
bool | commandIsProgramSaved () |
Send "Is program saved" request command. More... | |
bool | commandLoadInstallation (const std::string &installation_file_name) |
Send Load installation command. More... | |
bool | commandLoadProgram (const std::string &program_file_name) |
Send Load program command. More... | |
bool | commandPause () |
Send Pause program command. More... | |
bool | commandPlay () |
Send Play program command. More... | |
bool | commandPolyscopeVersion (std::string &polyscope_version) |
Get Polyscope version. More... | |
bool | commandPopup (const std::string &popup_text) |
Send popup command. More... | |
bool | commandPowerOff () |
Send Power off command. More... | |
bool | commandPowerOn (const std::chrono::duration< double > timeout=std::chrono::seconds(300)) |
Send Power on command. More... | |
bool | commandProgramState (std::string &program_state) |
Get Program state. More... | |
bool | commandQuit () |
Send Quit command. More... | |
bool | commandRestartSafety () |
Send Restart Safety command. More... | |
bool | commandRobotMode (std::string &robot_mode) |
Get Robot mode. More... | |
bool | commandRunning () |
Send Running command. More... | |
bool | commandSafetyMode (std::string &safety_mode) |
Get Safety mode. More... | |
bool | commandSafetyStatus (std::string &safety_status) |
Get Safety status. More... | |
bool | commandSaveLog () |
Flush the polyscope log to the log_history.txt file. More... | |
bool | commandSetOperationalMode (const std::string &operational_mode) |
Send Set operational mode command (Only available for e-series) More... | |
bool | commandSetUserRole (const std::string &user_role) |
Send Set user role command (Only available for CB3) More... | |
bool | commandShutdown () |
Send Shutdown command. More... | |
bool | commandStop () |
Send Stop program command. More... | |
bool | commandUnlockProtectiveStop () |
Send Unlock Protective stop popup command. More... | |
bool | connect () |
Opens a connection to the dashboard server on the host as specified in the constructor. More... | |
DashboardClient (const std::string &host) | |
Constructor that shall be used by default. More... | |
DashboardClient ()=delete | |
void | disconnect () |
Makes sure no connection to the dashboard server is held inside the object. More... | |
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. More... | |
std::string | sendAndReceive (const std::string &command) |
Sends a command through the socket and waits for an answer. More... | |
bool | sendRequest (const std::string &command, const std::string &expected) |
Sends command and compare it with the expected answer. More... | |
std::string | sendRequestString (const std::string &command, const std::string &expected) |
Sends command and compare it with the expected answer. More... | |
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 More... | |
virtual | ~DashboardClient ()=default |
![]() | |
void | close () |
Closes the connection to the socket. More... | |
std::string | getIP () const |
Determines the local IP address of the currently configured socket. More... | |
int | getSocketFD () |
Getter for the file descriptor of the socket. More... | |
SocketState | getState () |
Getter for the state of the socket. More... | |
bool | read (char *character) |
Reads one byte from the socket. More... | |
bool | read (uint8_t *buf, const size_t buf_len, size_t &read) |
Reads data from the socket. More... | |
void | setReceiveTimeout (const timeval &timeout) |
Setup Receive timeout used for this socket. More... | |
void | setReconnectionTime (std::chrono::seconds reconnection_time) |
Set reconnection time, if the server is unavailable during connection this will set the time before trying connect to the server again. More... | |
TCPSocket () | |
Creates a TCPSocket object. More... | |
bool | write (const uint8_t *buf, const size_t buf_len, size_t &written) |
Writes to the socket. More... | |
virtual | ~TCPSocket () |
Public Attributes | |
const int | DASHBOARD_SERVER_PORT = 29999 |
Protected Member Functions | |
virtual bool | open (int socket_fd, struct sockaddr *address, size_t address_len) |
![]() | |
virtual void | setOptions (int socket_fd) |
bool | setup (std::string &host, int port) |
Private Member Functions | |
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. More... | |
std::string | read () |
void | rtrim (std::string &str, const std::string &chars="\\\") |
bool | send (const std::string &text) |
Private Attributes | |
std::string | host_ |
VersionInformation | polyscope_version_ |
int | port_ |
std::mutex | write_mutex_ |
Additional Inherited Members | |
![]() | |
std::unique_ptr< timeval > | recv_timeout_ |
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
Definition at line 46 of file dashboard_client.h.
urcl::DashboardClient::DashboardClient | ( | const std::string & | host | ) |
Constructor that shall be used by default.
host | IP address of the robot |
Definition at line 41 of file dashboard_client.cpp.
|
delete |
|
virtualdefault |
|
private |
Makes sure that the dashboard_server's version is above the required version.
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 |
UrException | if the robot's version isn't large enough |
Definition at line 475 of file dashboard_client.cpp.
bool urcl::DashboardClient::commandAddToLog | ( | const std::string & | log_text | ) |
Send text to log.
log_text | The text to be sent to the log |
Definition at line 336 of file dashboard_client.cpp.
bool urcl::DashboardClient::commandBrakeRelease | ( | ) |
Send Brake release command.
Definition at line 236 of file dashboard_client.cpp.
bool urcl::DashboardClient::commandClearOperationalMode | ( | ) |
Send Clear operational mode command.
an | UrException when called on CB3 robots |
Definition at line 423 of file dashboard_client.cpp.
bool urcl::DashboardClient::commandClosePopup | ( | ) |
Send Close popup command.
Definition at line 274 of file dashboard_client.cpp.
bool urcl::DashboardClient::commandCloseSafetyPopup | ( | ) |
Send Close safety popup command.
Definition at line 280 of file dashboard_client.cpp.
bool urcl::DashboardClient::commandGenerateFlightReport | ( | const std::string & | report_type | ) |
Send Generate flight report command.
report_type | The report type to set for the flight report |
Definition at line 443 of file dashboard_client.cpp.
bool urcl::DashboardClient::commandGenerateSupportFile | ( | const std::string & | dir_path | ) |
Send Generate support file command.
dir_path | The path to the directory of an already existing directory location inside the programs directory, where the support file is saved |
Definition at line 456 of file dashboard_client.cpp.
bool urcl::DashboardClient::commandGetLoadedProgram | ( | std::string & | loaded_program | ) |
Get Loaded Program.
loaded_program | The path to the loaded program |
Definition at line 376 of file dashboard_client.cpp.
bool urcl::DashboardClient::commandGetOperationalMode | ( | std::string & | operational_mode | ) |
Get Operational mode.
operational_mode | The operational mode of the robot returned (Only available for e-series) |
an | UrException when called on CB3 robots |
Definition at line 408 of file dashboard_client.cpp.
bool urcl::DashboardClient::commandGetRobotModel | ( | std::string & | robot_model | ) |
Get Robot model.
robot_model | The string for the robot model returned |
Definition at line 352 of file dashboard_client.cpp.
bool urcl::DashboardClient::commandGetSerialNumber | ( | std::string & | serial_number | ) |
Get Serial number.
serial_number | The serial number of the robot returned |
Definition at line 360 of file dashboard_client.cpp.
bool urcl::DashboardClient::commandGetUserRole | ( | std::string & | user_role | ) |
Send Get user role command (Only available for CB3)
user_role | The user role on the robot |
an | UrException when called on e-series robots |
Definition at line 435 of file dashboard_client.cpp.
bool urcl::DashboardClient::commandIsInRemoteControl | ( | ) |
Send "Is in remote control" query command.
an | UrException when called on CB3 robots |
Definition at line 322 of file dashboard_client.cpp.
bool urcl::DashboardClient::commandIsProgramSaved | ( | ) |
Send "Is program saved" request command.
Definition at line 316 of file dashboard_client.cpp.
bool urcl::DashboardClient::commandLoadInstallation | ( | const std::string & | installation_file_name | ) |
Send Load installation command.
installation_file_name | The installation file name with the installation extension |
Definition at line 249 of file dashboard_client.cpp.
bool urcl::DashboardClient::commandLoadProgram | ( | const std::string & | program_file_name | ) |
Send Load program command.
program_file_name | The urp program file name with the urp extension |
Definition at line 242 of file dashboard_client.cpp.
bool urcl::DashboardClient::commandPause | ( | ) |
Send Pause program command.
Definition at line 262 of file dashboard_client.cpp.
bool urcl::DashboardClient::commandPlay | ( | ) |
Send Play program command.
Definition at line 256 of file dashboard_client.cpp.
bool urcl::DashboardClient::commandPolyscopeVersion | ( | std::string & | polyscope_version | ) |
Get Polyscope version.
polyscope_version | The string for the polyscope version number returned |
Definition at line 342 of file dashboard_client.cpp.
bool urcl::DashboardClient::commandPopup | ( | const std::string & | popup_text | ) |
Send popup command.
popup_text | The text to be shown in the popup |
Definition at line 330 of file dashboard_client.cpp.
bool urcl::DashboardClient::commandPowerOff | ( | ) |
bool urcl::DashboardClient::commandPowerOn | ( | const std::chrono::duration< double > | timeout = std::chrono::seconds(300) | ) |
Send Power on command.
timeout | Timeout in seconds - The robot might take some time to boot before this call can be made successfully. |
Definition at line 230 of file dashboard_client.cpp.
bool urcl::DashboardClient::commandProgramState | ( | std::string & | program_state | ) |
Get Program state.
program_state | The program state of the robot returned |
Definition at line 400 of file dashboard_client.cpp.
bool urcl::DashboardClient::commandQuit | ( | ) |
bool urcl::DashboardClient::commandRestartSafety | ( | ) |
Send Restart Safety command.
Definition at line 286 of file dashboard_client.cpp.
bool urcl::DashboardClient::commandRobotMode | ( | std::string & | robot_mode | ) |
Get Robot mode.
robot_mode | The mode of the robot returned |
Definition at line 368 of file dashboard_client.cpp.
bool urcl::DashboardClient::commandRunning | ( | ) |
bool urcl::DashboardClient::commandSafetyMode | ( | std::string & | safety_mode | ) |
Get Safety mode.
safety_mode | The safety mode of the robot returned |
Definition at line 384 of file dashboard_client.cpp.
bool urcl::DashboardClient::commandSafetyStatus | ( | std::string & | safety_status | ) |
Get Safety status.
safety_status | The safety status of the robot returned |
Definition at line 392 of file dashboard_client.cpp.
bool urcl::DashboardClient::commandSaveLog | ( | ) |
Flush the polyscope log to the log_history.txt file.
Definition at line 469 of file dashboard_client.cpp.
bool urcl::DashboardClient::commandSetOperationalMode | ( | const std::string & | operational_mode | ) |
Send Set operational mode command (Only available for e-series)
operational_mode | The operational mode to set on the robot |
an | UrException when called on CB3 robots |
Definition at line 416 of file dashboard_client.cpp.
bool urcl::DashboardClient::commandSetUserRole | ( | const std::string & | user_role | ) |
Send Set user role command (Only available for CB3)
user_role | The user role to set on the robot |
an | UrException when called on e-series robots |
Definition at line 429 of file dashboard_client.cpp.
bool urcl::DashboardClient::commandShutdown | ( | ) |
bool urcl::DashboardClient::commandStop | ( | ) |
Send Stop program command.
Definition at line 268 of file dashboard_client.cpp.
bool urcl::DashboardClient::commandUnlockProtectiveStop | ( | ) |
Send Unlock Protective stop popup command.
Definition at line 292 of file dashboard_client.cpp.
bool urcl::DashboardClient::connect | ( | ) |
Opens a connection to the dashboard server on the host as specified in the constructor.
Definition at line 50 of file dashboard_client.cpp.
void urcl::DashboardClient::disconnect | ( | ) |
Makes sure no connection to the dashboard server is held inside the object.
Definition at line 93 of file dashboard_client.cpp.
|
inlineprotectedvirtual |
Reimplemented from urcl::comm::TCPSocket.
Definition at line 433 of file dashboard_client.h.
|
private |
Definition at line 107 of file dashboard_client.cpp.
bool urcl::DashboardClient::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.
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 |
Definition at line 205 of file dashboard_client.cpp.
|
private |
Definition at line 45 of file dashboard_client.cpp.
|
private |
Definition at line 99 of file dashboard_client.cpp.
std::string urcl::DashboardClient::sendAndReceive | ( | const std::string & | command | ) |
Sends a command through the socket and waits for an answer.
command | Command that will be sent to the server. |
UrException | if no response was read from the dashboard server |
Definition at line 130 of file dashboard_client.cpp.
bool urcl::DashboardClient::sendRequest | ( | const std::string & | command, |
const std::string & | expected | ||
) |
Sends command and compare it with the expected answer.
command | Command that will be sent to the server. |
expected | Expected response |
Definition at line 152 of file dashboard_client.cpp.
std::string urcl::DashboardClient::sendRequestString | ( | const std::string & | command, |
const std::string & | expected | ||
) |
Sends command and compare it with the expected answer.
command | Command that will be sent to the server. |
expected | Expected response |
UrException | if the received answer does not match the expected one. |
Definition at line 164 of file dashboard_client.cpp.
bool urcl::DashboardClient::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
command | Command that will be sent to the server |
expected | Expected replay |
timeout | Timeout to wait before the command is considered failed. |
Definition at line 176 of file dashboard_client.cpp.
const int urcl::DashboardClient::DASHBOARD_SERVER_PORT = 29999 |
Definition at line 58 of file dashboard_client.h.
|
private |
Definition at line 455 of file dashboard_client.h.
|
private |
Definition at line 454 of file dashboard_client.h.
|
private |
Definition at line 456 of file dashboard_client.h.
|
private |
Definition at line 457 of file dashboard_client.h.