CHAI3D  3.0.0
CPhantomDevices.h
Go to the documentation of this file.
1 //==============================================================================
2 /*
3  Software License Agreement (BSD License)
4  Copyright (c) 2003-2015, 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 Federico Barbagli
40  \author Francois Conti
41  \version 3.0.0 $Rev: 1639 $
42 */
43 //==============================================================================
44 
45 //------------------------------------------------------------------------------
46 #ifndef CPhantomDevicesH
47 #define CPhantomDevicesH
48 //------------------------------------------------------------------------------
49 #if defined(C_ENABLE_PHANTOM_DEVICE_SUPPORT)
50 //------------------------------------------------------------------------------
52 //------------------------------------------------------------------------------
53 
54 //------------------------------------------------------------------------------
55 namespace chai3d {
56 //------------------------------------------------------------------------------
57 
58 //==============================================================================
65 //==============================================================================
66 
67 //------------------------------------------------------------------------------
69 typedef std::shared_ptr<cPhantomDevice> cPhantomDevicePtr;
70 //------------------------------------------------------------------------------
71 
72 //==============================================================================
85 //==============================================================================
87 {
88  public:
89  //--------------------------------------------------------------------------
90  // CONSTRUCTOR & DESTRUCTOR:
91  //--------------------------------------------------------------------------
92 
94  cPhantomDevice(unsigned int a_deviceNumber);
95 
98 
100  static cPhantomDevicePtr create(unsigned int a_deviceNumber) { return (std::make_shared<cPhantomDevice>(a_deviceNumber)); }
101 
102 
103  //--------------------------------------------------------------------------
104  // PUBLIC METHODS:
105  //--------------------------------------------------------------------------
106 
108  virtual bool open();
109 
111  virtual bool close();
112 
114  virtual bool calibrate(bool a_forceCalibration = false);
115 
117  virtual bool getPosition(cVector3d& a_position);
118 
120  virtual bool getRotation(cMatrix3d& a_rotation);
121 
123  virtual bool setForce(const cVector3d& a_force);
124 
126  virtual bool setForceAndTorque(const cVector3d& a_force, const cVector3d& a_torque);
127 
129  virtual bool getUserSwitches(unsigned int& a_userSwitches);
130 
131 
132  //--------------------------------------------------------------------------
133  // PUBLIC STATIC METHODS:
134  //--------------------------------------------------------------------------
135 
136 public:
137 
139  static unsigned int getNumDevices();
140 
141 
142  //--------------------------------------------------------------------------
143  // PROTECTED METHODS - DEVICE LIBRARY INITIALIZATION:
144  //--------------------------------------------------------------------------
145 
146 protected:
147 
149  static bool openLibraries();
150 
152  static bool closeLibraries();
153 
154 
155  //--------------------------------------------------------------------------
156  // PROTECTED MEMBERS - DEVICE LIBRARIES:
157  //--------------------------------------------------------------------------
158 
159 protected:
160 
163 
165  static unsigned int s_libraryCounter;
166 
167 
168  //--------------------------------------------------------------------------
169  // PROTECTED MEMBERS
170  //--------------------------------------------------------------------------
171 
172 protected:
173 
176 };
177 
178 //------------------------------------------------------------------------------
179 } // namespace chai3d
180 //------------------------------------------------------------------------------
181 
182 //------------------------------------------------------------------------------
183 #endif // C_ENABLE_PHANTOM_DEVICE_SUPPORT
184 //------------------------------------------------------------------------------
185 #endif
186 //------------------------------------------------------------------------------
This class implements a 3D vector.
Definition: CVector3d.h:85
int m_deviceID
Device ID number among the Phantom devices connected to the computer.
Definition: CPhantomDevices.h:175
static bool openLibraries()
This method opens libraries for this class of devices.
Definition: CPhantomDevices.cpp:177
virtual bool close()
This method close the connection to the haptic device.
Definition: CPhantomDevices.cpp:659
virtual bool setForce(const cVector3d &a_force)
This method sends a force [N] to the haptic device.
Definition: CPhantomDevices.cpp:782
virtual bool calibrate(bool a_forceCalibration=false)
This method calibrates the haptic device.
Definition: CPhantomDevices.cpp:685
const unsigned int C_MAX_DEVICES
Definition: CGenericDevice.h:65
virtual bool getPosition(cVector3d &a_position)
This method returns the position of the device.
Definition: CPhantomDevices.cpp:707
Implements a base class for haptic devices.
This class implements a 3D matrix.
Definition: CMatrix3d.h:97
~cPhantomDevice()
Destructor of cPhantomDevice.
Definition: CPhantomDevices.cpp:607
virtual bool open()
This method open a connection to the haptic device.
Definition: CPhantomDevices.cpp:633
static bool closeLibraries()
This method closes libraries for this class of devices.
Definition: CPhantomDevices.cpp:342
This class implements a base class for haptic devices.
Definition: CGenericHapticDevice.h:273
virtual bool getRotation(cMatrix3d &a_rotation)
This method returns orientation frame of the haptic device end-effector.
Definition: CPhantomDevices.cpp:743
static unsigned int s_libraryCounter
Number of instances for this class of devices currently using the libraries.
Definition: CPhantomDevices.h:165
cPhantomDevice(unsigned int a_deviceNumber)
Constructor of cPhantomDevice.
Definition: CPhantomDevices.cpp:413
std::shared_ptr< cPhantomDevice > cPhantomDevicePtr
Definition: CPhantomDevices.h:68
virtual bool setForceAndTorque(const cVector3d &a_force, const cVector3d &a_torque)
This method send a force [N] and torque [N*m] to the haptic device.
Definition: CPhantomDevices.cpp:813
static bool s_allocationTable[C_MAX_DEVICES]
Allocation table for devices of this class. true means that the device has been allocated, false means free.
Definition: CPhantomDevices.h:162
virtual bool getUserSwitches(unsigned int &a_userSwitches)
This method returns the status of all user switches [true = ON / false = OFF].
Definition: CPhantomDevices.cpp:847
static unsigned int getNumDevices()
This method returns the number of haptic devices available for this class of devices.
Definition: CPhantomDevices.cpp:386
This class implements an interface to all 3D-System Phantom haptic devices.
Definition: CPhantomDevices.h:86
Definition: CAudioBuffer.cpp:56
static cPhantomDevicePtr create(unsigned int a_deviceNumber)
Shared cPhantomDevice allocator.
Definition: CPhantomDevices.h:100

CHAI3D 3.0.0 documentation
Please address any questions to support@chai3d.org
(C) 2003-2015 - CHAI3D
All Rights Reserved.