My Project
Loading...
Searching...
No Matches
CLeapDevices.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 Sebastien Grange
40 \version 3.3.0
41*/
42//==============================================================================
43
44//------------------------------------------------------------------------------
45#ifndef CLeapDevicesH
46#define CLeapDevicesH
47//------------------------------------------------------------------------------
48#if defined(C_ENABLE_LEAP_DEVICE_SUPPORT)
49//------------------------------------------------------------------------------
51//------------------------------------------------------------------------------
52
53//------------------------------------------------------------------------------
54namespace chai3d {
55//------------------------------------------------------------------------------
56
57//==============================================================================
64//==============================================================================
65
66//------------------------------------------------------------------------------
67class cLeapDevice;
68typedef std::shared_ptr<cLeapDevice> cLeapDevicePtr;
69//------------------------------------------------------------------------------
70
71//==============================================================================
84//==============================================================================
86{
87 //--------------------------------------------------------------------------
88 // CONSTRUCTOR & DESTRUCTOR:
89 //--------------------------------------------------------------------------
90
91public:
92
94 cLeapDevice(unsigned int a_deviceNumber = 0);
95
97 virtual ~cLeapDevice();
98
100 static cLeapDevicePtr create(unsigned int a_deviceNumber = 0) { return (std::make_shared<cLeapDevice>(a_deviceNumber)); }
101
102
103 //--------------------------------------------------------------------------
104 // PUBLIC METHODS:
105 //--------------------------------------------------------------------------
106
107 public:
108
110 virtual bool open();
111
113 virtual bool close();
114
116 virtual bool calibrate(bool a_forceCalibration = false);
117
119 virtual bool getPosition(cVector3d& a_position);
120
122 virtual bool getRotation(cMatrix3d& a_rotation);
123
125 virtual bool getGripperAngleRad(double& a_angle);
126
128 virtual bool getUserSwitches(unsigned int& a_userSwitches);
129
130
131 //--------------------------------------------------------------------------
132 // PUBLIC STATIC METHODS:
133 //--------------------------------------------------------------------------
134
135public:
136
138 static unsigned int getNumDevices();
139
140
141 //--------------------------------------------------------------------------
142 // PROTECTED METHODS - DEVICE LIBRARY INITIALIZATION:
143 //--------------------------------------------------------------------------
144
145protected:
146
148 static bool openLibraries();
149
151 static bool closeLibraries();
152
153
154 //--------------------------------------------------------------------------
155 // PROTECTED MEMBERS - DEVICE LIBRARIES:
156 //--------------------------------------------------------------------------
157
158protected:
159
161 static unsigned int s_libraryCounter;
162
163
164 //--------------------------------------------------------------------------
165 // PROTECTED METHODS
166 //--------------------------------------------------------------------------
167
168protected:
169
171 bool updateData();
172};
173
174//------------------------------------------------------------------------------
175} // namespace chai3ds
176//------------------------------------------------------------------------------
177
178//------------------------------------------------------------------------------
179#endif //_DISABLE_LEAP_DEVICE_SUPPORT
180//------------------------------------------------------------------------------
181#endif
182//------------------------------------------------------------------------------
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 the Leap Motion tracker interface.
Definition CLeapDevices.h:86
virtual bool close()
This method closes the connection to the device.
Definition CLeapDevices.cpp:375
virtual bool getPosition(cVector3d &a_position)
This method returns the position of the device.
Definition CLeapDevices.cpp:425
static unsigned int s_libraryCounter
Number of instances for this class of devices currently using the libraries.
Definition CLeapDevices.h:161
virtual bool getRotation(cMatrix3d &a_rotation)
This method returns the orientation frame of the device end-effector.
Definition CLeapDevices.cpp:459
virtual ~cLeapDevice()
Destructor of cLeapDevice.
Definition CLeapDevices.cpp:323
virtual bool calibrate(bool a_forceCalibration=false)
This method calibrates the device.
Definition CLeapDevices.cpp:403
virtual bool open()
This method opens a connection to the device.
Definition CLeapDevices.cpp:340
static bool closeLibraries()
This method closes the libraries for this class of devices.
Definition CLeapDevices.cpp:192
virtual bool getUserSwitches(unsigned int &a_userSwitches)
This method returns the status of all user switches [true = ON / false = OFF].
Definition CLeapDevices.cpp:537
bool updateData()
Update data from controllers.
Definition CLeapDevices.cpp:569
static unsigned int getNumDevices()
This method returns the number of haptic devices available for this class of devices.
Definition CLeapDevices.cpp:240
virtual bool getGripperAngleRad(double &a_angle)
This method returns the gripper angle in radian [rad].
Definition CLeapDevices.cpp:496
static bool openLibraries()
This method opens the libraries for this class of devices.
Definition CLeapDevices.cpp:106
static cLeapDevicePtr create(unsigned int a_deviceNumber=0)
Shared cPhantomDevice allocator.
Definition CLeapDevices.h:100
Definition CAudioBuffer.cpp:57
std::shared_ptr< cLeapDevice > cLeapDevicePtr
Definition CLeapDevices.h:68
This class implements a 3D matrix.
Definition CMatrix3d.h:98
This class implements a 3D vector.
Definition CVector3d.h:89