xsglovedata.c
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 #include "xsglovedata.h"
66 #include "xsquaternion.h"
67 
72 #define SWAP(T, a, b) { T tmp = a; a = b; b = tmp; }
73 
81 void XsGloveData_construct(struct XsGloveData* thisPtr)
82 {
83  int i;
84  memset(thisPtr, 0, sizeof(XsGloveData));
85  for (i = 0; i < XSFINGERSEGMENTCOUNT; i++)
87 }
88 
92 void XsGloveData_destruct(struct XsGloveData* thisPtr)
93 {
94  // no destruction necessary, no dynamic memory allocated
95  (void)thisPtr;
96 }
97 
103 void XsGloveData_copy(struct XsGloveData* copy, struct XsGloveData const* src)
104 {
105  if (copy == src)
106  return;
107  int i;
108  copy->m_frameNumber = src->m_frameNumber;
110  for (i = 0; i < XSFINGERSEGMENTCOUNT; i++)
111  XsFingerData_copy(&copy->m_fingerData[i], &src->m_fingerData[i]);
112 }
113 
119 void XsGloveData_swap(struct XsGloveData* lhs, struct XsGloveData* rhs)
120 {
121  if (lhs == rhs)
122  return;
123  int i;
125  SWAP(uint16_t, lhs->m_validSampleFlags, rhs->m_validSampleFlags);
126  for (i = 0; i < XSFINGERSEGMENTCOUNT; i++)
127  XsFingerData_swap(&lhs->m_fingerData[i], &rhs->m_fingerData[i]);
128 }
129 
134 {
135  // XsQuaternion_construct(&thisPtr->m_orientationIncrement);
137  XsVector3_construct(&thisPtr->m_mag, 0);
138  thisPtr->m_flags = 0;
139 }
140 
144 void XsFingerData_destruct(struct XsFingerData* thisPtr)
145 {
146  // no destruction necessary, no dynamic memory allocated
147  (void)thisPtr;
148 }
149 
155 void XsFingerData_copy(struct XsFingerData* copy, struct XsFingerData const* src)
156 {
157  if (copy == src)
158  return;
161  XsVector3_copy(&copy->m_mag.m_vector, &src->m_mag);
162  copy->m_flags = src->m_flags;
163 }
164 
170 void XsFingerData_swap(struct XsFingerData* lhs, struct XsFingerData* rhs)
171 {
172  if (lhs == rhs)
173  return;
176  XsVector_swap(&lhs->m_mag.m_vector, &rhs->m_mag.m_vector);
177 
178  SWAP(uint16_t, lhs->m_flags, rhs->m_flags);
179 }
180 
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
SWAP
#define SWAP(T, a, b)
Definition: xsglovedata.c:72
xsquaternion.h
XsGloveData
A container for glove data.
Definition: xsglovedata.h:214
XsVector::XsVector_swap
void XsVector_swap(XsVector *a, XsVector *b)
Swap the contents of a and b.
Definition: xsvector.c:286
XsQuaternion::XsQuaternion_copy
void XsQuaternion_copy(XsQuaternion *copy, XsQuaternion const *src)
Copies the contents of thisPtr into copy.
Definition: xsquaternion.c:291
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
XsGloveData::m_validSampleFlags
uint16_t m_validSampleFlags
Flags describing the general validity of the data.
Definition: xsglovedata.h:312
XsVector3::XsVector3_copy
void XsVector3_copy(XsVector *copy, XsVector3 const *src)
Copy the contents of the XsVector3 to copy.
Definition: xsvector3.c:99
XSFINGERSEGMENTCOUNT
#define XSFINGERSEGMENTCOUNT
Definition: xsglovedata.h:99
XsFingerData::m_orientationIncrement
XsQuaternion m_orientationIncrement
The orientation increment for this segment.
Definition: xsglovedata.h:205
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
XsVector3::XsVector3_construct
void XsVector3_construct(XsVector3 *thisPtr, const XsReal *src)
Init the XsVector3 and copy the data from src into the vector if src is not null.
Definition: xsvector3.c:77
XsFingerData::m_velocityIncrement
XsVector3 m_velocityIncrement
The velocity increment for this segment.
Definition: xsglovedata.h:206
XsVector3::m_vector
XsVector m_vector
The underlying vector.
Definition: xsvector3.h:97
xsglovedata.h
XsQuaternion::XsQuaternion_swap
void XsQuaternion_swap(XsQuaternion *a, XsQuaternion *b)
Swap the contents of a and b.
Definition: xsquaternion.c:277
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
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
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