Robotics Library  0.7.0
WeissWsg50.h
Go to the documentation of this file.
1 //
2 // Copyright (c) 2013, Andre Gaschler, 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_WEISSWSG50_H
28 #define RL_HAL_WEISSWSG50_H
29 
30 #include <cstdint>
31 #include <string>
32 
33 #include "CyclicDevice.h"
34 #include "Device.h"
35 #include "Gripper.h"
36 #include "Socket.h"
37 
38 namespace rl
39 {
40  namespace hal
41  {
53  class WeissWsg50 : public CyclicDevice, public Gripper
54  {
55  public:
57  {
66  };
67 
69  {
89  };
90 
98  WeissWsg50(
99  const ::std::string& address = "192.168.1.20",
100  const unsigned short int& port = 1000,
101  const float& acceleration = 3.0f,
102  const float& forceLimit = 40.0f,
103  const unsigned int& period = 10
104  );
105 
106  virtual ~WeissWsg50();
107 
109 
110  void close();
111 
112  void doAcknowledgeFaults();
113 
114  void doFastStop();
115 
116  void doGetAcceleration();
117 
118  void doClearSoftLimits();
119 
120  void doGetForce(const bool& doAutomaticUpdate, const bool& doUpdateOnChange, const unsigned int& period = 0);
121 
122  void doGetForceLimit();
123 
124  void doGetGraspingState(const bool& doAutomaticUpdate, const bool& doUpdateOnChange, const unsigned int& period = 0);
125 
126  void doGetGraspingStatistics(const bool& doReset, int& numberGraspsTotal, int& numberGraspsNoPart, int& numberGraspsLostPart);
127 
128  void doGetOpeningWidth(const bool& doAutomaticUpdate, const bool& doUpdateOnChange, const unsigned int& period = 0);
129 
130  void doGetSoftLimits();
131 
132  void doGetSpeed(const bool& doAutomaticUpdate, const bool& doUpdateOnChange, const unsigned int& period = 0);
133 
134  void doGetSystemInformation(bool& isWsg50, int& hardwareRevision, int& firmwareRevision, int& serialNumber);
135 
136  void doGetSystemLimits();
137 
138  void doGetSystemState(const bool& doAutomaticUpdate, const bool& doUpdateOnChange, const unsigned int& period = 0);
139 
143  float doGetTemperature();
144 
149  void doGraspPart(const float& width, const float& speed);
150 
158  void doHomingMotion(const unsigned int& direction = 0);
159 
160  void doOverdriveMode(const bool& doOverdriveMode);
161 
166  void doPrePositionFingers(const float& width, const float& speed, const bool& doRelativeMovement = false, const bool& doStopOnBlock = false);
167 
172  void doReleasePart(const float& width, const float& speed);
173 
177  void doSetAcceleration(const float& acceleration);
178 
182  void doSetForceLimit(const float& force);
183 
188  void doSetSoftLimits(const float& limitMinus, const float& limitPlus);
189 
190  void doStop();
191 
192  void doTareForceSensor();
193 
197  float getAcceleration() const;
198 
202  float getForce() const;
203 
207  float getForceLimit() const;
208 
210 
214  float getOpeningWidth() const;
215 
219  float getSpeed() const;
220 
221  SystemState getSystemState() const;
222 
223  void halt();
224 
225  void open();
226 
227  void release();
228 
229  void shut();
230 
231  void start();
232 
233  void step();
234 
235  void stop();
236 
237  protected:
238 
239  private:
240  ::std::uint16_t crc(const ::std::uint8_t* buf, const ::std::size_t& len) const;
241 
243 
244  ::std::size_t recv(::std::uint8_t* buf);
245 
246  ::std::size_t recv(::std::uint8_t* buf, const ::std::size_t& len, const ::std::uint8_t& command);
247 
248  void send(::std::uint8_t* buf, const ::std::size_t& len);
249 
250  static const ::std::size_t HEADER_SIZE = 6;
251 
253 
255 
257 
258  float force;
259 
260  float forceLimit;
261 
263 
265 
267 
269 
270  float limitMinus;
271 
272  float limitPlus;
273 
275 
276  unsigned int period;
277 
279 
280  float speed;
281 
283 
285 
286  float stroke;
287 
289  };
290  }
291 }
292 
293 #endif // RL_HAL_WEISSWSG50_H
rl::hal::WeissWsg50::getOpeningWidth
float getOpeningWidth() const
Definition: WeissWsg50.cpp:640
rl::hal::WeissWsg50::doReleasePart
void doReleasePart(const float &width, const float &speed)
Definition: WeissWsg50.cpp:513
rl::hal::WeissWsg50::doGetSoftLimits
void doGetSoftLimits()
Definition: WeissWsg50.cpp:302
rl::hal::WeissWsg50::GRASPING_STATE_GRIPPING
@ GRASPING_STATE_GRIPPING
Definition: WeissWsg50.h:59
rl::hal::WeissWsg50::shut
void shut()
Definition: WeissWsg50.cpp:870
rl::hal::WeissWsg50::SystemState
SystemState
Definition: WeissWsg50.h:69
rl::hal::Socket
Definition: Socket.h:48
rl::hal::WeissWsg50::limitMinus
float limitMinus
Definition: WeissWsg50.h:270
rl::hal::WeissWsg50::close
void close()
Definition: WeissWsg50.cpp:123
rl::hal::WeissWsg50::GRASPING_STATE_POSITIONING
@ GRASPING_STATE_POSITIONING
Definition: WeissWsg50.h:64
rl::hal::WeissWsg50::SYSTEM_STATE_AXIS_BLOCKED_PLUS
@ SYSTEM_STATE_AXIS_BLOCKED_PLUS
Definition: WeissWsg50.h:85
rl::hal::WeissWsg50::acknowledgeFaults
void acknowledgeFaults()
rl::hal::WeissWsg50::forceOverdrive
float forceOverdrive
Definition: WeissWsg50.h:266
rl::hal::WeissWsg50::SYSTEM_STATE_OVERDRIVE_MODE
@ SYSTEM_STATE_OVERDRIVE_MODE
Definition: WeissWsg50.h:80
rl::hal::WeissWsg50::limitPlus
float limitPlus
Definition: WeissWsg50.h:272
rl::hal::WeissWsg50::doGetForceLimit
void doGetForceLimit()
Definition: WeissWsg50.cpp:237
rl::hal::WeissWsg50::doGetSystemInformation
void doGetSystemInformation(bool &isWsg50, int &hardwareRevision, int &firmwareRevision, int &serialNumber)
Definition: WeissWsg50.cpp:337
rl::hal::WeissWsg50::HEADER_SIZE
static const ::std::size_t HEADER_SIZE
Definition: WeissWsg50.h:250
rl::hal::WeissWsg50::doDisconnectAnnouncement
void doDisconnectAnnouncement()
Definition: WeissWsg50.cpp:178
rl::hal::WeissWsg50::doGetAcceleration
void doGetAcceleration()
Definition: WeissWsg50.cpp:204
rl::hal::WeissWsg50::GRASPING_STATE_IDLE
@ GRASPING_STATE_IDLE
Definition: WeissWsg50.h:58
rl::hal::WeissWsg50::SYSTEM_STATE_REFERENCED
@ SYSTEM_STATE_REFERENCED
Definition: WeissWsg50.h:88
rl::hal::WeissWsg50::doFastStop
void doFastStop()
Definition: WeissWsg50.cpp:191
rl::hal::WeissWsg50::GRASPING_STATE_NO_PART_FOUND
@ GRASPING_STATE_NO_PART_FOUND
Definition: WeissWsg50.h:60
rl::hal::WeissWsg50::systemState
SystemState systemState
Definition: WeissWsg50.h:288
rl::hal::WeissWsg50::getSpeed
float getSpeed() const
Definition: WeissWsg50.cpp:646
rl::hal::WeissWsg50::recv
::std::size_t recv(::std::uint8_t *buf)
Definition: WeissWsg50.cpp:676
rl::hal::WeissWsg50::halt
void halt()
Definition: WeissWsg50.cpp:658
rl::hal::WeissWsg50::accelerationMaximum
float accelerationMaximum
Definition: WeissWsg50.h:254
rl::hal::WeissWsg50::~WeissWsg50
virtual ~WeissWsg50()
Definition: WeissWsg50.cpp:114
rl::hal::WeissWsg50::getGraspingState
GraspingState getGraspingState() const
Definition: WeissWsg50.cpp:634
rl::hal::WeissWsg50::graspingState
GraspingState graspingState
Definition: WeissWsg50.h:268
rl::hal::WeissWsg50::doGetGraspingStatistics
void doGetGraspingStatistics(const bool &doReset, int &numberGraspsTotal, int &numberGraspsNoPart, int &numberGraspsLostPart)
Definition: WeissWsg50.cpp:268
rl::hal::WeissWsg50::doSetAcceleration
void doSetAcceleration(const float &acceleration)
Definition: WeissWsg50.cpp:533
rl::hal::WeissWsg50::doGetSystemState
void doGetSystemState(const bool &doAutomaticUpdate, const bool &doUpdateOnChange, const unsigned int &period=0)
Definition: WeissWsg50.cpp:383
rl::hal::WeissWsg50::crc
::std::uint16_t crc(const ::std::uint8_t *buf, const ::std::size_t &len) const
Definition: WeissWsg50.cpp:132
rl::hal::WeissWsg50::doSetSoftLimits
void doSetSoftLimits(const float &limitMinus, const float &limitPlus)
Definition: WeissWsg50.cpp:569
rl::hal::WeissWsg50::doSetForceLimit
void doSetForceLimit(const float &force)
Definition: WeissWsg50.cpp:552
rl::hal::WeissWsg50::doPrePositionFingers
void doPrePositionFingers(const float &width, const float &speed, const bool &doRelativeMovement=false, const bool &doStopOnBlock=false)
Definition: WeissWsg50.cpp:480
rl::hal::WeissWsg50::SYSTEM_STATE_CURRENT_FAULT
@ SYSTEM_STATE_CURRENT_FAULT
Definition: WeissWsg50.h:74
rl::hal::WeissWsg50::stroke
float stroke
Definition: WeissWsg50.h:286
rl::hal::WeissWsg50::getAcceleration
float getAcceleration() const
Definition: WeissWsg50.cpp:616
rl::hal::WeissWsg50::getSystemState
SystemState getSystemState() const
Definition: WeissWsg50.cpp:652
rl::hal::CyclicDevice
Definition: CyclicDevice.h:39
rl::hal::WeissWsg50::doGetTemperature
float doGetTemperature()
Definition: WeissWsg50.cpp:406
rl::hal::WeissWsg50::stop
void stop()
Definition: WeissWsg50.cpp:917
rl::hal::WeissWsg50::SYSTEM_STATE_FAST_STOP
@ SYSTEM_STATE_FAST_STOP
Definition: WeissWsg50.h:78
rl::hal::WeissWsg50::period
unsigned int period
Definition: WeissWsg50.h:276
rl::hal::WeissWsg50::GRASPING_STATE_HOLDING
@ GRASPING_STATE_HOLDING
Definition: WeissWsg50.h:62
rl::hal::WeissWsg50::accelerationMinimum
float accelerationMinimum
Definition: WeissWsg50.h:256
rl::hal::WeissWsg50::SYSTEM_STATE_SOFT_LIMIT_MINUS
@ SYSTEM_STATE_SOFT_LIMIT_MINUS
Definition: WeissWsg50.h:84
rl::hal::WeissWsg50::SYSTEM_STATE_FINGER_FAULT
@ SYSTEM_STATE_FINGER_FAULT
Definition: WeissWsg50.h:73
rl::hal::WeissWsg50::SYSTEM_STATE_SCRIPT_FAILURE
@ SYSTEM_STATE_SCRIPT_FAILURE
Definition: WeissWsg50.h:70
rl::hal::WeissWsg50::forceMinimum
float forceMinimum
Definition: WeissWsg50.h:262
rl::hal::WeissWsg50::WeissWsg50
WeissWsg50(const ::std::string &address="192.168.1.20", const unsigned short int &port=1000, const float &acceleration=3.0f, const float &forceLimit=40.0f, const unsigned int &period=10)
Definition: WeissWsg50.cpp:82
rl::hal::WeissWsg50::SYSTEM_STATE_TEMPERATURE_FAULT
@ SYSTEM_STATE_TEMPERATURE_FAULT
Definition: WeissWsg50.h:76
rl::hal::WeissWsg50::step
void step()
Definition: WeissWsg50.cpp:902
Device.h
Gripper.h
rl::hal::WeissWsg50
Weiss Robotics Universal Gripper WSG 50.
Definition: WeissWsg50.h:54
rl::hal::WeissWsg50::forceNominal
float forceNominal
Definition: WeissWsg50.h:264
rl::hal::WeissWsg50::doGetOpeningWidth
void doGetOpeningWidth(const bool &doAutomaticUpdate, const bool &doUpdateOnChange, const unsigned int &period=0)
Definition: WeissWsg50.cpp:286
rl::hal::WeissWsg50::getForce
float getForce() const
Definition: WeissWsg50.cpp:622
rl::hal::WeissWsg50::GRASPING_STATE_RELEASING
@ GRASPING_STATE_RELEASING
Definition: WeissWsg50.h:63
rl::hal::WeissWsg50::doGetSpeed
void doGetSpeed(const bool &doAutomaticUpdate, const bool &doUpdateOnChange, const unsigned int &period=0)
Definition: WeissWsg50.cpp:321
rl::hal::WeissWsg50::open
void open()
Definition: WeissWsg50.cpp:666
rl::hal::WeissWsg50::doGetForce
void doGetForce(const bool &doAutomaticUpdate, const bool &doUpdateOnChange, const unsigned int &period=0)
Definition: WeissWsg50.cpp:221
rl::hal::WeissWsg50::release
void release()
Definition: WeissWsg50.cpp:826
rl::hal::WeissWsg50::SYSTEM_STATE_AXIS_BLOCKED_MINUS
@ SYSTEM_STATE_AXIS_BLOCKED_MINUS
Definition: WeissWsg50.h:86
rl::hal::WeissWsg50::SYSTEM_STATE_TEMPERATURE_WARNING
@ SYSTEM_STATE_TEMPERATURE_WARNING
Definition: WeissWsg50.h:77
rl::hal::WeissWsg50::SYSTEM_STATE_MOVING
@ SYSTEM_STATE_MOVING
Definition: WeissWsg50.h:87
rl::hal::WeissWsg50::doAcknowledgeFaults
void doAcknowledgeFaults()
Definition: WeissWsg50.cpp:146
rl::hal::WeissWsg50::doTareForceSensor
void doTareForceSensor()
Definition: WeissWsg50.cpp:603
rl::hal::WeissWsg50::speedMinimum
float speedMinimum
Definition: WeissWsg50.h:284
rl::hal::WeissWsg50::doClearSoftLimits
void doClearSoftLimits()
Definition: WeissWsg50.cpp:162
rl::hal::WeissWsg50::speedMaximum
float speedMaximum
Definition: WeissWsg50.h:282
rl::hal::WeissWsg50::GRASPING_STATE_ERROR
@ GRASPING_STATE_ERROR
Definition: WeissWsg50.h:65
rl::hal::WeissWsg50::SYSTEM_STATE_FORCE_CONTROL_MODE
@ SYSTEM_STATE_FORCE_CONTROL_MODE
Definition: WeissWsg50.h:79
rl::hal::WeissWsg50::openingWidth
float openingWidth
Definition: WeissWsg50.h:274
rl::hal::WeissWsg50::acceleration
float acceleration
Definition: WeissWsg50.h:252
rl::hal::WeissWsg50::forceLimit
float forceLimit
Definition: WeissWsg50.h:260
rl::hal::WeissWsg50::doOverdriveMode
void doOverdriveMode(const bool &doOverdriveMode)
Definition: WeissWsg50.cpp:461
rl::hal::WeissWsg50::doGetGraspingState
void doGetGraspingState(const bool &doAutomaticUpdate, const bool &doUpdateOnChange, const unsigned int &period=0)
Definition: WeissWsg50.cpp:252
rl::hal::WeissWsg50::start
void start()
Definition: WeissWsg50.cpp:878
CyclicDevice.h
rl::hal::WeissWsg50::SYSTEM_STATE_SCRIPT_RUNNING
@ SYSTEM_STATE_SCRIPT_RUNNING
Definition: WeissWsg50.h:71
rl::hal::WeissWsg50::force
float force
Definition: WeissWsg50.h:258
rl::hal::WeissWsg50::SYSTEM_STATE_TARGET_POSITION_REACHED
@ SYSTEM_STATE_TARGET_POSITION_REACHED
Definition: WeissWsg50.h:81
rl::hal::WeissWsg50::doStop
void doStop()
Definition: WeissWsg50.cpp:590
rl::hal::WeissWsg50::GraspingState
GraspingState
Definition: WeissWsg50.h:57
rl::hal::WeissWsg50::speed
float speed
Definition: WeissWsg50.h:280
rl::hal::WeissWsg50::SYSTEM_STATE_AXIS_STOPPED
@ SYSTEM_STATE_AXIS_STOPPED
Definition: WeissWsg50.h:82
rl::hal::WeissWsg50::socket
Socket socket
Definition: WeissWsg50.h:278
rl::hal::WeissWsg50::doGetSystemLimits
void doGetSystemLimits()
Definition: WeissWsg50.cpp:355
rl::hal::WeissWsg50::doHomingMotion
void doHomingMotion(const unsigned int &direction=0)
Perform necessary homing motion for calibration.
Definition: WeissWsg50.cpp:445
rl::hal::WeissWsg50::getForceLimit
float getForceLimit() const
Definition: WeissWsg50.cpp:628
rl::hal::WeissWsg50::SYSTEM_STATE_POWER_FAULT
@ SYSTEM_STATE_POWER_FAULT
Definition: WeissWsg50.h:75
rl::hal::WeissWsg50::send
void send(::std::uint8_t *buf, const ::std::size_t &len)
Definition: WeissWsg50.cpp:834
rl::hal::WeissWsg50::SYSTEM_STATE_COMMAND_FAILURE
@ SYSTEM_STATE_COMMAND_FAILURE
Definition: WeissWsg50.h:72
Socket.h
rl::hal::WeissWsg50::doGraspPart
void doGraspPart(const float &width, const float &speed)
Definition: WeissWsg50.cpp:423
rl::hal::Gripper
Definition: Gripper.h:37
rl::hal::WeissWsg50::GRASPING_STATE_PART_LOST
@ GRASPING_STATE_PART_LOST
Definition: WeissWsg50.h:61
rl
Robotics Library.
Definition: AnalogInput.cpp:30
rl::hal::WeissWsg50::SYSTEM_STATE_SOFT_LIMIT_PLUS
@ SYSTEM_STATE_SOFT_LIMIT_PLUS
Definition: WeissWsg50.h:83