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  const int DASHBOARD_SERVER_PORT = 29999;
59 
65  bool connect();
66 
70  void disconnect();
71 
81  std::string sendAndReceive(const std::string& command);
82 
91  bool sendRequest(const std::string& command, const std::string& expected);
92 
103  std::string sendRequestString(const std::string& command, const std::string& expected);
104 
114  bool waitForReply(const std::string& command, const std::string& expected,
115  std::chrono::duration<double> timeout = std::chrono::seconds(30));
116 
130  bool retryCommand(const std::string& requestCommand, const std::string& requestExpectedResponse,
131  const std::string& waitRequest, const std::string& waitExpectedResponse,
132  const std::chrono::duration<double> timeout,
133  const std::chrono::duration<double> retry_period = std::chrono::seconds(1));
134 
140  bool commandPowerOff();
141 
150  bool commandPowerOn(const std::chrono::duration<double> timeout = std::chrono::seconds(300));
151 
157  bool commandBrakeRelease();
158 
166  bool commandLoadProgram(const std::string& program_file_name);
167 
175  bool commandLoadInstallation(const std::string& installation_file_name);
176 
182  bool commandPlay();
183 
189  bool commandPause();
190 
196  bool commandStop();
197 
203  bool commandClosePopup();
204 
211 
217  bool commandRestartSafety();
218 
225 
231  bool commandShutdown();
232 
238  bool commandQuit();
239 
245  bool commandRunning();
246 
252  bool commandIsProgramSaved();
253 
262 
270  bool commandPopup(const std::string& popup_text);
271 
279  bool commandAddToLog(const std::string& log_text);
280 
288  bool commandPolyscopeVersion(std::string& polyscope_version);
289 
297  bool commandGetRobotModel(std::string& robot_model);
298 
306  bool commandGetSerialNumber(std::string& serial_number);
307 
315  bool commandRobotMode(std::string& robot_mode);
316 
324  bool commandGetLoadedProgram(std::string& loaded_program);
325 
333  bool commandSafetyMode(std::string& safety_mode);
334 
342  bool commandSafetyStatus(std::string& safety_status);
343 
351  bool commandProgramState(std::string& program_state);
352 
362  bool commandGetOperationalMode(std::string& operational_mode);
363 
373  bool commandSetOperationalMode(const std::string& operational_mode);
374 
383 
393  bool commandSetUserRole(const std::string& user_role);
394 
404  bool commandGetUserRole(std::string& user_role);
405 
413  bool commandGenerateFlightReport(const std::string& report_type);
414 
423  bool commandGenerateSupportFile(const std::string& dir_path);
424 
430  bool commandSaveLog();
431 
432 protected:
433  virtual bool open(int socket_fd, struct sockaddr* address, size_t address_len)
434  {
435  return ::connect(socket_fd, address, address_len) == 0;
436  }
437 
438 private:
448  void assertVersion(const std::string& e_series_min_ver, const std::string& cb3_min_ver,
449  const std::string& required_call);
450  bool send(const std::string& text);
451  std::string read();
452  void rtrim(std::string& str, const std::string& chars = "\t\n\v\f\r ");
453 
455  std::string host_;
456  int port_;
457  std::mutex write_mutex_;
458 };
459 } // namespace urcl
460 #endif // ifndef UR_ROBOT_DRIVER_DASHBOARD_CLIENT_DASHBOARD_CLIENT_H_INCLUDED
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&#39;s version is above the required version.
bool commandGetSerialNumber(std::string &serial_number)
Get Serial number.
std::string sendRequestString(const std::string &command, const std::string &expected)
Sends command and compare it with the expected answer.
bool commandSafetyMode(std::string &safety_mode)
Get Safety mode.
bool commandSetUserRole(const std::string &user_role)
Send Set user role command (Only available for CB3)
VersionInformation polyscope_version_
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
bool commandIsProgramSaved()
Send "Is program saved" request command.
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.
bool commandGetRobotModel(std::string &robot_model)
Get Robot model.
bool send(const std::string &text)
Struct containing a robot&#39;s version information.
bool commandUnlockProtectiveStop()
Send Unlock Protective stop popup command.
virtual ~DashboardClient()=default
bool commandClosePopup()
Send Close popup command.
bool commandStop()
Send Stop program command.
bool commandGenerateSupportFile(const std::string &dir_path)
Send Generate support file command.
bool commandBrakeRelease()
Send Brake release command.
std::string sendAndReceive(const std::string &command)
Sends a command through the socket and waits for an answer.
bool commandPopup(const std::string &popup_text)
Send popup command.
bool commandQuit()
Send Quit command.
void rtrim(std::string &str, const std::string &chars="\\\")
bool commandClearOperationalMode()
Send Clear operational mode command.
bool sendRequest(const std::string &command, const std::string &expected)
Sends command and compare it with the expected answer.
bool commandShutdown()
Send Shutdown command.
bool commandLoadProgram(const std::string &program_file_name)
Send Load program command.
bool commandProgramState(std::string &program_state)
Get Program state.
bool commandSafetyStatus(std::string &safety_status)
Get Safety status.
bool commandAddToLog(const std::string &log_text)
Send text to log.
bool connect()
Opens a connection to the dashboard server on the host as specified in the constructor.
bool commandSaveLog()
Flush the polyscope log to the log_history.txt file.
bool commandLoadInstallation(const std::string &installation_file_name)
Send Load installation command.
bool commandPowerOn(const std::chrono::duration< double > timeout=std::chrono::seconds(300))
Send Power on command.
bool commandPowerOff()
Send Power off command.
bool commandRunning()
Send Running command.
bool commandRobotMode(std::string &robot_mode)
Get Robot mode.
Class for TCP socket abstraction.
Definition: tcp_socket.h:48
bool commandGetLoadedProgram(std::string &loaded_program)
Get Loaded Program.
virtual bool open(int socket_fd, struct sockaddr *address, size_t address_len)
This class is a wrapper around the dashboard server.
void disconnect()
Makes sure no connection to the dashboard server is held inside the object.
bool commandIsInRemoteControl()
Send "Is in remote control" query command.
bool commandPause()
Send Pause program command.
bool commandRestartSafety()
Send Restart Safety command.
bool commandPlay()
Send Play program command.
bool commandGenerateFlightReport(const std::string &report_type)
Send Generate flight report command.
bool commandSetOperationalMode(const std::string &operational_mode)
Send Set operational mode command (Only available for e-series)
bool commandGetUserRole(std::string &user_role)
Send Get user role command (Only available for CB3)
bool commandGetOperationalMode(std::string &operational_mode)
Get Operational mode.
bool commandCloseSafetyPopup()
Send Close safety popup command.
bool commandPolyscopeVersion(std::string &polyscope_version)
Get Polyscope version.


ur_client_library
Author(s): Thomas Timm Andersen, Simon Rasmussen, Felix Exner, Lea Steffen, Tristan Schnell
autogenerated on Tue Jul 4 2023 02:09:47