mtdef.py
Go to the documentation of this file.
00001 """Constant and messages definition for MT communication."""
00002 
00003 
00004 class MID:
00005         """Values for the message id (MID)"""
00006         ## Error message, 1 data byte
00007         Error = 0x42
00008         ErrorCodes = {
00009                 0x03: "Invalid period",
00010                 0x04: "Invalid message",
00011                 0x1E: "Timer overflow",
00012                 0x20: "Invalid baudrate",
00013                 0x21: "Invalid parameter"
00014         }
00015 
00016         # State MID
00017         ## Wake up procedure
00018         WakeUp = 0x3E
00019         ## Switch to config state
00020         GoToConfig = 0x30
00021         ## Switch to measurement state
00022         GoToMeasurement = 0x10
00023         ## Reset device
00024         Reset = 0x40
00025 
00026         # Informational messages
00027         ## Request device id
00028         ReqDID = 0x00
00029         ## DeviceID, 4 bytes: HH HL LH LL
00030         DeviceID = 0x01
00031         ## Compatibility for XBus Master users
00032         InitMT = 0x02
00033         InitMTResults = 0x03
00034         ## Request product code in plain text
00035         ReqProductCode = 0x1C
00036         ## Product code (max 20 bytes data)
00037         ProductCode = 0x1D
00038         ## Request firmware revision
00039         ReqFWRev = 0x12
00040         ## Firmware revision, 3 bytes: major minor rev
00041         FirmwareRev = 0x13
00042         ## Request data length according to current configuration
00043         ReqDataLength = 0x0A
00044         ## Data Length, 2 bytes
00045         DataLength = 0x0B
00046         ## Request GPS status (MTi-G only)
00047         ReqGPSStatus = 0xA6
00048         ## GPS status (MTi-G only)
00049         GPSStatus = 0xA7
00050 
00051         # Device specific messages
00052         ## Baudrate, 1 byte
00053         SetBaudrate = 0x18
00054         ## Error mode, 2 bytes, 0000, 0001, 0002, 0003 (default 0001)
00055         SetErrorMode = 0xDA
00056         ## Location ID, 2 bytes, arbitrary, default is 0
00057         SetLocationID = 0x84
00058         ## Restore factory defaults
00059         RestoreFactoryDef = 0x0E
00060         ## Transmit delay (RS485), 2 bytes, number of clock ticks (1/29.4912 MHz)
00061         SetTransmitDelay = 0xDC
00062 
00063         # Synchronization messages
00064         ## Synchronization settings (MTi-10/100 series only), N*12 bytes
00065         SetSyncSettings = 0x2C
00066         ## SyncIn setting (MTi only), (1+) 2 or 4 bytes depending on request
00067         SetSyncInSettings = 0xD6
00068         ## SyncOut setting (MTi/MTi-G only), (1+) 2 or 4 bytes depending on request
00069         SetSyncOutSettings = 0xD8
00070 
00071         # Configuration messages
00072         ## Request configuration
00073         ReqConfiguration = 0x0C
00074         ## Configuration, 118 bytes
00075         Configuration = 0x0D
00076         ## Output configuration (MTi-10/100 series only), N*4 bytes
00077         SetOutputConfiguration = 0xC0
00078         ## Sampling period (MTi/MTi-G only), 2 bytes
00079         SetPeriod = 0x04
00080         ## Skip factor (MTi/MTi-G only), 2 bytes
00081         SetOutputSkipFactor = 0xD4
00082         ## Object alignment matrix, 9*4 bytes
00083         SetObjectAlignment = 0xE0
00084         ## Output mode (MTi/MTi-G only), 2 bytes
00085         SetOutputMode = 0xD0
00086         ## Output settings (MTi/MTi-G only), 4 bytes
00087         SetOutputSettings = 0xD2
00088 
00089         # Data messages
00090         ## Request MTData message (for 65535 skip factor)
00091         ReqData = 0x34
00092         ## Legacy data packet
00093         MTData = 0x32
00094         ## Newer data packet (MTi-10/100 series only)
00095         MTData2 = 0x36
00096 
00097         # XKF Filter messages
00098         ## Heading (MTi only), 4 bytes
00099         SetHeading = 0x82
00100         ## Reset orientation, 2 bytes
00101         ResetOrientation = 0xA4
00102         ## Request UTC time from sensor (MTI-G and MTi-10/100 series)
00103         ReqUTCTime = 0x60
00104         ## UTC Time (MTI-G and MTi-10/100 series), 12 bytes
00105         UTCTime = 0x61
00106         ## Request the available XKF scenarios on the device
00107         ReqAvailableScenarios = 0x62
00108         ## Available Scenarios
00109         AvailableScenarios = 0x63
00110         ## Current XKF scenario, 2 bytes
00111         SetCurrentScenario = 0x64
00112         ## Magnitude of the gravity used for the sensor fusion mechanism, 4 bytes
00113         SetGravityMagnitude = 0x66
00114         ## Lever arm of the GPSin sensor coordinates (MTi-G and MTi-700 only), 3*4 bytes
00115         SetLeverArmGPS = 0x68
00116         ## Magnetic declination (MTi-G only), 4 bytes
00117         SetMagneticDeclination = 0x6A
00118         ## Latitude, Longitude and Altitude for local declination and gravity
00119         # (MTi-10/100 series only), 24 bytes
00120         SetLatLonAlt = 0x6E
00121         ## Processing flags (not on firmware 2.2 or lower for MTi/MTi-g), 1 byte
00122         SetProcessingFlags = 0x20
00123         ## Initiate No Rotation procedure (not on MTi-G), 2 bytes
00124         SetNoRotation = 0x22
00125 
00126 
00127 
00128 def getName(cls, value):
00129         '''Return the name of the first found member of class cls with given
00130         value.'''
00131         for k, v in cls.__dict__.iteritems():
00132                 if v==value:
00133                         return k
00134         return ''
00135 
00136 
00137 def getMIDName(mid):
00138         '''Return the name of a message given the message id.'''
00139         name = getName(MID, mid)
00140         if name:
00141                 return name
00142         if mid&1:
00143                 name = getName(MID, mid-1)
00144                 if name:
00145                         return name+'Ack'
00146         return 'unknown MID'
00147 
00148 
00149 class Baudrates(object):
00150         """Baudrate information and conversion."""
00151         ## Baudrate mapping between ID and value
00152         Baudrates = [
00153                 (0x80, 921600),
00154                 (0x0A, 921600),
00155                 (0x00, 460800),
00156                 (0x01, 230400),
00157                 (0x02, 115200),
00158                 (0x03,  76800),
00159                 (0x04,  57600),
00160                 (0x05,  38400),
00161                 (0x06,  28800),
00162                 (0x07,  19200),
00163                 (0x08,  14400),
00164                 (0x09,   9600),
00165                 (0x0B,   4800),
00166                 (0x80, 921600)]
00167         @classmethod
00168         def get_BRID(cls, baudrate):
00169                 """Get baudrate id for a given baudrate."""
00170                 for brid, br in cls.Baudrates:
00171                         if baudrate==br:
00172                                 return brid
00173                 raise MTException("unsupported baudrate.")
00174         @classmethod
00175         def     get_BR(cls, baudrate_id):
00176                 """Get baudrate for a given baudrate id."""
00177                 for brid, br in cls.Baudrates:
00178                         if baudrate_id==brid:
00179                                 return br
00180                 raise MTException("unknown baudrate id.")
00181         
00182 
00183 class OutputMode:
00184         """Values for the output mode."""
00185         Temp            = 0x0001
00186         Calib           = 0x0002
00187         Orient          = 0x0004
00188         Auxiliary       = 0x0008
00189         Position        = 0x0010
00190         Velocity        = 0x0020
00191         Status          = 0x0800
00192         RAWGPS          = 0x1000        # supposed to be incompatible with previous
00193         RAW             = 0x4000        # incompatible with all except RAWGPS
00194 
00195 
00196 class OutputSettings:
00197         """Values for the output settings."""
00198         Timestamp_None                  = 0x00000000
00199         Timestamp_SampleCnt     = 0x00000001
00200         OrientMode_Quaternion   = 0x00000000
00201         OrientMode_Euler                = 0x00000004
00202         OrientMode_Matrix               = 0x00000008
00203         CalibMode_AccGyrMag     = 0x00000000
00204         CalibMode_GyrMag                = 0x00000010
00205         CalibMode_AccMag                = 0x00000020
00206         CalibMode_Mag                   = 0x00000030
00207         CalibMode_AccGyr                = 0x00000040
00208         CalibMode_Gyr                   = 0x00000050
00209         CalibMode_Acc                   = 0x00000060
00210         CalibMode_Mask                  = 0x00000070
00211         DataFormat_Float                = 0x00000000
00212         DataFormat_12_20                = 0x00000100    # not supported yet
00213         DataFormat_16_32                = 0x00000200    # not supported yet
00214         DataFormat_Double               = 0x00000300    # not supported yet
00215         AuxiliaryMode_NoAIN1    = 0x00000400
00216         AuxiliaryMode_NoAIN2    = 0x00000800
00217         PositionMode_LLA_WGS84  = 0x00000000
00218         VelocityMode_MS_XYZ     = 0x00000000
00219         Coordinates_NED                 = 0x80000000
00220 
00221 
00222 class XDIGroup:
00223         """Values for the XDI groups."""
00224         Temperature                             = 0x0800
00225         Timestamp                               = 0x1000
00226         OrientationData                 = 0x2000
00227         Pressure                                = 0x3000
00228         Acceleration                    = 0x4000
00229         Position                                = 0x5000
00230         AngularVelocity                 = 0x8000
00231         GPS                                             = 0x8800
00232         SensorComponentReadout  = 0xA000
00233         AnalogIn                                = 0xB000
00234         Magnetic                                = 0xC000
00235         Velocity                                = 0xD000
00236         Status                                  = 0xE000
00237 
00238 
00239 class MTException(Exception):
00240         def __init__(self, message):
00241                 self.message = message
00242         def __str__(self):
00243                 return "MT error: " + self.message
00244 


xsens_driver
Author(s): Francis Colas
autogenerated on Thu Jan 2 2014 11:18:32