nimu.h
00001 /*
00002  *  Player - One Hell of a Robot Server
00003  *  Copyright (C) 2006
00004  *     Toby Collett
00005  *
00006  *
00007  *  This library is free software; you can redistribute it and/or
00008  *  modify it under the terms of the GNU Lesser General Public
00009  *  License as published by the Free Software Foundation; either
00010  *  version 2.1 of the License, or (at your option) any later version.
00011  *
00012  *  This library is distributed in the hope that it will be useful,
00013  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015  *  Lesser General Public License for more details.
00016  *
00017  *  You should have received a copy of the GNU Lesser General Public
00018  *  License along with this library; if not, write to the Free Software
00019  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00020  */
00021 
00022 #include <usb.h>
00023 #include <stdint.h>
00024 #include <stdio.h>
00025 #include <arpa/inet.h>
00026 
00027 
00028 #define NIMU_VENDORID 0x10c4
00029 #define NIMU_PRODUCTID 0xEA61
00030 
00031 #define NIMU_DATA_SIZE 38
00032 
00033 typedef unsigned char uint8_t;
00034 typedef unsigned short uint16_t;
00035 
00036 
00037 
00038 class nimu_data
00039 {
00040         public:
00041                 uint8_t DeviceID;
00042                 uint8_t MessageID;
00043                 uint16_t SampleTimer;
00044                 short GyroX;
00045                 short GyroY;
00046                 short GyroZ;
00047                 short AccelX;
00048                 short AccelY;
00049                 short AccelZ;
00050                 short MagX;
00051                 short MagY;
00052                 short MagZ;
00053                 short GyroTempX;
00054                 short GyroTempY;
00055                 short GyroTempZ;
00056 
00057                 void Print() {
00058                         printf("%04X %04X %04X,%04X %04X %04X\n",GyroX,GyroY,GyroZ,AccelX,AccelY,AccelZ);
00059                 }
00060 };
00061 
00062 class nimu
00063 {
00064         public:
00065                 nimu();
00066                 ~nimu();
00067 
00068                 int Open();
00069                 int Close();
00070 
00071                 nimu_data GetData();
00072 
00073         private:
00074                 usb_dev_handle * nimu_dev;
00075 
00076 };
00077 

Last updated 12 September 2005 21:38:45