xsglovedata.h
Go to the documentation of this file.
1 
2 // Copyright (c) 2003-2021 Xsens Technologies B.V. or subsidiaries worldwide.
3 // All rights reserved.
4 //
5 // Redistribution and use in source and binary forms, with or without modification,
6 // are permitted provided that the following conditions are met:
7 //
8 // 1. Redistributions of source code must retain the above copyright notice,
9 // this list of conditions, and the following disclaimer.
10 //
11 // 2. Redistributions in binary form must reproduce the above copyright notice,
12 // this list of conditions, and the following disclaimer in the documentation
13 // and/or other materials provided with the distribution.
14 //
15 // 3. Neither the names of the copyright holders nor the names of their contributors
16 // may be used to endorse or promote products derived from this software without
17 // specific prior written permission.
18 //
19 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
20 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
21 // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
22 // THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 // SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
24 // OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY OR
26 // TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.THE LAWS OF THE NETHERLANDS
28 // SHALL BE EXCLUSIVELY APPLICABLE AND ANY DISPUTES SHALL BE FINALLY SETTLED UNDER THE RULES
29 // OF ARBITRATION OF THE INTERNATIONAL CHAMBER OF COMMERCE IN THE HAGUE BY ONE OR MORE
30 // ARBITRATORS APPOINTED IN ACCORDANCE WITH SAID RULES.
31 //
32 
33 
34 // Copyright (c) 2003-2021 Xsens Technologies B.V. or subsidiaries worldwide.
35 // All rights reserved.
36 //
37 // Redistribution and use in source and binary forms, with or without modification,
38 // are permitted provided that the following conditions are met:
39 //
40 // 1. Redistributions of source code must retain the above copyright notice,
41 // this list of conditions, and the following disclaimer.
42 //
43 // 2. Redistributions in binary form must reproduce the above copyright notice,
44 // this list of conditions, and the following disclaimer in the documentation
45 // and/or other materials provided with the distribution.
46 //
47 // 3. Neither the names of the copyright holders nor the names of their contributors
48 // may be used to endorse or promote products derived from this software without
49 // specific prior written permission.
50 //
51 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
52 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
53 // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
54 // THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
55 // SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
56 // OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
57 // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY OR
58 // TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
59 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.THE LAWS OF THE NETHERLANDS
60 // SHALL BE EXCLUSIVELY APPLICABLE AND ANY DISPUTES SHALL BE FINALLY SETTLED UNDER THE RULES
61 // OF ARBITRATION OF THE INTERNATIONAL CHAMBER OF COMMERCE IN THE HAGUE BY ONE OR MORE
62 // ARBITRATORS APPOINTED IN ACCORDANCE WITH SAID RULES.
63 //
64 
65 #ifndef XSGLOVEDATA_H
66 #define XSGLOVEDATA_H
67 
68 #include "xstypesconfig.h"
69 #include "xsvector3.h"
70 #include "xsquaternion.h"
71 
72 struct XsGloveData;
73 struct XsFingerData;
74 
75 #ifdef __cplusplus
76 extern "C" {
77 #endif
78 #ifndef __cplusplus
79 #define XSFINGERDATA_INITIALIZER { XSQUATERNION_INITIALIZER, XSVECTOR3_INITIALIZER, XSVECTOR3_INITIALIZER, 0, 0, 0}
80 #define XSGLOVEDATA_INITIALIZER { XSFINGERDATA_INITIALIZER, XSFINGERDATA_INITIALIZER, XSFINGERDATA_INITIALIZER, XSFINGERDATA_INITIALIZER, XSFINGERDATA_INITIALIZER, XSFINGERDATA_INITIALIZER, \
81  XSFINGERDATA_INITIALIZER, XSFINGERDATA_INITIALIZER, XSFINGERDATA_INITIALIZER, XSFINGERDATA_INITIALIZER, XSFINGERDATA_INITIALIZER, XSFINGERDATA_INITIALIZER, \
82  0 ,0 ,0 ,0 }
83 #endif
84 
87 XSTYPES_DLL_API void XsFingerData_copy(struct XsFingerData* copy, struct XsFingerData const* src);
88 XSTYPES_DLL_API void XsFingerData_swap(struct XsFingerData* lhs, struct XsFingerData* rhs);
89 
92 XSTYPES_DLL_API void XsGloveData_copy(struct XsGloveData* copy, struct XsGloveData const* src);
93 XSTYPES_DLL_API void XsGloveData_swap(struct XsGloveData* lhs, struct XsGloveData* rhs);
94 
95 #ifdef __cplusplus
96 } // extern "C"
97 #endif
98 
99 #define XSFINGERSEGMENTCOUNT 12
100 
104 {
105 #ifdef __cplusplus
106  inline XsFingerData()
108  : m_flags(0)
109  {
110  }
111 
113  inline XsFingerData(const XsQuaternion& dq, const XsVector& dv, const XsVector& mag, const uint16_t flags)
115  , m_velocityIncrement(dv)
116  , m_mag(mag)
117  , m_flags(flags)
118  {
119  }
120 
122  inline XsFingerData(const XsFingerData& other)
125  , m_mag(other.m_mag)
126  , m_flags(other.m_flags)
127  {
128  }
129 
131  inline const XsFingerData& operator=(const XsFingerData& other)
132  {
133  if (this != &other)
134  {
137  m_mag = other.m_mag;
138  m_flags = other.m_flags;
139  }
140  return *this;
141  }
142 
144  inline void clear()
145  {
146  m_orientationIncrement = XsQuaternion::identity();
147  m_velocityIncrement.setZero();
148  m_mag.setZero();
149  }
150 
152  inline const XsQuaternion& orientationIncrement() const
153  {
154  return m_orientationIncrement;
155  }
156 
158  inline const XsVector3& velocityIncrement() const
159  {
160  return m_velocityIncrement;
161  }
162 
164  inline const XsVector3& mag() const
165  {
166  return m_mag;
167  }
168 
170  inline uint16_t flags() const
171  {
172  return m_flags;
173  }
174 
176  inline bool operator == (const XsFingerData& other) const
177  {
180  m_mag == other.m_mag &&
181  m_flags == other.m_flags;
182  }
183 
185  inline bool operator != (const XsFingerData& other) const
186  {
187  return !operator==(other);
188  }
189 
191  inline void swap(XsFingerData& other)
192  {
193  XsFingerData_swap(this, &other);
194  }
195 
197  friend void swap(XsFingerData& first, XsFingerData& second)
198  {
199  first.swap(second);
200  }
201 
202 protected:
203 #endif
204 
208  uint16_t m_flags;
209 };
210 typedef struct XsFingerData XsFingerData;
211 
215 {
216 #ifdef __cplusplus
217  inline XsGloveData()
219  : m_frameNumber(0)
220  , m_validSampleFlags(0)
221  {
222  }
223 
225  inline XsGloveData(const uint16_t frameNumber, const uint16_t validSampleFlags, const XsFingerData* fingerData)
226  : m_frameNumber(frameNumber)
227  , m_validSampleFlags(validSampleFlags)
228  {
229  for (int i = 0; i < XSFINGERSEGMENTCOUNT; ++i)
230  m_fingerData[i] = fingerData[i];
231  }
232 
234  inline XsGloveData(const XsGloveData& other)
237  {
238  for (int i = 0; i < XSFINGERSEGMENTCOUNT; ++i)
239  m_fingerData[i] = other.m_fingerData[i];
240  }
241 
243  inline uint32_t frameNumber() const
244  {
245  return m_frameNumber;
246  }
247 
249  inline uint16_t validSampleFlags() const
250  {
251  return m_validSampleFlags;
252  }
253 
254 
256  inline static int fingerSegmentCount()
257  {
258  return XSFINGERSEGMENTCOUNT;
259  }
260 
262  inline XsFingerData const& fingerData(int i) const
263  {
264  assert(i >= 0 && i < XSFINGERSEGMENTCOUNT);
265  return m_fingerData[i];
266  }
267 
269  inline bool operator == (const XsGloveData& other) const
270  {
271  if (m_frameNumber != other.m_frameNumber ||
273  return false;
274 
275  for (int i = 0; i < XSFINGERSEGMENTCOUNT; ++i)
276  {
277  if (!(m_fingerData[i] == other.m_fingerData[i]))
278  return false;
279  }
280  return true;
281  }
282 
284  inline bool operator != (const XsGloveData& other) const
285  {
286  return !operator==(other);
287  }
288 
290  inline XsGloveData const& operator = (XsGloveData const& other)
291  {
292  XsGloveData_copy(this, &other);
293  return *this;
294  }
295 
297  inline void swap(XsGloveData& other)
298  {
299  XsGloveData_swap(this, &other);
300  }
301 
303  friend void swap(XsGloveData& first, XsGloveData& second)
304  {
305  first.swap(second);
306  }
307 
308 protected:
309 #endif
313 };
314 
315 typedef struct XsGloveData XsGloveData;
316 
317 #endif
XsFingerData::XsFingerData_construct
void XsFingerData_construct(struct XsFingerData *thisPtr)
Initialize an XsFingerData object.
Definition: xsglovedata.c:133
XsFingerData::XsFingerData_swap
void XsFingerData_swap(struct XsFingerData *lhs, struct XsFingerData *rhs)
Swap the contents of two XsGloveData objects.
Definition: xsglovedata.c:170
XsVector
A class that represents a vector of real numbers.
Definition: xsvector.h:113
XsFingerData
struct XsFingerData XsFingerData
Definition: xsglovedata.h:210
xsquaternion.h
XsGloveData
A container for glove data.
Definition: xsglovedata.h:214
XsGloveData::m_frameNumber
uint32_t m_frameNumber
The sequential frame number for the data.
Definition: xsglovedata.h:311
XsFingerData::XsFingerData_destruct
void XsFingerData_destruct(struct XsFingerData *thisPtr)
Destruct an XsFingerData object.
Definition: xsglovedata.c:144
XsQuaternion
A class that implements a quaternion.
Definition: xsquaternion.h:102
XsGloveData::m_validSampleFlags
uint16_t m_validSampleFlags
Flags describing the general validity of the data.
Definition: xsglovedata.h:312
XSFINGERSEGMENTCOUNT
#define XSFINGERSEGMENTCOUNT
Definition: xsglovedata.h:99
XsFingerData::m_orientationIncrement
XsQuaternion m_orientationIncrement
The orientation increment for this segment.
Definition: xsglovedata.h:205
operator==
bool operator==(const XsFilterProfile &lhs, const XsFilterProfile &rhs)
Returns true if lhs has the same type as rhs.
Definition: scenariomatchpred.h:81
uint32_t
unsigned int uint32_t
Definition: pstdint.h:485
XsFingerData::XsFingerData_copy
void XsFingerData_copy(struct XsFingerData *copy, struct XsFingerData const *src)
Copy the contents of an XsFingerData object.
Definition: xsglovedata.c:155
XsFingerData
A container for Finger data.
Definition: xsglovedata.h:103
XsGloveData::XsGloveData_construct
void XsGloveData_construct(struct XsGloveData *thisPtr)
Initialize an XsGloveData object.
Definition: xsglovedata.c:81
XsFingerData::m_velocityIncrement
XsVector3 m_velocityIncrement
The velocity increment for this segment.
Definition: xsglovedata.h:206
xstypesconfig.h
XSTYPES_DLL_API
#define XSTYPES_DLL_API
Definition: xstypesconfig.h:65
XsGloveData::XsGloveData_copy
void XsGloveData_copy(struct XsGloveData *copy, struct XsGloveData const *src)
Copy the contents of an XsGloveData object.
Definition: xsglovedata.c:103
XsFingerData::m_flags
uint16_t m_flags
Data quality flags (LSB --> MSB: acc x,y,z gyr x,y,z mag x,y,z)
Definition: xsglovedata.h:208
xsvector3.h
XsVector3
A class that represents a fixed size (3) vector.
Definition: xsvector3.h:95
XsGloveData::XsGloveData_swap
void XsGloveData_swap(struct XsGloveData *lhs, struct XsGloveData *rhs)
Swap the contents of two XsGloveData objects.
Definition: xsglovedata.c:119
XsGloveData::XsGloveData_destruct
void XsGloveData_destruct(struct XsGloveData *thisPtr)
Destruct an XsGloveData object.
Definition: xsglovedata.c:92
XsGloveData
struct XsGloveData XsGloveData
Definition: xsglovedata.h:315
XsFingerData::m_mag
XsVector3 m_mag
The magnetic field data for this segment.
Definition: xsglovedata.h:207
XsGloveData::m_fingerData
XsFingerData m_fingerData[XSFINGERSEGMENTCOUNT]
Data for each tracked finger segment.
Definition: xsglovedata.h:310


xsens_mti_driver
Author(s):
autogenerated on Sun Sep 3 2023 02:43:20