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 // 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_WRITER_H_INCLUDED
30 #define UR_CLIENT_LIBRARY_RTDE_WRITER_H_INCLUDED
31 
38 #include <thread>
39 #include <mutex>
40 
41 namespace urcl
42 {
43 namespace rtde_interface
44 {
51 {
52 public:
53  RTDEWriter() = delete;
60  RTDEWriter(comm::URStream<RTDEPackage>* stream, const std::vector<std::string>& recipe);
61 
63  {
64  running_ = false;
65  if (writer_thread_.joinable())
66  {
67  writer_thread_.join();
68  }
69  }
76  void init(uint8_t recipe_id);
80  void run();
81 
89  bool sendSpeedSlider(double speed_slider_fraction);
98  bool sendStandardDigitalOutput(uint8_t output_pin, bool value);
107  bool sendConfigurableDigitalOutput(uint8_t output_pin, bool value);
116  bool sendToolDigitalOutput(uint8_t output_pin, bool value);
128  bool sendStandardAnalogOutput(uint8_t output_pin, double value,
130 
139  bool sendInputBitRegister(uint32_t register_id, bool value);
140 
149  bool sendInputIntRegister(uint32_t register_id, int32_t value);
150 
159  bool sendInputDoubleRegister(uint32_t register_id, double value);
160 
161 private:
162  uint8_t pinToMask(uint8_t pin);
164  std::vector<std::string> recipe_;
165  uint8_t recipe_id_;
167  std::thread writer_thread_;
168  bool running_;
170  std::mutex package_mutex_;
171 };
172 
173 } // namespace rtde_interface
174 } // namespace urcl
175 
176 #endif // UR_CLIENT_LIBRARY_RTDE_WRITER_H_INCLUDED
urcl::rtde_interface::RTDEWriter
The RTDEWriter class offers an abstraction layer to send data to the robot via the RTDE interface....
Definition: rtde_writer.h:50
data_package.h
urcl::comm::URStream
The stream is an abstraction of the TCPSocket that offers reading a full UR data package out of the s...
Definition: stream.h:40
urcl::rtde_interface::RTDEWriter::pinToMask
uint8_t pinToMask(uint8_t pin)
Definition: rtde_writer.cpp:250
urcl::rtde_interface::RTDEWriter::writer_thread_
std::thread writer_thread_
Definition: rtde_writer.h:167
urcl::rtde_interface::DataPackage
The DataPackage class handles communication in the form of RTDE data packages both to and from the ro...
Definition: data_package.h:60
urcl::rtde_interface::RTDEWriter::sendSpeedSlider
bool sendSpeedSlider(double speed_slider_fraction)
Creates a package to request setting a new value for the speed slider.
Definition: rtde_writer.cpp:66
urcl::rtde_interface::RTDEWriter::RTDEWriter
RTDEWriter()=delete
moodycamel::BlockingReaderWriterQueue
Definition: readerwriterqueue.h:691
urcl::rtde_interface::RTDEWriter::queue_
moodycamel::BlockingReaderWriterQueue< std::unique_ptr< DataPackage > > queue_
Definition: rtde_writer.h:166
urcl
Definition: bin_parser.h:36
urcl::rtde_interface::RTDEWriter::sendToolDigitalOutput
bool sendToolDigitalOutput(uint8_t output_pin, bool value)
Creates a package to request setting a new value for one of the tool output pins.
Definition: rtde_writer.cpp:170
urcl::rtde_interface::RTDEWriter::recipe_
std::vector< std::string > recipe_
Definition: rtde_writer.h:164
urcl::rtde_interface::RTDEWriter::sendInputIntRegister
bool sendInputIntRegister(uint32_t register_id, int32_t value)
Creates a package to request setting a new value for an input_int_register.
Definition: rtde_writer.cpp:286
datatypes.h
urcl::rtde_interface::RTDEWriter::sendInputDoubleRegister
bool sendInputDoubleRegister(uint32_t register_id, double value)
Creates a package to request setting a new value for an input_double_register.
Definition: rtde_writer.cpp:312
urcl::rtde_interface::RTDEWriter::package_
DataPackage package_
Definition: rtde_writer.h:169
urcl::rtde_interface::RTDEWriter::sendConfigurableDigitalOutput
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.
Definition: rtde_writer.cpp:132
stream.h
rtde_package.h
urcl::rtde_interface::RTDEWriter::run
void run()
The writer thread loop, continually serializing and sending packages to the robot.
Definition: rtde_writer.cpp:48
urcl::rtde_interface::RTDEWriter::running_
bool running_
Definition: rtde_writer.h:168
urcl::rtde_interface::RTDEWriter::package_mutex_
std::mutex package_mutex_
Definition: rtde_writer.h:170
urcl::rtde_interface::RTDEWriter::sendStandardDigitalOutput
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:95
urcl::rtde_interface::RTDEWriter::init
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:40
urcl::rtde_interface::RTDEWriter::stream_
comm::URStream< RTDEPackage > * stream_
Definition: rtde_writer.h:163
package_header.h
urcl::AnalogOutputType::SET_ON_TEACH_PENDANT
@ SET_ON_TEACH_PENDANT
urcl::rtde_interface::RTDEWriter::~RTDEWriter
~RTDEWriter()
Definition: rtde_writer.h:62
urcl::rtde_interface::RTDEWriter::recipe_id_
uint8_t recipe_id_
Definition: rtde_writer.h:165
urcl::rtde_interface::RTDEWriter::sendStandardAnalogOutput
bool sendStandardAnalogOutput(uint8_t output_pin, double value, const AnalogOutputType type=AnalogOutputType::SET_ON_TEACH_PENDANT)
Creates a package to request setting a new value for one of the standard analog output pins.
Definition: rtde_writer.cpp:207
urcl::rtde_interface::RTDEWriter::sendInputBitRegister
bool sendInputBitRegister(uint32_t register_id, bool value)
Creates a package to request setting a new value for an input_bit_register.
Definition: rtde_writer.cpp:260
readerwriterqueue.h
urcl::AnalogOutputType
AnalogOutputType
Definition: datatypes.h:83


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