资源说明:Arduino program for building an AHRS with a Pololu MinIMU-9
h1. Pololu MinIMU-9 + Arduino AHRS (Attitude and Heading Reference System) Version: 1.3.0 Release Date: 2016-04-27 "www.pololu.com":http://www.pololu.com/ h2. Summary This is a program (sketch) for the "Arduino":http://pololu.com/catalog/product/2191 that interfaces with the Pololu MinIMU-9 inertial measurement units: * "MinIMU-9 v5(LSM6DS33 and LIS3MDL carrier) ":http://www.pololu.com/product/2738 * "MinIMU-9 v3(L3GD20H and LSM303D carrier) ":http://www.pololu.com/product/2468 * "MinIMU-9 v2(L3GD20 and LSM303DLHC carrier) ":http://www.pololu.com/catalog/product/1268 (discontinued) * "MinIMU-9(L3G4200D and LSM303DLM carrier) ":http://www.pololu.com/catalog/product/1265 (discontinued) * "MinIMU-9(L3G4200D and LSM303DLH carrier) ":http://www.pololu.com/catalog/product/1264 (discontinued) It also works with the Pololu AltIMU-10 boards, although the output from the barometer is not used: * "AltIMU-10 v5(LSM6DS33, LIS3MDL, and LPS25H carrier) ":http://www.pololu.com/product/2739 * "AltIMU-10 v4(L3GD20H, LSM303D, and LPS25H carrier) ":http://www.pololu.com/catalog/product/2470 * "AltIMU-10 v3(L3GD20H, LSM303D, and LPS331AP carrier) ":http://www.pololu.com/catalog/product/2469 * "AltIMU-10(L3GD20, LSM303DLHC, and LPS331AP carrier) ":http://www.pololu.com/catalog/product/1269 (discontinued) This Arduino program processes the raw rotation, acceleration, and magnetic data from the MinIMU-9 to derive an estimate of the board's absolute orientation, which it outputs through the Arduino's serial interface, turning the MinIMU-9 and Arduino into an attitude and heading reference system (AHRS). A Python test program is also included. It communicates with the Arduino serially and displays a 3D representation of the MinIMU-9 board, allowing you to visualize the output of the AHRS in real time. Both the Arduino software and Python test program are based on "sf9domahrs":http://code.google.com/p/sf9domahrs/ by Doug Weibel and Jose Julio, which is in turn based on "ArduIMU":http://code.google.com/p/ardu-imu/ v1.5 by Jordi Munoz, William Premerlani, Jose Julio, and Doug Weibel. h2. Getting Started h3. Software The Arduino program uses Pololu's Arduino libraries for the sensors on the IMU board, which can also be downloaded from GitHub. Follow the instructions on their respective pages to install the libraries. * *v5* IMUs: "LSM6":https://github.com/pololu/LSM6-arduino and "LIS3MDL":https://github.com/pololu/LIS3MDL-arduino libraries * *v4 and earlier* IMUs: "L3G":https://github.com/pololu/L3G and "LSM303":https://github.com/pololu/LSM303 libraries The Python test program also has several dependencies you must install before you can run it: * "Python 2.7":http://www.python.org/download/ (download the 32-bit version) * "pywin32":http://sourceforge.net/projects/pywin32/files/pywin32/ (direct link: "pywin32-218.win32-py2.7.exe":http://sourceforge.net/projects/pywin32/files/pywin32/Build%20218/pywin32-218.win32-py2.7.exe/download) * "pyserial":http://sourceforge.net/projects/pyserial/files/pyserial/ (direct link: "pyserial-2.5.win32.exe":http://sourceforge.net/projects/pyserial/files/pyserial/2.5/pyserial-2.5.win32.exe/download) * "VPython 5":http://vpython.org/contents/download_windows.html (direct link: "VPython-Win-Py2.7-5.74.exe":http://vpython.org/contents/download/VPython-Win-Py2.7-5.74.exe) After you have set up the prerequisites, download the archive from "GitHub":https://github.com/pololu/MinIMU-9-Arduino-AHRS and decompress it. h3. Hardware Make the following connections with wires between the Arduino and the MinIMU-9: h4. 5V Arduino boards (including Arduino Uno, Leonardo, Mega; Pololu A-Star 32U4) pre. Arduino IMU ------- --- 5V - VIN GND - GND SDA - SDA SCL - SCL h4. 3.3V Arduino boards (including Arduino Due) pre. Arduino IMU ------- --- 3V3 - VIN GND - GND SDA - SDA SCL - SCL h3. Using the AHRS From the Arduino environment, open MinIMU9AHRS.ino, which can be found in the MinIMU9AHRS folder. The Arduino program is set up for a *v4 or earlier* IMU by default. If you are using a MinIMU or AltIMU *v5*, uncomment the line that says @//#define IMU_V5@ at the beginning of MinIMU9AHRS.ino. By default, the Arduino code treats the positive X axis of the MinIMU-9 as forward and the negative Z axis as up (so that the components are on the bottom of the board and the silkscreen is on top). If you want the positive Z axis to be up instead (so that the components are on top), find the definition of @SENSOR_SIGN[9]@ at the beginning of MinIMU9AHRS.ino and uncomment the appropriate line (after commenting the original). To ensure that the heading derived from the compass is accurate, you should change the @M_X_MIN@ through @M_Z_MAX@ calibration constants to appropriate values. You can use the Calibrate example from the "LIS3MDL library":https://github.com/pololu/LIS3MDL-arduino (v5) or "LSM303 library":https://github.com/pololu/LSM303 (v4 or earlier) to find the right values for your board. In the Tools menu, select the appropriate board and serial port. Click the "Upload" button to compile the sketch and load it onto your Arduino. When the AHRS program first starts running, it takes some readings to establish a baseline orientation, during which it expects both the roll and the pitch of the sensors to be zero. Therefore, it is important to keep the MinIMU-9 level for a few seconds after powering on or resetting the Arduino or connecting to it from a computer. After performing the startup routine, the program constantly takes readings from the gyro, accelerometer, and magnetometer on the MinIMU-9 and calculates an estimate of the board's orientation. It outputs estimated roll, pitch, and yaw angles (in degrees) through the Arduino's serial interface, and you can view the output with the Arduino Serial Monitor. Example output: pre. !ANG:0.08,0.09,137.01 !ANG:0.14,0.11,137.04 !ANG:0.15,0.12,137.06 To visualize the output of the AHRS, you can run the Python test program (MinIMU-9-test.py) while the Arduino is connected to your computer. (You will probably have to edit the file first and change the definition of @ser@ to match the COM port your Arduino is using.) You should be able to see three indicators showing the roll, pitch, and yaw angles being calculated by the AHRS, as well as a 3D representation of the MinIMU-9 board (the arrow indicates the positive X direction). You can watch these change in real time as you move the board around. !http://b.pololu-files.com/picture/0J3722.600.jpg! h2. Version History * 1.3.0 (2016-04-27): Added support for MinIMU-9 v5 and AltIMU-10 v5. Added a check to help work around nan (not a number) problems caused by USB serial stalling the main loop. * 1.2.3 (2015-02-05): Updated to work with L3G library version 2.0.0. * 1.2.2 (2013-11-27): Updated to work with LSM303 library version 2.0.0. * 1.2.1 (2013-03-15): Fixed issue with properly enabling high-resolution mode on accelerometer. * 1.2.0 (2012-07-06): Added support for MinIMU-9 v2 (L3GD20 and LSM303DLHC); L3G4200D library dependency changed to L3G. * 1.1.0 (2011-11-15): Added support for LSM303DLM; LSM303DLH library dependency changed to LSM303. * 1.0.0 (2011-09-26): Original release.
本源码包内暂不包含可直接显示的源代码文件,请下载源码包。