My Project
Loading...
Searching...
No Matches
CPhantomDevices.h
Go to the documentation of this file.
1//==============================================================================
2/*
3 Software License Agreement (BSD License)
4 Copyright (c) 2003-2024, 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.3.0
42*/
43//==============================================================================
44
45//------------------------------------------------------------------------------
46#ifndef CPhantomDevicesH
47#define CPhantomDevicesH
48//------------------------------------------------------------------------------
49#if defined(C_ENABLE_PHANTOM_DEVICE_SUPPORT)
50//------------------------------------------------------------------------------
52//------------------------------------------------------------------------------
53
54//------------------------------------------------------------------------------
55namespace chai3d {
56//------------------------------------------------------------------------------
57
58//==============================================================================
65//==============================================================================
66
67//------------------------------------------------------------------------------
68class cPhantomDevice;
69typedef 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
97 virtual ~cPhantomDevice();
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 getUserSwitches(unsigned int& a_userSwitches);
124
126 virtual bool setForceAndTorqueAndGripperForce(const cVector3d& a_force, const cVector3d& a_torque, double a_gripperForce);
127
128
129 //--------------------------------------------------------------------------
130 // PUBLIC STATIC METHODS:
131 //--------------------------------------------------------------------------
132
133public:
134
136 static unsigned int getNumDevices();
137
138
139 //--------------------------------------------------------------------------
140 // PROTECTED METHODS - DEVICE LIBRARY INITIALIZATION:
141 //--------------------------------------------------------------------------
142
143protected:
144
146 static bool openLibraries();
147
149 static bool closeLibraries();
150
151
152 //--------------------------------------------------------------------------
153 // PROTECTED MEMBERS - DEVICE LIBRARIES:
154 //--------------------------------------------------------------------------
155
156protected:
157
160
162 static unsigned int s_libraryCounter;
163
164
165 //--------------------------------------------------------------------------
166 // PROTECTED MEMBERS
167 //--------------------------------------------------------------------------
168
169protected:
170
173};
174
175//------------------------------------------------------------------------------
176} // namespace chai3d
177//------------------------------------------------------------------------------
178
179//------------------------------------------------------------------------------
180#endif // C_ENABLE_PHANTOM_DEVICE_SUPPORT
181//------------------------------------------------------------------------------
182#endif
183//------------------------------------------------------------------------------
Implements a base class for haptic devices.
This class implements a base class for haptic devices.
Definition CGenericHapticDevice.h:283
This class implements an interface to all 3D-System Phantom haptic devices.
Definition CPhantomDevices.h:87
static unsigned int s_libraryCounter
Number of instances for this class of devices currently using the libraries.
Definition CPhantomDevices.h:162
virtual bool open()
This method open a connection to the haptic device.
Definition CPhantomDevices.cpp:648
virtual bool calibrate(bool a_forceCalibration=false)
This method calibrates the haptic device.
Definition CPhantomDevices.cpp:700
static bool s_allocationTable[C_MAX_DEVICES]
Allocation table for devices of this class. true means that the device has been allocated,...
Definition CPhantomDevices.h:159
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 CPhantomDevices.cpp:800
virtual bool getPosition(cVector3d &a_position)
This method returns the position of the device.
Definition CPhantomDevices.cpp:722
static cPhantomDevicePtr create(unsigned int a_deviceNumber)
Shared cPhantomDevice allocator.
Definition CPhantomDevices.h:100
virtual bool getUserSwitches(unsigned int &a_userSwitches)
This method returns the status of all user switches [true = ON / false = OFF].
Definition CPhantomDevices.cpp:834
static bool closeLibraries()
This method closes libraries for this class of devices.
Definition CPhantomDevices.cpp:347
virtual bool close()
This method close the connection to the haptic device.
Definition CPhantomDevices.cpp:674
virtual bool getRotation(cMatrix3d &a_rotation)
This method returns orientation frame of the haptic device end-effector.
Definition CPhantomDevices.cpp:758
virtual ~cPhantomDevice()
Destructor of cPhantomDevice.
Definition CPhantomDevices.cpp:622
static bool openLibraries()
This method opens libraries for this class of devices.
Definition CPhantomDevices.cpp:177
static unsigned int getNumDevices()
This method returns the number of haptic devices available for this class of devices.
Definition CPhantomDevices.cpp:400
int m_deviceID
Device ID number among the Phantom devices connected to the computer.
Definition CPhantomDevices.h:172
Definition CAudioBuffer.cpp:57
const unsigned int C_MAX_DEVICES
Definition CGenericDevice.h:65
std::shared_ptr< cPhantomDevice > cPhantomDevicePtr
Definition CPhantomDevices.h:69
This class implements a 3D matrix.
Definition CMatrix3d.h:98
This class implements a 3D vector.
Definition CVector3d.h:89