rtde_writer.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 //
6 // Licensed under the Apache License, Version 2.0 (the "License");
7 // you may not use this file except in compliance with the License.
8 // You may obtain a copy of the License at
9 //
10 // http://www.apache.org/licenses/LICENSE-2.0
11 //
12 // Unless required by applicable law or agreed to in writing, software
13 // distributed under the License is distributed on an "AS IS" BASIS,
14 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 // See the License for the specific language governing permissions and
16 // limitations under the License.
17 // -- END LICENSE BLOCK ------------------------------------------------
18 
19 //----------------------------------------------------------------------
26 //----------------------------------------------------------------------
27 
28 #ifndef UR_CLIENT_LIBRARY_RTDE_WRITER_H_INCLUDED
29 #define UR_CLIENT_LIBRARY_RTDE_WRITER_H_INCLUDED
30 
36 #include <thread>
37 #include <mutex>
38 
39 namespace urcl
40 {
41 namespace rtde_interface
42 {
49 {
50 public:
51  RTDEWriter() = delete;
58  RTDEWriter(comm::URStream<RTDEPackage>* stream, const std::vector<std::string>& recipe);
59 
61  {
62  running_ = false;
63  std::this_thread::sleep_for(std::chrono::seconds(5));
64  if (writer_thread_.joinable())
65  {
66  writer_thread_.join();
67  }
68  }
75  void init(uint8_t recipe_id);
79  void run();
80 
88  bool sendSpeedSlider(double speed_slider_fraction);
97  bool sendStandardDigitalOutput(uint8_t output_pin, bool value);
106  bool sendConfigurableDigitalOutput(uint8_t output_pin, bool value);
115  bool sendToolDigitalOutput(uint8_t output_pin, bool value);
124  bool sendStandardAnalogOutput(uint8_t output_pin, double value);
125 
134  bool sendInputBitRegister(uint32_t register_id, bool value);
135 
144  bool sendInputIntRegister(uint32_t register_id, int32_t value);
145 
154  bool sendInputDoubleRegister(uint32_t register_id, double value);
155 
156 private:
157  uint8_t pinToMask(uint8_t pin);
159  std::vector<std::string> recipe_;
160  uint8_t recipe_id_;
162  std::thread writer_thread_;
163  bool running_;
165  std::mutex package_mutex_;
166 };
167 
168 } // namespace rtde_interface
169 } // namespace urcl
170 
171 #endif // UR_CLIENT_LIBRARY_RTDE_WRITER_H_INCLUDED
bool sendStandardDigitalOutput(uint8_t output_pin, bool value)
Creates a package to request setting a new value for one of the standard digital output pins...
Definition: rtde_writer.cpp:85
void init(uint8_t recipe_id)
Starts the writer thread, which periodically clears the queue to write packages to the robot...
Definition: rtde_writer.cpp:39
bool sendInputIntRegister(uint32_t register_id, int32_t value)
Creates a package to request setting a new value for an input_int_register.
The stream is an abstraction of the TCPSocket that offers reading a full UR data package out of the s...
Definition: stream.h:42
comm::URStream< RTDEPackage > * stream_
Definition: rtde_writer.h:158
The RTDEWriter class offers an abstraction layer to send data to the robot via the RTDE interface...
Definition: rtde_writer.h:48
bool sendConfigurableDigitalOutput(uint8_t output_pin, bool value)
Creates a package to request setting a new value for one of the configurable digital output pins...
bool sendToolDigitalOutput(uint8_t output_pin, bool value)
Creates a package to request setting a new value for one of the tool output pins. ...
uint8_t pinToMask(uint8_t pin)
std::vector< std::string > recipe_
Definition: rtde_writer.h:159
void run()
The writer thread loop, continually serializing and sending packages to the robot.
Definition: rtde_writer.cpp:47
bool sendStandardAnalogOutput(uint8_t output_pin, double value)
Creates a package to request setting a new value for one of the standard analog output pins...
bool sendInputBitRegister(uint32_t register_id, bool value)
Creates a package to request setting a new value for an input_bit_register.
bool sendInputDoubleRegister(uint32_t register_id, double value)
Creates a package to request setting a new value for an input_double_register.
The DataPackage class handles communication in the form of RTDE data packages both to and from the ro...
Definition: data_package.h:59
moodycamel::BlockingReaderWriterQueue< std::unique_ptr< DataPackage > > queue_
Definition: rtde_writer.h:161
bool sendSpeedSlider(double speed_slider_fraction)
Creates a package to request setting a new value for the speed slider.
Definition: rtde_writer.cpp:65


ur_client_library
Author(s): Thomas Timm Andersen, Simon Rasmussen, Felix Exner, Lea Steffen, Tristan Schnell
autogenerated on Sun May 9 2021 02:16:26