rtde_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 
29 #ifndef UR_CLIENT_LIBRARY_RTDE_CLIENT_H_INCLUDED
30 #define UR_CLIENT_LIBRARY_RTDE_CLIENT_H_INCLUDED
31 
42 #include "ur_client_library/log.h"
44 
45 static const int UR_RTDE_PORT = 30004;
46 static const std::string PIPELINE_NAME = "RTDE Data Pipeline";
47 
48 namespace urcl
49 {
50 namespace rtde_interface
51 {
52 static const uint16_t MAX_RTDE_PROTOCOL_VERSION = 2;
53 static const unsigned MAX_REQUEST_RETRIES = 5;
54 static const unsigned MAX_INITIALIZE_ATTEMPTS = 10;
55 
57 {
58  IS_POWER_ON = 0,
62 };
63 
65 {
66  IS_NORMAL_MODE = 0,
67  IS_REDUCED_MODE = 1,
69  IS_RECOVERY_MODE = 3,
74  IS_VIOLATION = 8,
75  IS_FAULT = 9,
77 };
78 
79 enum class ClientState
80 {
81  UNINITIALIZED = 0,
82  INITIALIZING = 1,
83  INITIALIZED = 2,
84  RUNNING = 3,
85  PAUSED = 4
86 };
87 
93 {
94 public:
95  RTDEClient() = delete;
106  RTDEClient(std::string robot_ip, comm::INotifier& notifier, const std::string& output_recipe_file,
107  const std::string& input_recipe_file, double target_frequency = 0.0);
108  ~RTDEClient();
115  bool init();
121  bool start();
127  bool pause();
135  std::unique_ptr<rtde_interface::DataPackage> getDataPackage(std::chrono::milliseconds timeout);
136 
142  double getMaxFrequency() const
143  {
144  return max_frequency_;
145  }
146 
152  double getTargetFrequency() const
153  {
154  return target_frequency_;
155  }
156 
163  {
164  return urcontrol_version_;
165  }
166 
172  std::string getIP() const;
173 
180  RTDEWriter& getWriter();
181 
187  std::vector<std::string> getOutputRecipe()
188  {
189  return output_recipe_;
190  }
191 
192 private:
194  std::vector<std::string> output_recipe_;
195  std::vector<std::string> input_recipe_;
200 
202 
205 
207 
208  constexpr static const double CB3_MAX_FREQUENCY = 125.0;
209  constexpr static const double URE_MAX_FREQUENCY = 500.0;
210 
211  std::vector<std::string> readRecipe(const std::string& recipe_file);
212 
213  void setupCommunication();
214  bool negotiateProtocolVersion(const uint16_t protocol_version);
215  void queryURControlVersion();
216  void setupOutputs(const uint16_t protocol_version);
217  void setupInputs();
218  void disconnect();
219 
230  bool isRobotBooted();
231  bool sendStart();
232  bool sendPause();
233 
242  std::vector<std::string> splitVariableTypes(const std::string& variable_types) const;
243 };
244 
245 } // namespace rtde_interface
246 } // namespace urcl
247 
248 #endif // UR_CLIENT_LIBRARY_RTDE_CLIENT_H_INCLUDED
static const unsigned MAX_REQUEST_RETRIES
Definition: rtde_client.h:53
comm::URProducer< RTDEPackage > prod_
Definition: rtde_client.h:197
std::vector< std::string > output_recipe_
Definition: rtde_client.h:194
The stream is an abstraction of the TCPSocket that offers reading a full UR data package out of the s...
Definition: stream.h:42
VersionInformation getVersion()
Getter for the UR control version received from the robot.
Definition: rtde_client.h:162
double getTargetFrequency() const
Getter for the target frequency that the robot will publish RTDE data packages with.
Definition: rtde_client.h:152
double getMaxFrequency() const
Getter for the maximum frequency the robot can publish RTDE data packages with.
Definition: rtde_client.h:142
std::vector< std::string > input_recipe_
Definition: rtde_client.h:195
Struct containing a robot&#39;s version information.
static const std::string PIPELINE_NAME
Definition: rtde_client.h:46
std::vector< std::string > getOutputRecipe()
Getter for the RTDE output recipe.
Definition: rtde_client.h:187
The RTDEWriter class offers an abstraction layer to send data to the robot via the RTDE interface...
Definition: rtde_writer.h:49
comm::Pipeline< RTDEPackage > pipeline_
Definition: rtde_client.h:198
Parent class for notifiers.
Definition: pipeline.h:210
The RTDE specific parser. Interprets a given byte stream as serialized RTDE packages and parses it ac...
Definition: rtde_parser.h:45
comm::URStream< RTDEPackage > stream_
Definition: rtde_client.h:193
static const unsigned MAX_INITIALIZE_ATTEMPTS
Definition: rtde_client.h:54
The RTDEClient class manages communication over the RTDE interface. It contains the RTDE handshake an...
Definition: rtde_client.h:92
static const uint16_t MAX_RTDE_PROTOCOL_VERSION
Definition: rtde_client.h:52
The Pipepline manages the production and optionally consumption of packages. Cyclically the producer ...
Definition: pipeline.h:235
A general producer for URPackages. Implements funcionality to produce packages by reading and parsing...
Definition: producer.h:40
VersionInformation urcontrol_version_
Definition: rtde_client.h:201
static const int UR_RTDE_PORT
Definition: rtde_client.h:45


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