tool_communication.h
Go to the documentation of this file.
1 
2 // this is for emacs file handling -*- mode: c++; indent-tabs-mode: nil -*-
3 
4 // -- BEGIN LICENSE BLOCK ----------------------------------------------
5 // Copyright 2019 FZI Forschungszentrum Informatik
6 // Created on behalf of Universal Robots A/S
7 //
8 // Licensed under the Apache License, Version 2.0 (the "License");
9 // you may not use this file except in compliance with the License.
10 // You may obtain a copy of the License at
11 //
12 // http://www.apache.org/licenses/LICENSE-2.0
13 //
14 // Unless required by applicable law or agreed to in writing, software
15 // distributed under the License is distributed on an "AS IS" BASIS,
16 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 // See the License for the specific language governing permissions and
18 // limitations under the License.
19 // -- END LICENSE BLOCK ------------------------------------------------
20 
21 //----------------------------------------------------------------------
28 //----------------------------------------------------------------------
29 
30 #ifndef UR_CLIENT_LIBRARY_UR_TOOL_COMMUNICATION_H_INCLUDED
31 #define UR_CLIENT_LIBRARY_UR_TOOL_COMMUNICATION_H_INCLUDED
32 
34 #include <set>
35 
36 namespace urcl
37 {
41 enum class ToolVoltage : int
42 {
43  OFF = 0,
44  _12V = 12,
45  _24V = 24
46 };
47 
51 enum class Parity : int
52 {
53  NONE = 0,
54  ODD = 1,
55  EVEN = 2
56 };
57 
63 template <class T>
64 class Limited
65 {
66 public:
67  Limited() = delete;
68  ~Limited() = default;
69 
70  using Datatype = T;
71 
78  Limited(const T lower, const T upper) : lower_(lower), upper_(upper)
79  {
80  data_ = lower_;
81  }
82 
90  void setData(const T data)
91  {
92  if (data >= lower_ && data <= upper_)
93  {
94  data_ = data;
95  }
96  else
97  {
98  throw std::runtime_error("Given data is out of range");
99  }
100  }
101 
105  T getData() const
106  {
107  return data_;
108  }
109 
110 private:
111  T data_;
112  const T lower_;
113  const T upper_;
114 };
115 
120 {
121 public:
122  ToolCommSetup();
123  ~ToolCommSetup() = default;
124 
128 
133  void setToolVoltage(const ToolVoltage tool_voltage)
134  {
135  tool_voltage_ = tool_voltage;
136  }
137 
142  {
143  return tool_voltage_;
144  }
145 
150  void setParity(const Parity parity)
151  {
152  parity_ = parity;
153  }
158  {
159  return parity_;
160  }
161 
168  void setBaudRate(const uint32_t baud_rate);
172  uint32_t getBaudRate() const
173  {
174  return baud_rate_;
175  };
176 
183  void setStopBits(const StopBitsT::Datatype stop_bits)
184  {
185  stop_bits_.setData(stop_bits);
186  }
191  {
192  return stop_bits_.getData();
193  }
194 
201  void setRxIdleChars(const RxIdleCharsT::Datatype rx_idle_chars)
202  {
203  rx_idle_chars_.setData(rx_idle_chars);
204  }
209  {
210  return rx_idle_chars_.getData();
211  }
212 
219  void setTxIdleChars(const TxIdleCharsT::Datatype tx_idle_chars)
220  {
221  tx_idle_chars_.setData(tx_idle_chars);
222  }
227  {
228  return tx_idle_chars_.getData();
229  }
230 
231 private:
232  const std::set<uint32_t> baud_rates_allowed_{ 9600,
233  19200,
234  38400,
235  57600,
236  115200,
237  static_cast<uint32_t>(1e6),
238  static_cast<uint32_t>(2e6),
239  static_cast<uint32_t>(5e6) };
240 
243  uint32_t baud_rate_;
247 };
248 } // namespace urcl
249 #endif // ifndef UR_CLIENT_LIBRARY_UR_TOOL_COMMUNICATION_H_INCLUDED
urcl::ToolCommSetup
Class holding a tool communication configuration.
Definition: tool_communication.h:119
urcl::ToolCommSetup::ToolCommSetup
ToolCommSetup()
Definition: tool_communication.cpp:33
urcl::ToolCommSetup::getToolVoltage
ToolVoltage getToolVoltage() const
Return the tool voltage currently stored.
Definition: tool_communication.h:141
urcl::Limited::upper_
const T upper_
Definition: tool_communication.h:113
urcl::ToolCommSetup::baud_rates_allowed_
const std::set< uint32_t > baud_rates_allowed_
Definition: tool_communication.h:232
urcl::Parity::NONE
@ NONE
types.h
urcl::ToolCommSetup::~ToolCommSetup
~ToolCommSetup()=default
urcl::ToolCommSetup::rx_idle_chars_
RxIdleCharsT rx_idle_chars_
Definition: tool_communication.h:245
urcl::ToolCommSetup::baud_rate_
uint32_t baud_rate_
Definition: tool_communication.h:243
urcl::Parity
Parity
Possible values for th parity flag.
Definition: tool_communication.h:51
urcl::ToolCommSetup::getParity
Parity getParity() const
Return the parity currently stored.
Definition: tool_communication.h:157
urcl::ToolVoltage
ToolVoltage
Possible values for the tool voltage.
Definition: tool_communication.h:41
urcl
Definition: bin_parser.h:36
urcl::ToolCommSetup::tx_idle_chars_
TxIdleCharsT tx_idle_chars_
Definition: tool_communication.h:246
urcl::ToolCommSetup::getRxIdleChars
RxIdleCharsT::Datatype getRxIdleChars() const
Return the number of rx idle chars currently stored.
Definition: tool_communication.h:208
urcl::Limited::setData
void setData(const T data)
Set the data field with a given value.
Definition: tool_communication.h:90
urcl::Limited::Limited
Limited(const T lower, const T upper)
Create a new Limited object.
Definition: tool_communication.h:78
urcl::ToolCommSetup::setParity
void setParity(const Parity parity)
Setup the tool communication parity that will be configured on the robot. This will not immediately c...
Definition: tool_communication.h:150
urcl::Parity::ODD
@ ODD
urcl::ToolCommSetup::tool_voltage_
ToolVoltage tool_voltage_
Definition: tool_communication.h:241
urcl::Limited::getData
T getData() const
Returns the data stored in this object.
Definition: tool_communication.h:105
urcl::Limited::Limited
Limited()=delete
urcl::Limited< float >::Datatype
float Datatype
Definition: tool_communication.h:70
urcl::ToolVoltage::_24V
@ _24V
24V
urcl::ToolCommSetup::setBaudRate
void setBaudRate(const uint32_t baud_rate)
Setup the tool communication baud rate that will be configured on the robot. This will not immediatel...
Definition: tool_communication.cpp:43
urcl::ToolCommSetup::setStopBits
void setStopBits(const StopBitsT::Datatype stop_bits)
Setup the tool communication number of stop bits that will be configured on the robot....
Definition: tool_communication.h:183
urcl::Limited::lower_
const T lower_
Definition: tool_communication.h:112
urcl::ToolCommSetup::getBaudRate
uint32_t getBaudRate() const
Return the baud rate currently stored.
Definition: tool_communication.h:172
urcl::Limited::data_
T data_
Definition: tool_communication.h:111
urcl::ToolCommSetup::parity_
Parity parity_
Definition: tool_communication.h:242
urcl::ToolCommSetup::setToolVoltage
void setToolVoltage(const ToolVoltage tool_voltage)
Setup the tool voltage that will be configured on the robot. This will not immediately change values ...
Definition: tool_communication.h:133
urcl::ToolCommSetup::getTxIdleChars
TxIdleCharsT::Datatype getTxIdleChars() const
Return the number of tx idle chars currently stored.
Definition: tool_communication.h:226
urcl::Limited::~Limited
~Limited()=default
urcl::ToolVoltage::_12V
@ _12V
12V
urcl::Limited
Helper class that represents a numeric value with a lower and an upper boundary.
Definition: tool_communication.h:64
urcl::ToolCommSetup::getStopBits
StopBitsT::Datatype getStopBits() const
Return the number of stop bits currently stored.
Definition: tool_communication.h:190
urcl::ToolCommSetup::setTxIdleChars
void setTxIdleChars(const TxIdleCharsT::Datatype tx_idle_chars)
Setup the tool communication number of idle chars for the tx channel that will be configured on the r...
Definition: tool_communication.h:219
urcl::ToolVoltage::OFF
@ OFF
0V
urcl::Parity::EVEN
@ EVEN
urcl::ToolCommSetup::stop_bits_
StopBitsT stop_bits_
Definition: tool_communication.h:244
urcl::ToolCommSetup::setRxIdleChars
void setRxIdleChars(const RxIdleCharsT::Datatype rx_idle_chars)
Setup the tool communication number of idle chars for the rx channel that will be configured on the r...
Definition: tool_communication.h:201


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