00001 #ifndef _CMT_MONOLITHIC 00002 /*! \file 00003 \brief Contains the CMT Packet interface 00004 00005 This level contains the packet interface of Cmt. 00006 All code should be OS-independent. 00007 00008 \section FileCopyright Copyright Notice 00009 Copyright (C) Xsens Technologies B.V., 2006. All rights reserved. 00010 00011 This source code is intended for use only by Xsens Technologies BV and 00012 those that have explicit written permission to use it from 00013 Xsens Technologies BV. 00014 00015 THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY 00016 KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE 00017 IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 00018 PARTICULAR PURPOSE. 00019 00020 \section FileChangelog Changelog 00021 \par 2006-05-10, v0.0.1 00022 \li Job Mulder: Created Cmtpacket.h 00023 \par 2006-07-21, v0.1.0 00024 \li Job Mulder: Updated file for release 0.1.0 00025 */ 00026 #endif 00027 #ifndef _CMTPACKET_H_2006_05_10 00028 #define _CMTPACKET_H_2006_05_10 00029 00030 #ifndef _CMT_MONOLITHIC 00031 # include "cmtdef.h" 00032 # include "cmt2.h" 00033 #endif 00034 00035 namespace xsens { 00036 00037 00038 //! Indicates that a data item is not available in the packet 00039 #define CMT_DATA_ITEM_NOT_AVAILABLE 65535 00040 00041 //! A structure containing MT data + timestamp and formatting information. 00042 class Packet 00043 { 00044 friend class Cmt4; 00045 protected: 00046 //! Contains information about data in the packet and the format of that data 00047 mutable struct PacketInfo { 00048 uint16_t m_offset; 00049 uint16_t m_rawData; 00050 uint16_t m_rawAcc; 00051 uint16_t m_rawGyr; 00052 uint16_t m_rawMag; 00053 uint16_t m_rawTemp; 00054 uint16_t m_temp; 00055 uint16_t m_calData; 00056 uint16_t m_calAcc; 00057 uint16_t m_calGyr; 00058 uint16_t m_calMag; 00059 uint16_t m_oriQuat; 00060 uint16_t m_oriEul; 00061 uint16_t m_oriMat; 00062 uint16_t m_analogIn1; 00063 uint16_t m_analogIn2; 00064 uint16_t m_posLLA; 00065 uint16_t m_velNEDorNWU; 00066 uint16_t m_status; 00067 uint16_t m_sc; 00068 uint16_t m_utcTime; 00069 uint16_t m_utcNano; 00070 uint16_t m_utcYear; 00071 uint16_t m_utcMonth; 00072 uint16_t m_utcDay; 00073 uint16_t m_utcHour; 00074 uint16_t m_utcMinute; 00075 uint16_t m_utcSecond; 00076 uint16_t m_utcValid; 00077 uint16_t m_acc_g; 00078 uint16_t m_gpsPvtData; 00079 uint16_t m_gpsPvtPressure; 00080 uint16_t m_gpsPvtPressureAge; 00081 uint16_t m_gpsPvtGpsData; 00082 uint16_t m_gpsPvtItow; 00083 uint16_t m_gpsPvtLatitude; 00084 uint16_t m_gpsPvtLongitude; 00085 uint16_t m_gpsPvtHeight; 00086 uint16_t m_gpsPvtVeln; 00087 uint16_t m_gpsPvtVele; 00088 uint16_t m_gpsPvtVeld; 00089 uint16_t m_gpsPvtHacc; 00090 uint16_t m_gpsPvtVacc; 00091 uint16_t m_gpsPvtSacc; 00092 uint16_t m_gpsPvtGpsAge; 00093 uint16_t m_size; 00094 uint16_t m_doubleBoundary; 00095 }* m_infoList; 00096 CmtDataFormat* m_formatList; //!< A list of the formats of the data items 00097 bool m_xm; //!< Indicates that xbus-formatting is used 00098 00099 public: 00100 uint16_t m_itemCount; //!< The number of data items in the message 00101 Message m_msg; //!< The message 00102 TimeStamp m_rtc; //!< Sample time in ms, based on the sample counter 00103 TimeStamp m_toa; //!< Time of arrival 00104 00105 Packet(uint16_t items, bool xbus); 00106 Packet(const Packet& pack); 00107 ~Packet(); 00108 00109 void operator = (const Packet& pack); 00110 00111 bool setDataFormat(const CmtDataFormat& format, const uint16_t index = 0); 00112 bool setDataFormat(const CmtOutputMode outputMode, const CmtOutputSettings outputSettings, const uint16_t index = 0); 00113 CmtDataFormat getDataFormat(const uint16_t index = 0) const; 00114 void setXbus(bool xbus, bool convert = false); 00115 bool getXbus(void) const; 00116 00117 /*! \brief Return the data size. 00118 00119 \param index The index of the item of which the size should be returned. 00120 */ 00121 uint16_t getDataSize(const uint16_t index=0) const; 00122 00123 /*! \brief Return the floating/fixed point value size 00124 00125 \param index The index of the item whose fp size should be returned. 00126 */ 00127 uint16_t getFPValueSize(const uint16_t index) const; 00128 00129 /*! \brief Return the Raw Accelerometer component of a data item. 00130 00131 \param index The index of the item of which the data should be returned. 00132 */ 00133 CmtShortVector getRawAcc(const uint16_t index=0) const; 00134 //! Check if data item contains Raw Accelerometer data 00135 bool containsRawAcc(const uint16_t index=0) const; 00136 //! Add/update Raw Accelerometer data for the item 00137 bool updateRawAcc(const CmtShortVector& vec, const uint16_t index=0); 00138 /*! \brief Return the Raw Gyroscope component of a data item. 00139 00140 \param index The index of the item of which the data should be returned. 00141 */ 00142 CmtShortVector getRawGyr(const uint16_t index=0) const; 00143 //! Check if data item contains Raw Gyroscope data 00144 bool containsRawGyr(const uint16_t index=0) const; 00145 //! Add/update Raw Gyroscope data for the item 00146 bool updateRawGyr(const CmtShortVector& vec, const uint16_t index=0); 00147 /*! \brief Return the Raw Magnetometer component of a data item. 00148 00149 \param index The index of the item of which the data should be returned. 00150 */ 00151 CmtShortVector getRawMag(const uint16_t index=0) const; 00152 //! Check if data item contains Raw Magnetometer data 00153 bool containsRawMag(const uint16_t index=0) const; 00154 //! Add/update Raw Magnetometer data for the item 00155 bool updateRawMag(const CmtShortVector& vec, const uint16_t index=0); 00156 /*! \brief Return the Raw Temperature component of a data item. 00157 00158 \param index The index of the item of which the data should be returned. 00159 */ 00160 uint16_t getRawTemp(const uint16_t index=0) const; 00161 //! Check if data item contains Raw Temperature data 00162 bool containsRawTemp(const uint16_t index=0) const; 00163 //! Add/update Raw Temperature data for the item 00164 bool updateRawTemp(uint16_t temp, const uint16_t index=0); 00165 /*! \brief Return the Raw Data component of a data item. 00166 00167 \param index The index of the item of which the data should be returned. 00168 */ 00169 CmtRawData getRawData(const uint16_t index=0) const; 00170 //! Check if data item contains Raw Data 00171 bool containsRawData(const uint16_t index=0) const; 00172 //! Add/update Raw Data for the item 00173 bool updateRawData(const CmtRawData& data, const uint16_t index=0); 00174 /*! \brief Return the Gps PVT data component of a data item. 00175 \param index The index of the item of which the data should be returned. 00176 */ 00177 CmtGpsPvtData getGpsPvtData(const uint16_t index=0) const; 00178 //! Check if data item contains Gps PVT Data 00179 bool containsGpsPvtData(const uint16_t index=0) const; 00180 //! Add/update Gps PVT Data for the item 00181 bool updateGpsPvtData(const CmtGpsPvtData& data, const uint16_t index=0); 00182 00183 //! This function is obsolete, use getGpsPvtData instead. This function will be removed in future versions of the MT SDK. \see getGpsPvtData 00184 #define getRawGpsData getGpsPvtData 00185 //! This function is obsolete, use containsGpsPvtData instead. This function will be removed in future versions of the MT SDK. \see containsGpsPvtData 00186 #define containsRawGpsData containsGpsPvtData 00187 //! This function is obsolete, use updateGpsPvtData instead. This function will be removed in future versions of the MT SDK. \see updateGpsPvtData 00188 #define updateRawGpsData updateGpsPvtData 00189 00190 /*! \brief Return the Raw Pressure Data component of a data item. 00191 \param index The index of the item of which the data should be returned. 00192 */ 00193 CmtRawPressureData getRawPressureData(const uint16_t index=0) const; 00194 //! Check if data item contains Raw Pressure Data 00195 bool containsRawPressureData(const uint16_t index=0) const; 00196 //! Add/update Raw Pressure Data for the item 00197 bool updateRawPressureData(const CmtRawPressureData& data, const uint16_t index=0); 00198 00199 /*! \brief Return the Temperature component of a data item. 00200 00201 \param index The index of the item of which the data should be returned. 00202 */ 00203 double getTemp(const uint16_t index=0) const; 00204 //! Check if data item contains Temperature data 00205 bool containsTemp(const uint16_t index=0) const; 00206 //! Add/update Calibrated Accelerometer data for the item 00207 bool updateTemp(const double& temp, const uint16_t index=0); 00208 /*! \brief Return the Calibrated Accelerometer component of a data item. 00209 00210 \param index The index of the item of which the data should be returned. 00211 */ 00212 CmtVector getCalAcc(const uint16_t index=0) const; 00213 //! Check if data item contains Calibrated Accelerometer data 00214 bool containsCalAcc(const uint16_t index=0) const; 00215 //! Add/update Calibrated Accelerometer data for the item 00216 bool updateCalAcc(const CmtVector& vec, const uint16_t index=0); 00217 /*! \brief Return the Calibrated Gyroscope component of a data item. 00218 00219 \param index The index of the item of which the data should be returned. 00220 */ 00221 CmtVector getCalGyr(const uint16_t index=0) const; 00222 //! Check if data item contains Calibrated Gyroscope data 00223 bool containsCalGyr(const uint16_t index=0) const; 00224 //! Add/update Calibrated Gyroscope data for the item 00225 bool updateCalGyr(const CmtVector& vec, const uint16_t index=0); 00226 /*! \brief Return the Calibrated Magnetometer component of a data item. 00227 00228 \param index The index of the item of which the data should be returned. 00229 */ 00230 CmtVector getCalMag(const uint16_t index=0) const; 00231 //! Check if data item contains Calibrated Magnetometer data 00232 bool containsCalMag(const uint16_t index=0) const; 00233 //! Add/update Calibrated Magnetometer data for the item 00234 bool updateCalMag(const CmtVector& vec, const uint16_t index=0); 00235 /*! \brief Return the Calibrated Data component of a data item. 00236 00237 \param index The index of the item of which the data should be returned. 00238 */ 00239 CmtCalData getCalData(const uint16_t index=0) const; 00240 //! Check if data item contains Calibrated Data 00241 bool containsCalData(const uint16_t index=0) const; 00242 //! Add/update Calibrated Data for the item 00243 bool updateCalData(const CmtCalData& data, const uint16_t index=0); 00244 00245 /*! \brief Return the Orientation component of a data item as a Quaternion. 00246 00247 \param index The index of the item of which the data should be returned. 00248 */ 00249 CmtQuat getOriQuat(const uint16_t index=0) const; 00250 //! Check if data item contains Quaternion Orientation data 00251 bool containsOriQuat(const uint16_t index=0) const; 00252 //! Add/update Quaternion Orientation data for the item 00253 bool updateOriQuat(const CmtQuat& data, const uint16_t index=0); 00254 /*! \brief Return the Orientation component of a data item as Euler angles. 00255 00256 \param index The index of the item of which the data should be returned. 00257 */ 00258 CmtEuler getOriEuler(const uint16_t index=0) const; 00259 //! Check if data item contains Euler Orientation data 00260 bool containsOriEuler(const uint16_t index=0) const; 00261 //! Add/update Euler Orientation data for the item 00262 bool updateOriEuler(const CmtEuler& data, const uint16_t index=0); 00263 /*! \brief Return the Orientation component of a data item as an Orientation Matrix. 00264 00265 \param index The index of the item of which the data should be returned. 00266 */ 00267 CmtMatrix getOriMatrix(const uint16_t index=0) const; 00268 //! Check if data item contains Matrix Orientation data 00269 bool containsOriMatrix(const uint16_t index=0) const; 00270 //! Add/update Matrix Orientation data for the item 00271 bool updateOriMatrix(const CmtMatrix& data, const uint16_t index=0); 00272 00273 //! Check if data item contains Orientation Data of any kind 00274 bool containsOri(const uint16_t index=0) const; 00275 00276 /*! \brief Return the AnalogIn 1 component of a data item. 00277 00278 \param index The index of the item of which the data should be returned. 00279 */ 00280 CmtAnalogInData getAnalogIn1(const uint16_t index=0) const; 00281 //! Check if data item contains AnalogIn 1 00282 bool containsAnalogIn1(const uint16_t index=0) const; 00283 //! Add/update AnalogIn 1 for the item 00284 bool updateAnalogIn1(const CmtAnalogInData& data, const uint16_t index=0); 00285 00286 /*! \brief Return the AnalogIn 2 component of a data item. 00287 00288 \param index The index of the item of which the data should be returned. 00289 */ 00290 CmtAnalogInData getAnalogIn2(const uint16_t index=0) const; 00291 //! Check if data item contains AnalogIn 2 00292 bool containsAnalogIn2(const uint16_t index=0) const; 00293 //! Add/update AnalogIn 2 for the item 00294 bool updateAnalogIn2(const CmtAnalogInData& data, const uint16_t index=0); 00295 00296 /*! \brief Return the Position Lat Lon Alt component of a data item. 00297 00298 \param index The index of the item of which the data should be returned. 00299 */ 00300 CmtVector getPositionLLA(const uint16_t index=0) const; 00301 //! Check if data item contains Position Lat Lon Alt 00302 bool containsPositionLLA(const uint16_t index=0) const; 00303 //! Add/update Position Lat Lon Alt for the item 00304 bool updatePositionLLA(const CmtVector& data, const uint16_t index=0); 00305 00306 /*! \brief Return the Velocity component of a data item. 00307 00308 \param index The index of the item of which the data should be returned. 00309 */ 00310 CmtVector getVelocity(const uint16_t index=0) const; 00311 //! Check if data item contains Velocity 00312 bool containsVelocity(const uint16_t index=0) const; 00313 //! Add/update Velocity for the item 00314 bool updateVelocity(const CmtVector& data, const uint16_t index=0); 00315 00316 /*! \brief Return the Status component of a data item. 00317 00318 \param index The index of the item of which the data should be returned. 00319 */ 00320 uint8_t getStatus(const uint16_t index=0) const; 00321 //! Check if data item contains Status 00322 bool containsStatus(const uint16_t index=0) const; 00323 //! Add/update Status information for the item 00324 bool updateStatus(const uint8_t data, const uint16_t index=0); 00325 00326 /*! \brief Return the Sample Counter component of the packet. 00327 00328 \param index The index of the item of which the data should be returned. (ignored) 00329 */ 00330 uint16_t getSampleCounter(const uint16_t index=0) const; 00331 //! Check if data item contains Sample Counter 00332 bool containsSampleCounter(const uint16_t index=0) const; 00333 //! Add/update Sample Counter for all items 00334 bool updateSampleCounter(const uint16_t counter, const uint16_t index=0); 00335 00336 /*! \brief Return the UTC Time component of the packet. 00337 00338 \param index The index of the item of which the data should be returned. (ignored) 00339 */ 00340 CmtUtcTime getUtcTime(const uint16_t index=0) const; 00341 //! Check if data item contains UTC Time 00342 bool containsUtcTime(const uint16_t index=0) const; 00343 //! Add/update UTC Time for all items 00344 bool updateUtcTime(const CmtUtcTime& data, const uint16_t index=0); 00345 00346 /*! \brief Return the RTC of the packet. 00347 00348 \param index The index of the item of which the data should be returned. (ignored) 00349 */ 00350 CmtTimeStamp getRtc(const uint16_t index=0) const; 00351 00352 00353 /*! \brief Return the XKF-3 Acc-G component of the packet. 00354 00355 \param index The index of the item of which the data should be returned. 00356 */ 00357 CmtVector getAccG(const uint16_t index=0) const; 00358 //! Check if data item contains XKF-3 Acc-G data 00359 bool containsAccG(const uint16_t index=0) const; 00360 //! Add/update XKF-3 Acc-G data for the item 00361 bool updateAccG(const CmtVector& g, const uint16_t index=0); 00362 00363 #ifdef _CMT_DLL_EXPORT 00364 //! Interpolate so resulting packet is (1-f)*pa + pb OR pb if pa and pb are non-matching types 00365 void interpolate(const Packet& pa, const Packet& pb, const double f); 00366 #endif 00367 }; 00368 00369 } // end of xsens namespace 00370 00371 #endif // _CMTPACKET_H_2006_05_10