H3D API  2.4.1
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
ForceDimensionDevice.h
Go to the documentation of this file.
1 // Copyright 2004-2019, SenseGraphics AB
3 //
4 // This file is part of H3D API.
5 //
6 // H3D API is free software; you can redistribute it and/or modify
7 // it under the terms of the GNU General Public License as published by
8 // the Free Software Foundation; either version 2 of the License, or
9 // (at your option) any later version.
10 //
11 // H3D API is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
15 //
16 // You should have received a copy of the GNU General Public License
17 // along with H3D API; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 //
20 // A commercial license is also available. Please contact us at
21 // www.sensegraphics.com for more information.
22 //
23 //
27 //
29 #ifndef __FORCEDIMENSIONDEVICE_H__
30 #define __FORCEDIMENSIONDEVICE_H__
31 
32 #include <H3D/H3DHapticsDevice.h>
33 #include <H3D/MFString.h>
34 #include <H3D/PeriodicUpdate.h>
35 #include <H3D/SFVec3d.h>
36 
37 namespace H3D {
38 
48  class H3DAPI_API ForceDimensionDevice: public H3DHapticsDevice {
49  public:
50 
53  class H3DAPI_API Reset: public OnNewValueSField< SFBool > {
54  virtual void onNewValue( const bool &v );
55  };
56 
59  class H3DAPI_API WaitReset: public OnNewValueSField< SFBool > {
60  virtual void onNewValue( const bool &v );
61  };
62 
65  class H3DAPI_API GravityComp: public OnValueChangeSField< SFBool > {
66  virtual void onValueChange( const bool &v );
67  };
68 
71  class H3DAPI_API EffectorMass: public OnValueChangeSField< SFFloat > {
72  virtual void onValueChange( const H3DFloat &v );
73  };
74 
77  class H3DAPI_API Brakes: public OnValueChangeSField< SFBool > {
78  virtual void onValueChange( const bool &v );
79  };
80 
83  class H3DAPI_API EnableForce: public OnValueChangeSField< SFBool > {
84  public:
85  EnableForce(): OnValueChangeSField< SFBool >(), call_hapi_function( true ) {}
86 
87  bool call_hapi_function;
88  protected:
89  virtual void onValueChange( const bool &v );
90  };
91 
94  class H3DAPI_API SFAutoCalibrate: public OnNewValueSField< SFBool > {
95  virtual void onNewValue( const bool &v );
96  };
97 
100  class H3DAPI_API SFReleasePosition: public OnNewValueSField< SFVec3d > {
101  public:
103  SFReleasePosition() : value_is_set( false ) {}
104 
108 
109  protected:
110  virtual void onNewValue( const Vec3d &v );
111  };
112 
115  Inst< SFVec3f > _devicePosition = 0,
116  Inst< SFRotation > _deviceOrientation = 0,
117  Inst< TrackerPosition > _trackerPosition = 0,
118  Inst< TrackerOrientation > _trackerOrientation = 0,
119  Inst< SFMatrix4f > _positionCalibration = 0,
120  Inst< SFRotation > _orientationCalibration = 0,
121  Inst< SFVec3f > _proxyPosition = 0,
122  Inst< WeightedProxy > _weightedProxyPosition = 0,
123  Inst< SFFloat > _proxyWeighting = 0,
124  Inst< SFBool > _mainButton = 0,
125  Inst< SFBool > _secondaryButton = 0,
126  Inst< SFInt32 > _buttons = 0,
127  Inst< SFVec3f > _force = 0,
128  Inst< SFVec3f > _torque = 0,
129  Inst< SFInt32 > _inputDOF = 0,
130  Inst< SFInt32 > _outputDOF = 0,
131  Inst< SFInt32 > _hapticsRate = 0,
132  Inst< SFInt32 > _desiredHapticsRate = 0,
133  Inst< SFNode > _stylus = 0,
134  Inst< SFHapticsRendererNode > _hapticsRenderer = 0,
135  Inst< MFVec3f > _proxyPositions = 0,
136  Inst< SFBool > _followViewpoint = 0,
137  Inst< GravityComp > _useGravityCompensation = 0,
138  Inst< Reset > _reset = 0,
139  Inst< WaitReset > _waitForReset = 0,
140  Inst< EffectorMass > _endEffectorMass = 0,
141  Inst< Brakes > _useBrakes = 0,
142  Inst< SFInt32 > _deviceType = 0,
143  Inst< EnableForce > _enableForce = 0,
144  Inst< SFFloat > _vibrationFrequency = 0,
145  Inst< SFFloat > _vibrationAmplitude = 0,
146  Inst< SFFloat > _gripperAngle = 0,
147  Inst< SFAutoCalibrate > _autoCalibrate = 0,
148  Inst< SFBool > _isAutoCalibrated = 0,
149  Inst< SFInt32 > _desiredComThreadRate = 0,
150  Inst< SFFloat > _gripperForce = 0,
151  Inst< SFBool > _flipGripperValues = 0,
152  Inst< SFReleasePosition > _releaseDevicePosition = 0 );
153 
156  virtual ErrorCode initDevice();
157 
161  virtual ErrorCode releaseDevice();
162 
170  H3DUniquePtr< SFBool > useGravityCompensation;
171 
177  H3DUniquePtr< Reset > reset;
178 
183  H3DUniquePtr< WaitReset > waitForReset;
184 
190  H3DUniquePtr< SFFloat > endEffectorMass;
191 
200  H3DUniquePtr< SFBool > useBrakes;
201 
225  H3DUniquePtr< SFInt32 > deviceType;
226 
237  H3DUniquePtr< EnableForce > enableForce;
238 
241 
249  H3DUniquePtr< SFFloat > vibrationFrequency;
250 
259  H3DUniquePtr< SFFloat > vibrationAmplitude;
260 
264  H3DUniquePtr< SFFloat > gripperAngle;
265 
269  virtual void updateDeviceValues();
270 
271  protected:
273  class H3DAPI_API ChangeVibration: public PeriodicUpdate< TypedField< SFBool, Types< SFFloat, SFFloat > > > {
274  protected:
275  virtual void update();
276  };
277 
278  H3DUniquePtr< ChangeVibration > changeVibration;
279 
280  public:
288  H3DUniquePtr< SFAutoCalibrate > autoCalibrate;
289 
293  H3DUniquePtr< SFBool > isAutoCalibrated;
294 
302  H3DUniquePtr< SFInt32 > desiredComThreadRate;
303 
307  H3DUniquePtr< SFFloat > gripperForce;
308 
317  H3DUniquePtr< SFBool > flipGripperValues;
318 
327  H3DUniquePtr< SFReleasePosition > releaseDevicePosition;
328 
331  virtual void initialize();
332  };
333 }
334 
335 #endif
Header file for H3DHapticsDevice.
Contains the MFString field class.
Header file for PeriodicUpdate, template field modifier.
Contains the SFVec3d field class.
Brakes specializes SFBool to toggle brakes on and off.
Definition: ForceDimensionDevice.h:77
EnableForce specializes SFFloat to handle vibration.
Definition: ForceDimensionDevice.h:273
EffectorMass specializes SFFloat to change the end effector mass at change of value.
Definition: ForceDimensionDevice.h:71
EnableForce specializes SFBool to toggle forces on and off.
Definition: ForceDimensionDevice.h:83
GravityComp specializes SFBool to toggle gravity compensation on and off.
Definition: ForceDimensionDevice.h:65
Reset specializes SFBool to go into reset mode when a true event is received.
Definition: ForceDimensionDevice.h:53
SFAutoCalibrate specializes SFBool to go into auto calibrate mode when a true event is received.
Definition: ForceDimensionDevice.h:94
SFReleasePosition specializes SFVec3d to go set the release position of the contained haptics device.
Definition: ForceDimensionDevice.h:100
bool value_is_set
Just a flag used to check if the value was set before the hapi_device pointer was set.
Definition: ForceDimensionDevice.h:107
SFReleasePosition()
Constructor.
Definition: ForceDimensionDevice.h:103
WaitReset specializes SFBool to go into wait on reset mode when a true event is received.
Definition: ForceDimensionDevice.h:59
A ForceDimensionDevice is a node for handling communication with a haptics device from ForceDimension...
Definition: ForceDimensionDevice.h:48
H3DUniquePtr< SFReleasePosition > releaseDevicePosition
If this value is set, and HAPI was compiled with DRD support then when the device is released the dev...
Definition: ForceDimensionDevice.h:327
H3DUniquePtr< WaitReset > waitForReset
When a true event is received, the device is put into RESET mode and wait for the user to calibrate t...
Definition: ForceDimensionDevice.h:183
H3DUniquePtr< SFBool > flipGripperValues
If true then the gripper angle output is negated with respect to what the underlying dhd api reports.
Definition: ForceDimensionDevice.h:317
H3DUniquePtr< SFFloat > vibrationFrequency
On some (custom) devices from force dimension there are vibration support.
Definition: ForceDimensionDevice.h:249
H3DUniquePtr< SFBool > useGravityCompensation
Enable/disable gravity compensation.
Definition: ForceDimensionDevice.h:170
H3DUniquePtr< SFBool > isAutoCalibrated
Indicates whether the device is calibrated.
Definition: ForceDimensionDevice.h:293
H3DUniquePtr< EnableForce > enableForce
On some (custom) devices from force dimension there is no button to enable/disable forces on the devi...
Definition: ForceDimensionDevice.h:237
H3DUniquePtr< SFInt32 > deviceType
Contains the device type of the Force Dimension device.
Definition: ForceDimensionDevice.h:225
H3DUniquePtr< SFFloat > gripperForce
Output field for the gripper force.
Definition: ForceDimensionDevice.h:307
H3DUniquePtr< SFBool > useBrakes
Enable/disable the device electromagnetic brakes.
Definition: ForceDimensionDevice.h:200
H3DUniquePtr< SFInt32 > desiredComThreadRate
The desired frequency for the thread that communicates with the haptics device.
Definition: ForceDimensionDevice.h:302
static H3DNodeDatabase database
Node database entry.
Definition: ForceDimensionDevice.h:240
H3DUniquePtr< SFFloat > gripperAngle
Output field for the gripper angle.
Definition: ForceDimensionDevice.h:264
H3DUniquePtr< SFFloat > endEffectorMass
Set the end effector mass used in gravity compensation in order to provide accurate gravity compensat...
Definition: ForceDimensionDevice.h:190
H3DUniquePtr< Reset > reset
When a true event is received, the device is put into RESET mode.
Definition: ForceDimensionDevice.h:177
H3DUniquePtr< SFFloat > vibrationAmplitude
On some (custom) devices from force dimension there are vibration support.
Definition: ForceDimensionDevice.h:259
H3DUniquePtr< SFAutoCalibrate > autoCalibrate
When a true event is received, the device is auto calibrated.
Definition: ForceDimensionDevice.h:288
Base class for all haptic devices.
Definition: H3DHapticsDevice.h:68
Template for adding the virtual function onNewValue that can be overridden in subclasses in order to ...
Definition: FieldTemplates.h:79
Template for adding the virtual function onValueChange that can be overridden in subclasses in order ...
Definition: FieldTemplates.h:49
The PeriodicUpdate is a template modifier that changes the way the field is updated.
Definition: PeriodicUpdate.h:74
Vec3d()
float H3DFloat
H3D API namespace.
Definition: Anchor.h:38
The H3DNodeDatabase contains a mapping between a name of a Node and the constructor for the Node with...
Definition: H3DNodeDatabase.h:194