NXShield  v1.07
NXShield Library Reference by OpenElectrons.com
 All Classes Files Functions Variables Enumerations Enumerator Macros Pages
AbsoluteIMU.h
1 
2 // AbsoluteIMU.h
3 //
4 // This is a class for reading from AbsoluteIMU, made by Mindsensors.
5 // See http://www.mindsensors.com/index.php?module=pagemaster&PAGE_user_op=view_page&PAGE_id=169
6 
7 // Initial version: 2013-01-22 by Michael Giles
8 // Large parts of the code is ported from the NXC library for the device,
9 // written by Deepak Patil.Deepak Patil
10 
11 /*
12  This library is free software; you can redistribute it and/or
13  modify it under the terms of the GNU Lesser General Public
14  License as published by the Free Software Foundation; either
15  version 2.1 of the License, or (at your option) any later version.
16 
17  This library is distributed in the hope that it will be useful,
18  but WITHOUT ANY WARRANTY; without even the implied warranty of
19  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20  Lesser General Public License for more details.
21 
22  You should have received a copy of the GNU Lesser General Public
23  License along with this library; if not, write to the Free Software
24  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 */
26 
27 
28 #ifndef ABSIMU_H
29 #define ABSIMU_H
30 
35 #define IMU_Command 0x41
36 
37 #include "NXShieldI2C.h"
38 
44 {
45  short mx_h;
46  short mx_l;
47  short my_h;
48  short my_l;
49  short mz_h;
50  short mz_l;
52  int mx;
53  int my;
54  int mz;
55  int error;
56 };
57 
62 struct gyro
63 {
64  short gx_h;
65  short gx_l;
66  short gy_h;
67  short gy_l;
68  short gz_h;
69  short gz_l;
71  int gx;
72  int gy;
73  int gz;
74  int error;
75 };
76 
81 struct accl
82 {
83  short tx;
84  short ty;
85  short tz;
87  short ax_h;
88  short ax_l;
89  short ay_h;
90  short ay_l;
91  short az_h;
92  short az_l;
94  int ax;
95  int ay;
96  int az;
97  int error;
98 };
99 
104 struct cmps
105 {
106  int heading;
108  short heading_h;
109  short heading_l;
111  int error;
112 };
113 
117 class AbsoluteIMU : public NXShieldI2C
118 {
119 public:
121  AbsoluteIMU(uint8_t i2c_address = 0x22);
122 
124  uint8_t issueCommand(char command);
125 
130  void readGyro(gyro & currGyro);
131 
136  void readCompass(cmps & currCompass);
137 
142  void readAccelerometer(accl & currAccelerometer);
143 
148  void readMagneticField(magnetic_field & currMagnetic_field);
156  bool endCompassCalibration();
157 };
158 
159 #endif
This class implements I2C interfaces used by NXShield.
Definition: NXShieldI2C.h:32
short heading_h
Definition: AbsoluteIMU.h:108
Definition: AbsoluteIMU.h:62
int ax
Definition: AbsoluteIMU.h:94
int gz
Definition: AbsoluteIMU.h:73
This class interfaces with AbsoluteIMU sensor attached to NXShield.
Definition: AbsoluteIMU.h:117
void readAccelerometer(accl &currAccelerometer)
Definition: AbsoluteIMU.cpp:58
short gx_l
Definition: AbsoluteIMU.h:65
int error
Definition: AbsoluteIMU.h:97
short gy_l
Definition: AbsoluteIMU.h:67
Definition: AbsoluteIMU.h:104
short ax_h
Definition: AbsoluteIMU.h:87
int mz
Definition: AbsoluteIMU.h:54
int gx
Definition: AbsoluteIMU.h:71
AbsoluteIMU(uint8_t i2c_address=0x22)
Definition: AbsoluteIMU.cpp:29
short gy_h
Definition: AbsoluteIMU.h:66
int heading
Definition: AbsoluteIMU.h:106
short tx
Definition: AbsoluteIMU.h:83
short ay_l
Definition: AbsoluteIMU.h:90
int az
Definition: AbsoluteIMU.h:96
Definition: AbsoluteIMU.h:81
bool endCompassCalibration()
Definition: AbsoluteIMU.cpp:85
int my
Definition: AbsoluteIMU.h:53
short mz_l
Definition: AbsoluteIMU.h:50
uint8_t issueCommand(char command)
Definition: AbsoluteIMU.cpp:35
int gy
Definition: AbsoluteIMU.h:72
short ay_h
Definition: AbsoluteIMU.h:89
void readGyro(gyro &currGyro)
Definition: AbsoluteIMU.cpp:40
short my_h
Definition: AbsoluteIMU.h:47
Definition: AbsoluteIMU.h:43
short mz_h
Definition: AbsoluteIMU.h:49
short heading_l
Definition: AbsoluteIMU.h:109
short ty
Definition: AbsoluteIMU.h:84
int error
Definition: AbsoluteIMU.h:55
short tz
Definition: AbsoluteIMU.h:85
int ay
Definition: AbsoluteIMU.h:95
int mx
Definition: AbsoluteIMU.h:52
short gx_h
Definition: AbsoluteIMU.h:64
int error
Definition: AbsoluteIMU.h:74
int error
Definition: AbsoluteIMU.h:111
short mx_h
Definition: AbsoluteIMU.h:45
short my_l
Definition: AbsoluteIMU.h:48
bool beginCompassCalibration()
Definition: AbsoluteIMU.cpp:81
short az_l
Definition: AbsoluteIMU.h:92
short mx_l
Definition: AbsoluteIMU.h:46
short ax_l
Definition: AbsoluteIMU.h:88
void readCompass(cmps &currCompass)
Definition: AbsoluteIMU.cpp:51
short gz_h
Definition: AbsoluteIMU.h:68
void readMagneticField(magnetic_field &currMagnetic_field)
Definition: AbsoluteIMU.cpp:71
short gz_l
Definition: AbsoluteIMU.h:69
short az_h
Definition: AbsoluteIMU.h:91