Robotics Library  0.7.0
UniversalRobotsRealtime.h
Go to the documentation of this file.
1 //
2 // Copyright (c) 2009, Markus Rickert
3 // All rights reserved.
4 //
5 // Redistribution and use in source and binary forms, with or without
6 // modification, are permitted provided that the following conditions are met:
7 //
8 // * Redistributions of source code must retain the above copyright notice,
9 // this list of conditions and the following disclaimer.
10 // * Redistributions in binary form must reproduce the above copyright notice,
11 // this list of conditions and the following disclaimer in the documentation
12 // and/or other materials provided with the distribution.
13 //
14 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
15 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
18 // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
19 // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
20 // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
21 // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
22 // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
23 // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
24 // POSSIBILITY OF SUCH DAMAGE.
25 //
26 
27 #ifndef RL_HAL_UNIVERSALROBOTSREALTIME_H
28 #define RL_HAL_UNIVERSALROBOTSREALTIME_H
29 
30 #include <cstdint>
31 
32 #include "CartesianForceSensor.h"
35 #include "CyclicDevice.h"
36 #include "DigitalInputReader.h"
37 #include "DigitalOutputReader.h"
38 #include "Endian.h"
39 #include "JointCurrentSensor.h"
40 #include "JointPositionSensor.h"
41 #include "JointVelocitySensor.h"
42 #include "Socket.h"
43 
44 namespace rl
45 {
46  namespace hal
47  {
52  public CartesianForceSensor,
55  public CyclicDevice,
56  public DigitalInputReader,
57  public DigitalOutputReader,
58  public JointCurrentSensor,
59  public JointPositionSensor,
60  public JointVelocitySensor
61  {
62  public:
63  UniversalRobotsRealtime(const ::std::string& address);
64 
65  virtual ~UniversalRobotsRealtime();
66 
67  void close();
68 
69  void doScript(const ::std::string& script);
70 
72 
74 
76 
77  ::boost::dynamic_bitset<> getDigitalInput() const;
78 
79  bool getDigitalInput(const ::std::size_t& i) const;
80 
81  ::std::size_t getDigitalInputCount() const;
82 
83  ::boost::dynamic_bitset<> getDigitalOutput() const;
84 
85  bool getDigitalOutput(const ::std::size_t& i) const;
86 
87  ::std::size_t getDigitalOutputCount() const;
88 
90 
92 
94 
95  void open();
96 
97  void start();
98 
99  void step();
100 
101  void stop();
102 
103  protected:
104 
105  private:
106  struct Message
107  {
108  void unserialize(::std::uint8_t* ptr);
109 
110  template<typename T>
111  void unserialize(::std::uint8_t*& ptr, T& t)
112  {
113  ::std::memcpy(&t, ptr, sizeof(t));
115  ptr += sizeof(t);
116  }
117 
118  template<typename T, ::std::size_t N>
119  void unserialize(::std::uint8_t*& ptr, T (&t)[N])
120  {
121  for (::std::size_t i = 0; i < N; ++i)
122  {
123  this->unserialize(ptr, t[i]);
124  }
125  }
126 
127  ::std::uint32_t messageSize;
128 
129  double time;
130 
131  double qTarget[6];
132 
133  double qdTarget[6];
134 
135  double qddTarget[6];
136 
137  double iTarget[6];
138 
139  double mTarget[6];
140 
141  double qActual[6];
142 
143  double qdActual[6];
144 
145  double iActual[6];
146 
147  double iControl[6];
148 
149  double toolVectorActual[6];
150 
151  double tcpSpeedActual[6];
152 
153  double tcpForce[6];
154 
155  double toolVectorTarget[6];
156 
157  double tcpSpeedTarget[6];
158 
159  ::std::int64_t digitalInputBits;
160 
161  double motorTemperatures[6];
162 
164 
165  double testValue;
166 
167  double robotMode;
168 
169  double jointModes[6];
170 
171  double safetyMode;
172 
174 
175  double speedScaling;
176 
178 
179  double vMain;
180 
181  double vRobot;
182 
183  double iRobot;
184 
185  double vActual[6];
186 
187  ::std::int64_t digitalOutputs;
188 
189  double programState;
190  };
191 
192  Message in;
193 
194  Socket socket;
195  };
196 
197  template<>
198  void UniversalRobotsRealtime::Message::unserialize(::std::uint8_t*& ptr, ::std::int64_t& t);
199  }
200 }
201 
202 #endif // RL_HAL_UNIVERSALROBOTSREALTIME_H
rl::hal::UniversalRobotsRealtime::open
void open()
Definition: UniversalRobotsRealtime.cpp:204
rl::hal::UniversalRobotsRealtime::Message::safetyMode
double safetyMode
Definition: UniversalRobotsRealtime.h:167
rl::hal::UniversalRobotsRealtime::Message::tcpSpeedActual
double tcpSpeedActual[6]
Definition: UniversalRobotsRealtime.h:147
rl::hal::UniversalRobotsRealtime::close
void close()
Definition: UniversalRobotsRealtime.cpp:69
rl::hal::UniversalRobotsRealtime::Message::tcpForce
double tcpForce[6]
Definition: UniversalRobotsRealtime.h:149
rl::hal::JointPositionSensor
Definition: JointPositionSensor.h:39
rl::hal::Socket
Definition: Socket.h:48
rl::hal::JointVelocitySensor
Definition: JointVelocitySensor.h:39
rl::hal::UniversalRobotsRealtime::Message::unserialize
void unserialize(::std::uint8_t *ptr)
Definition: UniversalRobotsRealtime.cpp:283
rl::hal::UniversalRobotsRealtime::~UniversalRobotsRealtime
virtual ~UniversalRobotsRealtime()
Definition: UniversalRobotsRealtime.cpp:55
rl::math::Transform
::Eigen::Transform< Real, 3, ::Eigen::Affine > Transform
Rigid transformation in 3D.
Definition: Transform.h:46
rl::hal::UniversalRobotsRealtime::getCartesianVelocity
::rl::math::MotionVector getCartesianVelocity() const
Definition: UniversalRobotsRealtime.cpp:120
rl::hal::UniversalRobotsRealtime::Message::linearMomentumNorm
double linearMomentumNorm
Definition: UniversalRobotsRealtime.h:173
rl::hal::UniversalRobotsRealtime::socket
Socket socket
Definition: UniversalRobotsRealtime.h:190
rl::hal::UniversalRobotsRealtime::in
Message in
Definition: UniversalRobotsRealtime.h:188
rl::hal::UniversalRobotsRealtime::getCartesianPosition
::rl::math::Transform getCartesianPosition() const
Definition: UniversalRobotsRealtime.cpp:95
rl::hal::UniversalRobotsRealtime::Message::mTarget
double mTarget[6]
Definition: UniversalRobotsRealtime.h:135
rl::hal::UniversalRobotsRealtime::step
void step()
Definition: UniversalRobotsRealtime.cpp:219
rl::hal::UniversalRobotsRealtime::Message::vRobot
double vRobot
Definition: UniversalRobotsRealtime.h:177
rl::hal::UniversalRobotsRealtime::Message::qdTarget
double qdTarget[6]
Definition: UniversalRobotsRealtime.h:129
rl::hal::UniversalRobotsRealtime::getJointVelocity
::rl::math::Vector getJointVelocity() const
Definition: UniversalRobotsRealtime.cpp:191
rl::hal::UniversalRobotsRealtime::Message::programState
double programState
Definition: UniversalRobotsRealtime.h:185
rl::hal::UniversalRobotsRealtime::Message::qddTarget
double qddTarget[6]
Definition: UniversalRobotsRealtime.h:131
rl::hal::UniversalRobotsRealtime::getDigitalOutputCount
::std::size_t getDigitalOutputCount() const
Definition: UniversalRobotsRealtime.cpp:159
DigitalInputReader.h
rl::math::Vector
::Eigen::Matrix< Real, ::Eigen::Dynamic, 1 > Vector
Definition: Vector.h:42
rl::hal::UniversalRobotsRealtime::Message::toolVectorTarget
double toolVectorTarget[6]
Definition: UniversalRobotsRealtime.h:151
rl::hal::UniversalRobotsRealtime::Message::toolVectorActual
double toolVectorActual[6]
Definition: UniversalRobotsRealtime.h:145
rl::hal::UniversalRobotsRealtime::Message::vActual
double vActual[6]
Definition: UniversalRobotsRealtime.h:181
rl::hal::CartesianForceSensor
Definition: CartesianForceSensor.h:39
rl::hal::UniversalRobotsRealtime::Message::testValue
double testValue
Definition: UniversalRobotsRealtime.h:161
JointVelocitySensor.h
rl::hal::UniversalRobotsRealtime::getJointPosition
::rl::math::Vector getJointPosition() const
Definition: UniversalRobotsRealtime.cpp:178
rl::hal::UniversalRobotsRealtime::doScript
void doScript(const ::std::string &script)
Definition: UniversalRobotsRealtime.cpp:76
rl::hal::UniversalRobotsRealtime::stop
void stop()
Definition: UniversalRobotsRealtime.cpp:277
rl::hal::UniversalRobotsRealtime::Message::tcpSpeedTarget
double tcpSpeedTarget[6]
Definition: UniversalRobotsRealtime.h:153
rl::hal::UniversalRobotsRealtime::Message::iControl
double iControl[6]
Definition: UniversalRobotsRealtime.h:143
rl::hal::CyclicDevice
Definition: CyclicDevice.h:39
JointCurrentSensor.h
rl::hal::UniversalRobotsRealtime::Message::iActual
double iActual[6]
Definition: UniversalRobotsRealtime.h:141
Endian.h
rl::hal::UniversalRobotsRealtime::Message::vMain
double vMain
Definition: UniversalRobotsRealtime.h:175
rl::hal::UniversalRobotsRealtime::Message::digitalInputBits
::std::int64_t digitalInputBits
Definition: UniversalRobotsRealtime.h:155
rl::hal::UniversalRobotsRealtime::getDigitalOutput
::boost::dynamic_bitset getDigitalOutput() const
Definition: UniversalRobotsRealtime.cpp:147
CartesianPositionSensor.h
rl::hal::UniversalRobotsRealtime::Message::qTarget
double qTarget[6]
Definition: UniversalRobotsRealtime.h:127
rl::hal::UniversalRobotsRealtime::Message::qActual
double qActual[6]
Definition: UniversalRobotsRealtime.h:137
rl::hal::DigitalOutputReader
Definition: DigitalOutputReader.h:39
CartesianForceSensor.h
rl::hal::UniversalRobotsRealtime::Message::messageSize
::std::uint32_t messageSize
Definition: UniversalRobotsRealtime.h:123
rl::hal::UniversalRobotsRealtime::Message::time
double time
Definition: UniversalRobotsRealtime.h:125
CartesianVelocitySensor.h
rl::hal::UniversalRobotsRealtime::Message::digitalOutputs
::std::int64_t digitalOutputs
Definition: UniversalRobotsRealtime.h:183
DigitalOutputReader.h
rl::hal::Endian::bigToHost
static void bigToHost(::std::int8_t &character)
Definition: Endian.h:55
rl::hal::UniversalRobotsRealtime::Message::robotMode
double robotMode
Definition: UniversalRobotsRealtime.h:163
JointPositionSensor.h
rl::hal::UniversalRobotsRealtime::UniversalRobotsRealtime
UniversalRobotsRealtime(const ::std::string &address)
Definition: UniversalRobotsRealtime.cpp:37
rl::hal::UniversalRobotsRealtime::Message::motorTemperatures
double motorTemperatures[6]
Definition: UniversalRobotsRealtime.h:157
rl::hal::CartesianPositionSensor
Definition: CartesianPositionSensor.h:39
rl::hal::UniversalRobotsRealtime::getJointCurrent
::rl::math::Vector getJointCurrent() const
Definition: UniversalRobotsRealtime.cpp:165
CyclicDevice.h
rl::hal::UniversalRobotsRealtime::Message
Definition: UniversalRobotsRealtime.h:103
rl::hal::UniversalRobotsRealtime::Message::qdActual
double qdActual[6]
Definition: UniversalRobotsRealtime.h:139
rl::hal::UniversalRobotsRealtime::Message::speedScaling
double speedScaling
Definition: UniversalRobotsRealtime.h:171
rl::hal::UniversalRobotsRealtime
Universal Robots realtime interface (pre-3.0, 3.0, 3.1, 3.2).
Definition: UniversalRobotsRealtime.h:61
rl::hal::CartesianVelocitySensor
Definition: CartesianVelocitySensor.h:39
rl::hal::DigitalInputReader
Definition: DigitalInputReader.h:39
rl::hal::UniversalRobotsRealtime::Message::toolAccelerometerValues
double toolAccelerometerValues[3]
Definition: UniversalRobotsRealtime.h:169
rl::hal::UniversalRobotsRealtime::getCartesianForce
::rl::math::ForceVector getCartesianForce() const
Definition: UniversalRobotsRealtime.cpp:82
rl::hal::UniversalRobotsRealtime::getDigitalInput
::boost::dynamic_bitset getDigitalInput() const
Definition: UniversalRobotsRealtime.cpp:131
rl::hal::UniversalRobotsRealtime::Message::controllerTimer
double controllerTimer
Definition: UniversalRobotsRealtime.h:159
rl::hal::UniversalRobotsRealtime::Message::iRobot
double iRobot
Definition: UniversalRobotsRealtime.h:179
rl::math::spatial::ForceVector
Force vector.
Definition: ForceVector.h:46
rl::hal::JointCurrentSensor
Definition: JointCurrentSensor.h:39
rl::hal::UniversalRobotsRealtime::getDigitalInputCount
::std::size_t getDigitalInputCount() const
Definition: UniversalRobotsRealtime.cpp:143
rl::math::spatial::MotionVector
Motion vector.
Definition: MotionVector.h:45
rl::hal::UniversalRobotsRealtime::Message::jointModes
double jointModes[6]
Definition: UniversalRobotsRealtime.h:165
Socket.h
rl::hal::UniversalRobotsRealtime::start
void start()
Definition: UniversalRobotsRealtime.cpp:213
rl::hal::UniversalRobotsRealtime::Message::iTarget
double iTarget[6]
Definition: UniversalRobotsRealtime.h:133
rl
Robotics Library.
Definition: AnalogInput.cpp:30