mtixdevice.cpp
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 "mtixdevice.h"
66 
67 #include <xstypes/xsdatapacket.h>
68 #include "replyobject.h"
69 #include "communicator.h"
70 #include "scenariomatchpred.h"
71 #include <xstypes/xsstatusflag.h>
72 
73 #include <xstypes/xssensorranges.h>
74 #include "synclinegmt.h"
75 #include <xstypes/xssyncsetting.h>
76 
77 using namespace xsens;
78 
83  : MtiBaseDeviceEx(comm)
84 {
85  if (comm)
86  comm->setDefaultTimeout(2000); //Increase the default timeout for MTi-1 devices because a settings write can occasionally take ~900ms
87 }
88 
92 {
93 }
94 
98 {
100  result.m_frequency = 0;
101  result.m_divedable = true;
102 
103  if ((dataType == XDI_FreeAcceleration && deviceId().isImu()) ||
104  ((dataType & XDI_FullTypeMask) == XDI_LocationId) ||
105  ((dataType & XDI_FullTypeMask) == XDI_DeviceId))
106  return result;
107 
108  if ((dataType & XDI_FullTypeMask) == XDI_AccelerationHR || (dataType & XDI_FullTypeMask) == XDI_RateOfTurnHR)
109  {
110  bool isMtMk4_1_v1 = hardwareVersion().major() == 1;
111  bool isMtMk4_1_v2 = hardwareVersion().major() == 2;
112  result.m_frequency = isMtMk4_1_v2 ? 800 : 1000;
113  result.m_divedable = isMtMk4_1_v1 ? false : true;
114 
115  return result;
116  }
117 
118  auto baseFreq = [this](XsDataIdentifier dataType)
119  {
120  switch (dataType & XDI_TypeMask)
121  {
122  case XDI_None:
123  return 100;
124  case XDI_TimestampGroup:
125  return XDI_MAX_FREQUENCY_VAL;
126  case XDI_StatusGroup:
127  return 100;
129  return 100;
131  return deviceId().isImu() ? 0 : 100;
133  return 100;
135  return 100;
136  case XDI_MagneticGroup:
137  return 100;
138 
139  case XDI_GnssGroup:
140  return deviceId().isGnss() ? 4 : 0;
141  case XDI_PressureGroup:
142  return deviceId().isGnss() ? 50 : 0;
143  case XDI_PositionGroup:
144  return deviceId().isGnss() ? 100 : 0;
145  case XDI_VelocityGroup:
146  return deviceId().isGnss() ? 100 : 0;
147  default:
148  return 0;
149  }
150  };
151  result.m_frequency = baseFreq(dataType);
152 
153  if ((dataType & XDI_TypeMask) == XDI_TimestampGroup)
154  result.m_divedable = false;
155 
156  return result;
157 }
158 
162 {
163  return (firmwareVersion() >= XsVersion(1, 1, 0));
164 }
165 
167 {
169  | (deviceId().isImu() ? 0 : XSF_OrientationValid
172  )
173  | XSF_ClipAccX
174  | XSF_ClipAccY
175  | XSF_ClipAccZ
176  | XSF_ClipGyrX
177  | XSF_ClipGyrY
178  | XSF_ClipGyrZ
179  | XSF_ClipMagX
180  | XSF_ClipMagY
181  | XSF_ClipMagZ
182  //|XSF_Retransmitted
184  //|XSF_Interpolated
185  | XSF_SyncIn
186  | XSF_SyncOut
187  //|XSF_FilterMode
188  //|XSF_HaveGnssTimePulse
189  );
190 }
191 
195 {
196  XsString code = productCode();
197 
198  if (hardwareVersion() >= XsVersion(2, 0, 0))
199  code = stripProductCode(code);
200 
201  return code;
202 }
XSF_SyncIn
@ XSF_SyncIn
When set indicates a sync-in event has been triggered.
Definition: xsstatusflag.h:109
XDI_RateOfTurnHR
@ XDI_RateOfTurnHR
Rate of turn HR data.
Definition: xsdataidentifier.h:154
XsDevice::deviceId
XsDeviceId const & deviceId() const
Return the device ID of the device.
Definition: xsdevice_def.cpp:742
XDI_PositionGroup
@ XDI_PositionGroup
Group for position related outputs.
Definition: xsdataidentifier.h:140
scenariomatchpred.h
MtiXDevice::~MtiXDevice
virtual ~MtiXDevice()
Destroys a device.
Definition: mtixdevice.cpp:91
XDI_AccelerationGroup
@ XDI_AccelerationGroup
Group for acceleration related outputs.
Definition: xsdataidentifier.h:129
XDI_AngularVelocityGroup
@ XDI_AngularVelocityGroup
Group for angular velocity related outputs.
Definition: xsdataidentifier.h:151
MtiBaseDevice::BaseFrequencyResult::m_frequency
int m_frequency
A frequency value.
Definition: mtibasedevice.h:126
MtDevice::stripProductCode
static XsString stripProductCode(const XsString &code)
Helper function to strip the hardware type from the product code.
Definition: mtdevice.cpp:895
XSF_ClipGyrZ
@ XSF_ClipGyrZ
Definition: xsstatusflag.h:101
XDI_None
@ XDI_None
Empty datatype.
Definition: xsdataidentifier.h:86
XDI_DeviceId
@ XDI_DeviceId
DeviceId output.
Definition: xsdataidentifier.h:196
MtDevice::productCode
XsString productCode() const
Return the product code of the device.
Definition: mtdevice.cpp:497
XDI_VelocityGroup
@ XDI_VelocityGroup
Group for velocity related outputs.
Definition: xsdataidentifier.h:189
MtiXDevice::getBaseFrequencyInternal
MtiBaseDevice::BaseFrequencyResult getBaseFrequencyInternal(XsDataIdentifier dataType=XDI_None) const override
Returns the base update rate (Hz) corresponding to the dataType. Returns 0 if no update rate is avail...
Definition: mtixdevice.cpp:97
xsstatusflag.h
XsVersion
struct XsVersion XsVersion
Definition: xsversion.h:80
MtDevice::hardwareVersion
XsVersion hardwareVersion() const
Return the hardware version of the device.
Definition: mtdevice.cpp:424
MtiXDevice::shortProductCode
XsString shortProductCode() const override
Return the shortened product code of the device suitable for display.
Definition: mtixdevice.cpp:194
XSF_ClippingDetected
@ XSF_ClippingDetected
When set Indicates clipping has occurred.
Definition: xsstatusflag.h:107
XSF_ClipMagZ
@ XSF_ClipMagZ
Definition: xsstatusflag.h:104
XSF_RepresentativeMotion
@ XSF_RepresentativeMotion
Indicates if the In-Run Compass Calibration is doing the representative motion analysis.
Definition: xsstatusflag.h:90
XDI_MagneticGroup
@ XDI_MagneticGroup
Group for magnetometer related outputs.
Definition: xsdataidentifier.h:172
XDI_FullTypeMask
@ XDI_FullTypeMask
Mask to get the type of data, without the data format.
Definition: xsdataidentifier.h:88
XSF_ClipAccX
@ XSF_ClipAccX
Definition: xsstatusflag.h:96
XDI_LocationId
@ XDI_LocationId
LocationId output.
Definition: xsdataidentifier.h:197
XSF_NoRotationMask
@ XSF_NoRotationMask
If all of these flags are set, the No Rotation algorithm is running.
Definition: xsstatusflag.h:85
XSF_ExternalClockSynced
@ XSF_ExternalClockSynced
Indicates whether the internal clock is synced with an external clock (Either GNNS or custom provided...
Definition: xsstatusflag.h:92
XSF_OrientationValid
@ XSF_OrientationValid
Is set when the computed orientation is valid. The orientation may be invalid during startup or when ...
Definition: xsstatusflag.h:82
XSF_ClipMagX
@ XSF_ClipMagX
Definition: xsstatusflag.h:102
XsDataIdentifier
XsDataIdentifier
Defines the data identifiers.
Definition: xsdataidentifier.h:84
Communicator
A base struct for a communication interface.
Definition: communicator.h:95
uint32_t
unsigned int uint32_t
Definition: pstdint.h:485
MtiXDevice::supportedStatusFlags
uint32_t supportedStatusFlags() const override
Returns a bitmask with all the status flags supported by this device.
Definition: mtixdevice.cpp:166
xssensorranges.h
XsDevice::firmwareVersion
virtual XsVersion firmwareVersion() const
Return the firmware version.
Definition: xsdevice_def.cpp:675
XSF_ClipGyrX
@ XSF_ClipGyrX
Definition: xsstatusflag.h:99
XDI_TimestampGroup
@ XDI_TimestampGroup
Group for time stamp related outputs.
Definition: xsdataidentifier.h:105
MtiXDevice::MtiXDevice
MtiXDevice(Communicator *comm)
Constructs a device.
Definition: mtixdevice.cpp:82
Communicator::setDefaultTimeout
void setDefaultTimeout(uint32_t timeout)
Sets a default timeout.
Definition: communicator.h:139
XDI_GnssGroup
@ XDI_GnssGroup
Group for Gnss related outputs.
Definition: xsdataidentifier.h:146
replyobject.h
XDI_StatusGroup
@ XDI_StatusGroup
Group for status related outputs.
Definition: xsdataidentifier.h:192
xsdatapacket.h
XSF_ClipGyrY
@ XSF_ClipGyrY
Definition: xsstatusflag.h:100
mtixdevice.h
XDI_MAX_FREQUENCY_VAL
#define XDI_MAX_FREQUENCY_VAL
Definition: xsdataidentifiervalue.h:69
XDI_FreeAcceleration
@ XDI_FreeAcceleration
Free acceleration output in m/s2.
Definition: xsdataidentifier.h:132
XSF_ClipAccZ
@ XSF_ClipAccZ
Definition: xsstatusflag.h:98
xssyncsetting.h
XSF_SyncOut
@ XSF_SyncOut
When set Indicates a sync-out event has been generated.
Definition: xsstatusflag.h:110
MtiXDevice::hasIccSupport
bool hasIccSupport() const override
Definition: mtixdevice.cpp:161
MtiBaseDevice::BaseFrequencyResult::m_divedable
bool m_divedable
A divedable value.
Definition: mtibasedevice.h:127
XSF_ClipMagY
@ XSF_ClipMagY
Definition: xsstatusflag.h:103
synclinegmt.h
XSF_ClipAccY
@ XSF_ClipAccY
Definition: xsstatusflag.h:97
XDI_PressureGroup
@ XDI_PressureGroup
Group for pressure related outputs.
Definition: xsdataidentifier.h:126
XDI_OrientationGroup
@ XDI_OrientationGroup
Group for orientation related outputs.
Definition: xsdataidentifier.h:117
XDI_TemperatureGroup
@ XDI_TemperatureGroup
Group for temperature outputs.
Definition: xsdataidentifier.h:102
communicator.h
MtiBaseDevice::BaseFrequencyResult
A struct for base frequency result.
Definition: mtibasedevice.h:124
XsString
A 0-terminated managed string of characters.
xsens
Definition: threading.cpp:78
XDI_TypeMask
@ XDI_TypeMask
Mask for checking the group which a dataidentifier belongs to, Eg. XDI_TimestampGroup or XDI_Orientat...
Definition: xsdataidentifier.h:87
XDI_AccelerationHR
@ XDI_AccelerationHR
AccelerationHR output.
Definition: xsdataidentifier.h:133
MtiBaseDeviceEx
The internal base class for MTi devices.
Definition: mtibasedevice.h:161


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