My Project
Loading...
Searching...
No Matches
CDeltaDevices.h
Go to the documentation of this file.
1//==============================================================================
2/*
3 Software License Agreement (BSD License)
4 Copyright (c) 2003-2022, CHAI3D
5 (www.chai3d.org)
6
7 All rights reserved.
8
9 Redistribution and use in source and binary forms, with or without
10 modification, are permitted provided that the following conditions
11 are met:
12
13 * Redistributions of source code must retain the above copyright
14 notice, this list of conditions and the following disclaimer.
15
16 * Redistributions in binary form must reproduce the above
17 copyright notice, this list of conditions and the following
18 disclaimer in the documentation and/or other materials provided
19 with the distribution.
20
21 * Neither the name of CHAI3D nor the names of its contributors may
22 be used to endorse or promote products derived from this software
23 without specific prior written permission.
24
25 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
26 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
27 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
28 FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
29 COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
30 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
31 BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
32 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
33 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
35 ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 POSSIBILITY OF SUCH DAMAGE.
37
38 \author <http://www.chai3d.org>
39 \author Francois Conti
40 \author Force Dimension - www.forcedimension.com
41 \version 3.3.0
42*/
43//==============================================================================
44
45//------------------------------------------------------------------------------
46#ifndef CDeltaDevicesH
47#define CDeltaDevicesH
48//------------------------------------------------------------------------------
49#if defined(C_ENABLE_DELTA_DEVICE_SUPPORT)
50//------------------------------------------------------------------------------
52//------------------------------------------------------------------------------
53
54//------------------------------------------------------------------------------
55namespace chai3d {
56//------------------------------------------------------------------------------
57
58//==============================================================================
65//==============================================================================
66
67//------------------------------------------------------------------------------
68#ifndef DOXYGEN_SHOULD_SKIP_THIS
69//------------------------------------------------------------------------------
70
71// encoder count (must match the definition of the Force Dimension SDK)
72#define DHD_MAX_DOF 8
73
74//------------------------------------------------------------------------------
75#endif // DOXYGEN_SHOULD_SKIP_THIS
76//------------------------------------------------------------------------------
77
78//------------------------------------------------------------------------------
79class cDeltaDevice;
80typedef std::shared_ptr<cDeltaDevice> cDeltaDevicePtr;
81//------------------------------------------------------------------------------
82
83//==============================================================================
96//==============================================================================
98{
99 //--------------------------------------------------------------------------
100 // CONSTRUCTOR & DESTRUCTOR:
101 //--------------------------------------------------------------------------
102
103public:
104
106 cDeltaDevice(unsigned int a_deviceNumber = 0, bool a_external = false);
107
109 virtual ~cDeltaDevice();
110
112 static cDeltaDevicePtr create(unsigned int a_deviceNumber = 0, bool a_external = false) { return (std::make_shared<cDeltaDevice>(a_deviceNumber, a_external)); }
113
114
115 //--------------------------------------------------------------------------
116 // PUBLIC METHODS:
117 //--------------------------------------------------------------------------
118
119public:
120
122 virtual bool open();
123
125 virtual bool close();
126
128 virtual bool calibrate(bool a_forceCalibration = false);
129
131 virtual bool getPosition(cVector3d& a_position);
132
134 virtual bool getLinearVelocity(cVector3d& a_linearVelocity);
135
137 virtual bool getRotation(cMatrix3d& a_rotation);
138
140 virtual bool getJointAnglesRad(double a_jointAnglesRad[C_MAX_DOF]);
141
143 virtual bool getGripperAngleRad(double& a_angle);
144
146 virtual bool getUserSwitches(unsigned int& a_userSwitches);
147
149 virtual bool setForceAndTorqueAndGripperForce(const cVector3d& a_force, const cVector3d& a_torque, double a_gripperForce);
150
152 virtual bool enableForces(bool a_value);
153
154
155 //--------------------------------------------------------------------------
156 // PUBLIC STATIC METHODS:
157 //--------------------------------------------------------------------------
158
159public:
160
162 static unsigned int getNumDevices();
163
164
165 //--------------------------------------------------------------------------
166 // PROTECTED METHODS - DEVICE LIBRARY INITIALIZATION:
167 //--------------------------------------------------------------------------
168
169protected:
170
172 static bool openLibraries();
173
175 static bool closeLibraries();
176
177
178 //--------------------------------------------------------------------------
179 // PROTECTED MEMBERS - DEVICE LIBRARIES:
180 //--------------------------------------------------------------------------
181
182protected:
183
186
188 static unsigned int s_libraryCounter;
189
190
191 //--------------------------------------------------------------------------
192 // PUBLIC METHODS RESTRICTED TO FORCE DIMENSION DEVICES ONLY:
193 //--------------------------------------------------------------------------
194
195public:
196
198 int getDeviceType() { return (m_deviceType); }
199
201 bool setDeviceAngleDeg(double a_angleDeg);
202
204 bool setVibration(double a_freq, double a_amplitude, int a_type = 0);
205
207 bool presetEnc(int a_encPreset[DHD_MAX_DOF], unsigned short a_mask = 0xff);
208
210 bool presetEncAll(int a_encPreset = 0);
211
213 bool getEncPos(int a_encPos[DHD_MAX_DOF]);
214
216 bool getEncVel(double a_encVel[DHD_MAX_DOF]);
217
219 bool setMot(unsigned short a_mot[DHD_MAX_DOF], unsigned short a_mask = 0xff);
220
222 bool getJacobianDelta(cMatrix3d& a_jacobian);
223
225 bool getJacobianWrist(cMatrix3d& a_jacobian);
226
228 bool setJointTorques(double a_jointTorques[DHD_MAX_DOF]);
229
231 bool getJointTorquesGravityCompensation(double a_jointTorques[DHD_MAX_DOF]);
232
233
234 //--------------------------------------------------------------------------
235 // PROTECTED MEMBERS
236 //--------------------------------------------------------------------------
237
238protected:
239
242
245
248
251
254
257
260
263
264 //--------------------------------------------------------------------------
265 #ifndef DOXYGEN_SHOULD_SKIP_THIS
266 //--------------------------------------------------------------------------
268 static bool s_dhdGetDeviceCount;
269 static bool s_dhdGetDeviceID;
270 static bool s_dhdGetSystemType;
271 static bool s_dhdOpenID;
272 static bool s_dhdClose;
273 static bool s_dhdReset;
274 static bool s_dhdGetButton;
275 static bool s_dhdGetButtonMask;
276 static bool s_dhdGetPosition;
277 static bool s_dhdGetLinearVelocity;
278 static bool s_dhdGetOrientationRad;
279 static bool s_dhdSetTorque;
280 static bool s_dhdGetOrientationFrame;
281 static bool s_dhdSetForce;
282 static bool s_dhdSetForceAndTorque;
283 static bool s_dhdSetForceAndGripperForce;
284 static bool s_dhdSetForceAndTorqueAndGripperForce;
285 static bool s_dhdGetGripperThumbPos;
286 static bool s_dhdGetGripperFingerPos;
287 static bool s_dhdGetGripperAngleRad;
288 static bool s_dhdEnableExpertMode;
289 static bool s_dhdDisableExpertMode;
290 static bool s_dhdEnableForce;
291 static bool s_dhdIsLeftHanded;
292 static bool s_dhdSetBaseAngleZDeg;
293 static bool s_dhdSetVelocityThreshold;
294 static bool s_dhdSetWatchdog;
295 static bool s_drdOpenID;
296 static bool s_drdClose;
297 static bool s_drdIsInitialized;
298 static bool s_drdAutoInit;
299 static bool s_drdStop;
300 static bool s_flagUsingSDK32;
301 static bool s_dhdSetDeviceAngleDeg;
302 static bool s_dhdGetJointAngles;
303 static bool s_dhdSetVibration;
304 static bool s_dhdEnableSimulator;
305 static bool s_dhdPreset;
306 static bool s_dhdGetEnc;
307 static bool s_dhdGetEncVelocities;
308 static bool s_dhdSetMot;
309 static bool s_dhdGetDeltaJacobian;
310 static bool s_dhdGetWristJacobian;
311 static bool s_dhdSetJointTorques;
312 static bool s_dhdJointAnglesToGravityJointTorques;
313
314 //--------------------------------------------------------------------------
315 #endif // DOXYGEN_SHOULD_SKIP_THIS
316 //--------------------------------------------------------------------------
317};
318
319//------------------------------------------------------------------------------
320} // namespace chai3d
321//------------------------------------------------------------------------------
322
323//------------------------------------------------------------------------------
324#endif // C_ENABLE_DELTA_DEVICE_SUPPORT
325//------------------------------------------------------------------------------
326#endif
327//------------------------------------------------------------------------------
Implements a base class for haptic devices.
This class implements an interface to all Force Dimension and Novint haptic devices.
Definition CDeltaDevices.h:98
virtual bool open()
This method opens a connection to the haptic device.
Definition CDeltaDevices.cpp:701
bool presetEncAll(int a_encPreset=0)
This method presets all encoder values to given value.
Definition CDeltaDevices.cpp:1846
virtual bool getRotation(cMatrix3d &a_rotation)
This method returns the orientation frame of the haptic device.
Definition CDeltaDevices.cpp:1369
cPrecisionClock m_userSwitchClock[8]
Time guard for user switch.
Definition CDeltaDevices.h:253
int m_userSwitchCount[8]
Data structure for simulating a low-pass filter on user switches.
Definition CDeltaDevices.h:247
bool m_external
Was dhdOpen() called outside CHAI3D?
Definition CDeltaDevices.h:259
bool presetEnc(int a_encPreset[DHD_MAX_DOF], unsigned short a_mask=0xff)
This method presets the encoder values given a table of values.
Definition CDeltaDevices.cpp:1812
virtual bool getUserSwitches(unsigned int &a_userSwitches)
This method returns the status of all user switches [true = ON / false = OFF].
Definition CDeltaDevices.cpp:1633
int m_deviceType
Device type among the Force Dimension devices.
Definition CDeltaDevices.h:244
int getDeviceType()
This method returns the type of this haptic device.
Definition CDeltaDevices.h:198
bool getEncPos(int a_encPos[DHD_MAX_DOF])
This method returns the encoder position values of the device.
Definition CDeltaDevices.cpp:1886
virtual bool setForceAndTorqueAndGripperForce(const cVector3d &a_force, const cVector3d &a_torque, double a_gripperForce)
This method sends a force, torque, and gripper force to the haptic device.
Definition CDeltaDevices.cpp:1529
int m_deviceID
Device ID number among the Force Dimension devices connected to the computer.
Definition CDeltaDevices.h:241
virtual bool getGripperAngleRad(double &a_angle)
This method returns the gripper angle in radian [rad].
Definition CDeltaDevices.cpp:1467
static bool openLibraries()
This method opens libraries for this class of devices.
Definition CDeltaDevices.cpp:293
bool setJointTorques(double a_jointTorques[DHD_MAX_DOF])
This method applies joint torques on the device.
Definition CDeltaDevices.cpp:2076
static cDeltaDevicePtr create(unsigned int a_deviceNumber=0, bool a_external=false)
Shared cDeltaDevice allocator.
Definition CDeltaDevices.h:112
bool m_statusEnableForcesFirstTime
Have forces been enable yet since the connection to the device was opened?
Definition CDeltaDevices.h:256
static unsigned int s_libraryCounter
Number of instances for this class of devices currently using the libraries.
Definition CDeltaDevices.h:188
bool getEncVel(double a_encVel[DHD_MAX_DOF])
This method returns the encoder velocity values of the device.
Definition CDeltaDevices.cpp:1920
cVector3d m_posWorkspaceOffset
Translational workspace offset.
Definition CDeltaDevices.h:262
virtual bool calibrate(bool a_forceCalibration=false)
This method calibrates the haptic device.
Definition CDeltaDevices.cpp:1242
virtual ~cDeltaDevice()
Destructor of cDeltaDevice.
Definition CDeltaDevices.cpp:675
bool setVibration(double a_freq, double a_amplitude, int a_type=0)
This method assign a vibration to the devices that support this feature.
Definition CDeltaDevices.cpp:1778
virtual bool getJointAnglesRad(double a_jointAnglesRad[C_MAX_DOF])
This method returns the joint angles of the haptic device.
Definition CDeltaDevices.cpp:1431
bool setMot(unsigned short a_mot[DHD_MAX_DOF], unsigned short a_mask=0xff)
This method sets motor commands to the device.
Definition CDeltaDevices.cpp:1955
bool getJacobianWrist(cMatrix3d &a_jacobian)
This method returns the Jacobian of the wrist.
Definition CDeltaDevices.cpp:2033
virtual bool enableForces(bool a_value)
This method enables or disables forces.
Definition CDeltaDevices.cpp:1689
static unsigned int getNumDevices()
This method returns the number of haptic devices available for this class of devices.
Definition CDeltaDevices.cpp:553
static bool s_allocationTable[C_MAX_DEVICES]
Allocation table for devices of this class. true means that the device has been allocated,...
Definition CDeltaDevices.h:185
virtual bool close()
This method closes the connection to the haptic device.
Definition CDeltaDevices.cpp:1191
virtual bool getLinearVelocity(cVector3d &a_linearVelocity)
This method returns the linear velocity of the haptic device.
Definition CDeltaDevices.cpp:1329
bool getJointTorquesGravityCompensation(double a_jointTorques[DHD_MAX_DOF])
This method returns the joints torques for gravity compensation.
Definition CDeltaDevices.cpp:2110
virtual bool getPosition(cVector3d &a_position)
This method returns the position of the haptic device.
Definition CDeltaDevices.cpp:1289
int m_userSwitchStatus[8]
Last state of user switch.
Definition CDeltaDevices.h:250
bool setDeviceAngleDeg(double a_angleDeg)
This method orients the device around the y-axis.
Definition CDeltaDevices.cpp:1743
static bool closeLibraries()
This method closes libraries for this class of devices.
Definition CDeltaDevices.cpp:519
bool getJacobianDelta(cMatrix3d &a_jacobian)
This method returns the jacobian of the base.
Definition CDeltaDevices.cpp:1989
This class implements a base class for haptic devices.
Definition CGenericHapticDevice.h:283
This class implements a high precision clock.
Definition CPrecisionClock.h:86
Definition CAudioBuffer.cpp:57
std::shared_ptr< cDeltaDevice > cDeltaDevicePtr
Definition CDeltaDevices.h:80
const unsigned int C_MAX_DEVICES
Definition CGenericDevice.h:65
const int C_MAX_DOF
Maximum number of joint of a haptic device.
Definition CGenericHapticDevice.h:78
This class implements a 3D matrix.
Definition CMatrix3d.h:98
This class implements a 3D vector.
Definition CVector3d.h:89