dashboard_client.h
Go to the documentation of this file.
1 // this is for emacs file handling -*- mode: c++; indent-tabs-mode: nil -*-
2 
3 // -- BEGIN LICENSE BLOCK ----------------------------------------------
4 // Copyright 2019 FZI Forschungszentrum Informatik
5 // Created on behalf of Universal Robots A/S
6 //
7 // Licensed under the Apache License, Version 2.0 (the "License");
8 // you may not use this file except in compliance with the License.
9 // You may obtain a copy of the License at
10 //
11 // http://www.apache.org/licenses/LICENSE-2.0
12 //
13 // Unless required by applicable law or agreed to in writing, software
14 // distributed under the License is distributed on an "AS IS" BASIS,
15 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 // See the License for the specific language governing permissions and
17 // limitations under the License.
18 // -- END LICENSE BLOCK ------------------------------------------------
19 
20 //----------------------------------------------------------------------
27 //----------------------------------------------------------------------
28 #ifndef UR_ROBOT_DRIVER_DASHBOARD_CLIENT_DASHBOARD_CLIENT_H_INCLUDED
29 #define UR_ROBOT_DRIVER_DASHBOARD_CLIENT_DASHBOARD_CLIENT_H_INCLUDED
30 
33 
34 namespace urcl
35 {
47 {
48 public:
54  DashboardClient(const std::string& host);
55  DashboardClient() = delete;
56  virtual ~DashboardClient() = default;
57 
58  static constexpr int DASHBOARD_SERVER_PORT = 29999;
59 
69  bool connect(const size_t max_num_tries = 0,
70  const std::chrono::milliseconds reconnection_time = std::chrono::seconds(10));
71 
75  void disconnect();
76 
86  std::string sendAndReceive(const std::string& command);
87 
96  bool sendRequest(const std::string& command, const std::string& expected);
97 
108  std::string sendRequestString(const std::string& command, const std::string& expected);
109 
119  bool waitForReply(const std::string& command, const std::string& expected,
120  std::chrono::duration<double> timeout = std::chrono::seconds(30));
121 
135  bool retryCommand(const std::string& requestCommand, const std::string& requestExpectedResponse,
136  const std::string& waitRequest, const std::string& waitExpectedResponse,
137  const std::chrono::duration<double> timeout,
138  const std::chrono::duration<double> retry_period = std::chrono::seconds(1));
139 
145  bool commandPowerOff();
146 
155  bool commandPowerOn(const std::chrono::duration<double> timeout = std::chrono::seconds(300));
156 
162  bool commandBrakeRelease();
163 
171  bool commandLoadProgram(const std::string& program_file_name);
172 
180  bool commandLoadInstallation(const std::string& installation_file_name);
181 
187  bool commandPlay();
188 
194  bool commandPause();
195 
201  bool commandStop();
202 
208  bool commandClosePopup();
209 
216 
222  bool commandRestartSafety();
223 
230 
236  bool commandShutdown();
237 
243  bool commandQuit();
244 
250  bool commandRunning();
251 
257  bool commandIsProgramSaved();
258 
267 
275  bool commandPopup(const std::string& popup_text);
276 
284  bool commandAddToLog(const std::string& log_text);
285 
293  bool commandPolyscopeVersion(std::string& polyscope_version);
294 
302  bool commandGetRobotModel(std::string& robot_model);
303 
311  bool commandGetSerialNumber(std::string& serial_number);
312 
320  bool commandRobotMode(std::string& robot_mode);
321 
329  bool commandGetLoadedProgram(std::string& loaded_program);
330 
338  bool commandSafetyMode(std::string& safety_mode);
339 
347  bool commandSafetyStatus(std::string& safety_status);
348 
356  bool commandProgramState(std::string& program_state);
357 
367  bool commandGetOperationalMode(std::string& operational_mode);
368 
378  bool commandSetOperationalMode(const std::string& operational_mode);
379 
388 
398  bool commandSetUserRole(const std::string& user_role);
399 
409  bool commandGetUserRole(std::string& user_role);
410 
418  bool commandGenerateFlightReport(const std::string& report_type);
419 
428  bool commandGenerateSupportFile(const std::string& dir_path);
429 
435  bool commandSaveLog();
436 
446  void assertVersion(const std::string& e_series_min_ver, const std::string& cb3_min_ver,
447  const std::string& required_call);
448 
455  timeval getConfiguredReceiveTimeout() const;
456 
457 protected:
459 
460 private:
461  bool send(const std::string& text);
462  std::string read();
463  void rtrim(std::string& str, const std::string& chars = "\t\n\v\f\r ");
464 
465  std::string host_;
466  int port_;
467  std::mutex write_mutex_;
468 };
469 } // namespace urcl
470 #endif // ifndef UR_ROBOT_DRIVER_DASHBOARD_CLIENT_DASHBOARD_CLIENT_H_INCLUDED
urcl::comm::TCPSocket
Class for TCP socket abstraction.
Definition: tcp_socket.h:48
urcl::DashboardClient::commandRestartSafety
bool commandRestartSafety()
Send Restart Safety command.
Definition: dashboard_client.cpp:298
urcl::DashboardClient::commandPlay
bool commandPlay()
Send Play program command.
Definition: dashboard_client.cpp:268
urcl::DashboardClient::commandSetOperationalMode
bool commandSetOperationalMode(const std::string &operational_mode)
Send Set operational mode command (Only available for e-series)
Definition: dashboard_client.cpp:429
urcl::DashboardClient::assertVersion
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.
Definition: dashboard_client.cpp:488
version_information.h
urcl::DashboardClient::commandIsProgramSaved
bool commandIsProgramSaved()
Send "Is program saved" request command.
Definition: dashboard_client.cpp:329
urcl::DashboardClient::commandGetSerialNumber
bool commandGetSerialNumber(std::string &serial_number)
Get Serial number.
Definition: dashboard_client.cpp:373
urcl::DashboardClient::polyscope_version_
VersionInformation polyscope_version_
Definition: dashboard_client.h:458
urcl::DashboardClient::commandClosePopup
bool commandClosePopup()
Send Close popup command.
Definition: dashboard_client.cpp:286
urcl
Definition: bin_parser.h:36
urcl::DashboardClient::commandStop
bool commandStop()
Send Stop program command.
Definition: dashboard_client.cpp:280
urcl::DashboardClient::commandGenerateSupportFile
bool commandGenerateSupportFile(const std::string &dir_path)
Send Generate support file command.
Definition: dashboard_client.cpp:469
urcl::DashboardClient::commandSetUserRole
bool commandSetUserRole(const std::string &user_role)
Send Set user role command (Only available for CB3)
Definition: dashboard_client.cpp:442
urcl::DashboardClient::commandUnlockProtectiveStop
bool commandUnlockProtectiveStop()
Send Unlock Protective stop popup command.
Definition: dashboard_client.cpp:304
urcl::DashboardClient::write_mutex_
std::mutex write_mutex_
Definition: dashboard_client.h:467
urcl::DashboardClient::retryCommand
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.
Definition: dashboard_client.cpp:213
urcl::DashboardClient::send
bool send(const std::string &text)
Definition: dashboard_client.cpp:106
urcl::DashboardClient::waitForReply
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
Definition: dashboard_client.cpp:184
urcl::DashboardClient::rtrim
void rtrim(std::string &str, const std::string &chars="\t\n\v\f\r ")
Definition: dashboard_client.cpp:49
urcl::DashboardClient::DASHBOARD_SERVER_PORT
static constexpr int DASHBOARD_SERVER_PORT
Definition: dashboard_client.h:58
urcl::DashboardClient::port_
int port_
Definition: dashboard_client.h:466
urcl::DashboardClient::commandLoadProgram
bool commandLoadProgram(const std::string &program_file_name)
Send Load program command.
Definition: dashboard_client.cpp:250
urcl::DashboardClient::commandShutdown
bool commandShutdown()
Send Shutdown command.
Definition: dashboard_client.cpp:310
urcl::DashboardClient::commandGetRobotModel
bool commandGetRobotModel(std::string &robot_model)
Get Robot model.
Definition: dashboard_client.cpp:365
urcl::DashboardClient::commandPopup
bool commandPopup(const std::string &popup_text)
Send popup command.
Definition: dashboard_client.cpp:343
urcl::DashboardClient::commandBrakeRelease
bool commandBrakeRelease()
Send Brake release command.
Definition: dashboard_client.cpp:244
urcl::DashboardClient::commandAddToLog
bool commandAddToLog(const std::string &log_text)
Send text to log.
Definition: dashboard_client.cpp:349
urcl::DashboardClient::host_
std::string host_
Definition: dashboard_client.h:465
urcl::VersionInformation
Struct containing a robot's version information.
Definition: version_information.h:42
urcl::DashboardClient::~DashboardClient
virtual ~DashboardClient()=default
urcl::DashboardClient::sendRequest
bool sendRequest(const std::string &command, const std::string &expected)
Sends command and compare it with the expected answer.
Definition: dashboard_client.cpp:159
urcl::DashboardClient::sendAndReceive
std::string sendAndReceive(const std::string &command)
Sends a command through the socket and waits for an answer.
Definition: dashboard_client.cpp:137
urcl::DashboardClient::commandQuit
bool commandQuit()
Send Quit command.
Definition: dashboard_client.cpp:316
urcl::DashboardClient::commandProgramState
bool commandProgramState(std::string &program_state)
Get Program state.
Definition: dashboard_client.cpp:413
urcl::DashboardClient::commandSaveLog
bool commandSaveLog()
Flush the polyscope log to the log_history.txt file.
Definition: dashboard_client.cpp:482
urcl::DashboardClient::read
std::string read()
Definition: dashboard_client.cpp:114
urcl::DashboardClient::commandClearOperationalMode
bool commandClearOperationalMode()
Send Clear operational mode command.
Definition: dashboard_client.cpp:436
urcl::DashboardClient::commandRunning
bool commandRunning()
Send Running command.
Definition: dashboard_client.cpp:322
urcl::DashboardClient::getConfiguredReceiveTimeout
timeval getConfiguredReceiveTimeout() const
Gets the configured receive timeout. If receive timeout is unconfigured "normal" socket timeout of 1 ...
Definition: dashboard_client.cpp:519
urcl::DashboardClient::commandLoadInstallation
bool commandLoadInstallation(const std::string &installation_file_name)
Send Load installation command.
Definition: dashboard_client.cpp:261
urcl::DashboardClient::disconnect
void disconnect()
Makes sure no connection to the dashboard server is held inside the object.
Definition: dashboard_client.cpp:100
urcl::DashboardClient::commandGetLoadedProgram
bool commandGetLoadedProgram(std::string &loaded_program)
Get Loaded Program.
Definition: dashboard_client.cpp:389
urcl::DashboardClient
This class is a wrapper around the dashboard server.
Definition: dashboard_client.h:46
urcl::DashboardClient::commandGenerateFlightReport
bool commandGenerateFlightReport(const std::string &report_type)
Send Generate flight report command.
Definition: dashboard_client.cpp:456
urcl::DashboardClient::connect
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.
Definition: dashboard_client.cpp:54
urcl::DashboardClient::commandSafetyStatus
bool commandSafetyStatus(std::string &safety_status)
Get Safety status.
Definition: dashboard_client.cpp:405
urcl::DashboardClient::commandGetUserRole
bool commandGetUserRole(std::string &user_role)
Send Get user role command (Only available for CB3)
Definition: dashboard_client.cpp:448
urcl::DashboardClient::commandPause
bool commandPause()
Send Pause program command.
Definition: dashboard_client.cpp:274
urcl::DashboardClient::DashboardClient
DashboardClient()=delete
urcl::DashboardClient::commandPolyscopeVersion
bool commandPolyscopeVersion(std::string &polyscope_version)
Get Polyscope version.
Definition: dashboard_client.cpp:355
urcl::DashboardClient::commandPowerOn
bool commandPowerOn(const std::chrono::duration< double > timeout=std::chrono::seconds(300))
Send Power on command.
Definition: dashboard_client.cpp:238
urcl::DashboardClient::commandPowerOff
bool commandPowerOff()
Send Power off command.
Definition: dashboard_client.cpp:232
urcl::DashboardClient::commandGetOperationalMode
bool commandGetOperationalMode(std::string &operational_mode)
Get Operational mode.
Definition: dashboard_client.cpp:421
urcl::DashboardClient::commandCloseSafetyPopup
bool commandCloseSafetyPopup()
Send Close safety popup command.
Definition: dashboard_client.cpp:292
urcl::DashboardClient::commandSafetyMode
bool commandSafetyMode(std::string &safety_mode)
Get Safety mode.
Definition: dashboard_client.cpp:397
urcl::DashboardClient::commandRobotMode
bool commandRobotMode(std::string &robot_mode)
Get Robot mode.
Definition: dashboard_client.cpp:381
urcl::DashboardClient::sendRequestString
std::string sendRequestString(const std::string &command, const std::string &expected)
Sends command and compare it with the expected answer.
Definition: dashboard_client.cpp:172
tcp_socket.h
urcl::DashboardClient::commandIsInRemoteControl
bool commandIsInRemoteControl()
Send "Is in remote control" query command.
Definition: dashboard_client.cpp:335


ur_client_library
Author(s): Thomas Timm Andersen, Simon Rasmussen, Felix Exner, Lea Steffen, Tristan Schnell
autogenerated on Mon May 26 2025 02:35:58