Kauai Labs navX2-MXP User manual

navX2-MXP Robotics Navigation Sensor User Guide
Kauai Labs
Creative Commons - BY — 2020

Table of Contents
Overview
2
navX2-MXP
2
Features
3
Technical Specifications
3
"Behind the Design" 4
Frequently-asked Questions
5
Installation 10
Installation
10
RoboRIO Installation
10
FTC Installation
12
Orientation
15
OmniMount 19
I/O Expansion
21
Alternative Installation Options 25
Creating an Enclosure 27
Software 30
Software 30
RoboRIO Libraries
30
Android Library (FTC) 31
Linux Library 33
Arduino Library
33
navXUI
34
Tools 37
Examples 38
Examples
38
Field-Oriented Drive (FRC)
38
Rotate to Angle (FRC)
42
Automatic Balancing (FRC) 45
Collision Detection (FRC) 48
Motion Detection (FRC)
51
Data Monitor (FRC) 53
MXP I/O Expansion (FRC)
56
Guidance
60
Best Practices 60
Terminology
62
Selecting an Interface 68
Gyro/Accelerometer Calibration
69
Magnetometer Calibration
73
Yaw Drift 74
Support
78
Support
78
Firmware Archive 78
Factory Test Procedure 78
Software Archive
78
Advanced 81

Overview
navX2-MXP
Overview
navX2-MXP
navX2-MXP is a second-generation 9-axis inertial/magnetic sensor and motion processor. Designed
for plug-n-play installation onto a National Instruments RoboRIO™, navX2-MXP also
provides RoboRIO I/O Expansion.
“Generation 2” navX2-MXP is a drop-in replacement for “Classic” navX2-MXP. See the Frequently
Asked Questions (FAQ) for more information about navX2-MXP improvements.
navX2-MXP is a must-have add on to any RoboRIO-based control system, and includes free software
libraries, example code and many more features.
Super-charge your robot:
Field-Oriented Drive
Auto-balance
Auto-rotate to angle
Motion Detection
Collision Detection
and more…
1

Overview
navX2-MXP
Expand your RoboRIO™:
10 Digital I/Os
4 Analog Inputs
2 Analog Outputs
I2C, SPI & UART Interfaces
Selectable Output Voltage
Features
Sophisticated Motion Processing
Low-latency Yaw, Pitch and Roll Angles, w/low yaw drift
Supports high rotation rates (4000 degrees/second), High acceleration rates (16G) ensuring
accuracy even during extreme circumstances
Gravity-corrected Linear Velocity Vectors and Linear Displacement Estimates
Automatic Accelerometer/Gyroscope Calibration
High-sensitivity Motion Detection
Tilt-compensated Compass Heading
9-Axis absolute heading w/Magnetic disturbance detection
Configurable Update Rate from 4 to 200Hz
Easy to Use
Plug-n-Play Installation via RoboRIO MXP Interface
USB, TTL UART, I2C and SPI communication interfaces
RoboRIO libraries and sample code
Tools for Magnetometer Calibration
Protective Enclosure
A custom navX2-MXP enclosure can be created with a 3D printer using provided Enclosure
design files
Alternatively, the navX2-MXP enclosure can be purchased online.
Firmware updates can be easily downloaded to the navX2-MXP circuit board via the USB port.
Technical Specifications
The navX2-MXP circuit board and official firmware provide inertial and magnetic measurements, with a
range, accuracy and update rate as described on this page.
2

Overview
Technical Specifications
Note that certain performance specifications are only valid after Startup Gyroscope/Accelerometer
Calibration period, during which time the navX2-MXP circuit board must be held still.
Additional details can be found in the navX2-MXP datasheet.
Product Performance Specifications:
Electrical Specifications
Voltage: 5V DC
Current Consumption: 60 millamps
Communications Interfaces: USB, TTL UART, SPI, I2C
Power Connector: USB and/or 5VDC/GND Pins on MXP Connector
Power Source Fail-over: Automatic switch between USB/MXP Power within
100us
USB Connector: USB Mini-B
"Behind the Design"
The “Classic” navX-MXP is mentioned several times (pages 214-217, 227 and 231) within “FIRST Robots – Behind the
Design – 30 Profiles of Design, Manufacturing and Control” (2015, USFIRST). Please keep in mind that “Generation 2”
navX2-MXP is a drop-in replacement for the “Classic” navX-MXP.
Team 624’s 2015 Robot
3

Overview
"Behind the Design"
navX-MXP on Team 624’s 2015 Robot
Team 2062’s 2015 Robot
navX-MXP on Team 2062’s 2015 Robot
About the “Behind the Design” Book
“Behind the Design – 30 Profiles of Design, Manufacturing and Control” has six chapters that focus on CAD modeling,
traditional machining, CNC mills and lathes, CNC cutting, 3D printing, and sensors/control. Each chapter profiles five FRC
teams to illustrate how these technologies apply to robot design, manufacturing, and control. The book also includes vignettes
between the chapters that illustrate the purpose of FIRST and its impact.
Frequently-asked Questions
4

Overview
Frequently-asked Questions
How does navX2-MXP improve upon the “Classic” navX-MXP sensor?
Improved Sensors: navX2-MXP replaces the older MPU-9250 9-axis IMU with the
newer 6-axis ISM330DHCX IMU and LIS2MDL Magnetometer from ST
Microelectronics; these modern sensors feature significantly lower noise, greater stability,
higher accuracy and improved shock resistance than the now-obsolete Invensense
MPU-9250 found in the “Classic” navX-MXP sensor. Notably,
navX2-MXP’s ISM330DHCX IMU is an industrial-class sensor which is extremely stable,
has far lower sensor noise characteristics, and handles higher rotation speeds (4000
degrees/second).
Improved Processing Power and Sensor Fusion: navX2-MXP features an upgraded
180Mhz onboard 32-bit floating-point microcontroller which doubles the computation
power found on the “Classic” navX-MXP. This additional computation power enables
navX2-MXP to introduce a new Kalman Filter-based algorithm with improved accuracy,
running at a blazing fast 416Hz update rate and processing +/- 4000 degree/second
gyroscope and +/-16G accelerometer data.
As a result of these enhancements:
Startup time is reduced to only 5 seconds
Pitch/Roll accuracy is increased to 0.5 degrees
Errors due to Extreme inertial events are minimized:The combination of
increased 4000 degree/second gyroscope range, 16G accelerometer range and high-
speed Kalman Filter based on this data greatly minimizes Yaw angle errors due to
vibration and high-speed impacts
Velocity Measurement accuracy is improved:Lower accelerometer noise levels
and stability enable very accurate Linear Velocity Vectors.
Displacement Estimate accuracy is improved: Lower accelerometer noise levels,
improved “zero-velocity update” processing, and higher-speed Kalman Filter
updates increase the accuracy of displacement estimates, although error levels are
still high enough that they are referred to as “estimates” rather than
“measurements”.
For more details, please review the navX2-MXP Technical Specifications.
If I currently use the “Classic” navX-MXP, how easy is it to upgrade to the new navX2-MXP?
Simply swap out the existing navX-MXP, replacing it with the new “Generation 2” navX2-MXP.
navX2-MXP is identical to navX-MXP from both a hardware and software interface perspective; it’s a
“drop-in replacement” with enhanced performance.
5

Overview
Frequently-asked Questions
Why is a 4000 degree/second gyroscope like that present on navX2-MXP useful on a FRC robot?
Simply put, this minimizes yaw errors during high-inertia (e.g., impact) events.
Current consumer-class IMUs typically found on FRC robots (e.g., the “classic” navX-MXP) are limited
to measuring rotation at 2000 degrees/second. At first glance, this seems sufficient, since FRC robots
don’t typically rotate 6 times per second. However 2000 degrees translates to 2 degrees in a single
millisecond, and to 20 degrees per 10 millisecond period. If a FRC robot is contacted by a second robot
weighing 120 pounds and moving at 12 feet/second, this can cause the first robot to rotate sufficiently to
cause a 2000 degrees/second gyroscope to saturate – which in turn causes errors in the accumulated yaw
angle.
Will navX2-MXP work with the National Instruments RoboRIO™?
Yes, the navX2-MXP – like it’s predecessor the “Classic” navX-MXP – is designed specifically
to work with the RoboRIO. Please see the instructions for installing navX2-MXP onto a FIRST
FRC robot for more details, as there are several installation options.
Will navX2-MXP work with the Android-based FTC Control System?
Yes, navX2-MXP can be used with the Android-based FTC Control System, via its I2C interface.
For more information, please see the FTC Robot Installation instructions and the description of
the Android Libraries.
What interface/installation options are available for the navX2-MXP?
Plug-n-play install to the RoboRIO MXP port
Connection to the RoboRIO MXP port via a male-to-female floppy-disk-style ribbon cable
Connection to one of the RoboRIO USB Connectors via a USB Cable
Connection of power (+5VDC)/ground to the navX2-MXP’s MXP Connector, and direct
connection to the TTL UART, I2C or SPI pins.
Aren’t the magnetometer (compass heading) readings unreliable when the navX2-MXP is used on a
Robot with powerful motors?
Yes, this is correct. If navX2-MXP is mounted nearby any energized motors, the magnetometer’s
ability to measure the (weak) earth’s magnetic field is severely diminished.
For this reason, using the magnetometer during a FIRST FRC match is an advanced feature.
6

Overview
Frequently-asked Questions
However, at the beginning of each FIRST FRC match, the robot is turned on for about a minute
before the match begins. During this time period, the motors are not energized and thus do not add
magnetic interference that would disturb the magnetometer readings. Once the magnetometer is
calibrated, navX2-MXP will return either an accurate magnetometer reading, or an indication that
its measurement of the earth’s magnetic field has been disturbed.
Magnetometer readings taken at the beginning of a match, when combined with the navX2-MXP
yaw measurements, enable a robot’s pose and absolute heading to be maintained throughout the
match. This feature of the navX2-MXP is referred to as a “9-axis” heading.
Why do the Yaw angles provided by the navX2-MXP drift over time?
The short answer is that the yaw angle is calculated by integrating reading from a gyroscope
which measures changes in rotation, rather than absolute angles. Over time, small errors in the
rotation measurements build up over time. The navX2-MXP features sophisticated digital motion
processing and calibration algorithms that limit this error in the yaw angle of ~.5 degree per
minute when moving, and ~.2 degree per hour when still. For further details, please see the Yaw
Drift page.
Can the navX2-MXP “Displacement” estimates be used for tracking a FRC or FTC robot’s change in
position (dead-reckoning) during autonomous?
Accelerometer data from the navX-MXP’s onboard MPU-9250 are double-integrated by the navX-
MXP firmware to estimate displacement, and are accurate to approximately .1 meter of error
during a 15 second period.
To track a FRC or FTC robot’s position during autonomous requires an accuracy of about 1 cm of
error per 15 seconds. While the accuracy of the navX2-MXP displacement estimates might be
good enough to track the position of an automobile on a road, it is typically too low for use in
tracking a FRC or FTC robot’s position during the 15 second autonomous period, and employing
a sensor such as a quadrature encoder on the robot drive wheels is recommended.
The root cause of the displacement estimate error rate is accelerometer noise. Estimating
displacement requires first that each acceleration sample be multiple by itself twice (cubed), and
then integrated over time. Practically, if a noisy signal is cubed, the result is very noisy, and when
this very noisy value is integrated over time, the total amount of error grows very quickly.
The current noise levels (approximately 60 micro-g per square-root-hertz) would need to be
reduced by approaximately a factor of 10 (one order of magnitude) before displacement estimates
with 1 cm of error per 15 seconds can be achieved by double-integration of accelerometers.
7

Overview
Frequently-asked Questions
MEMS accelerometers featuring even lower noise levels than the ISM330DHCX continue to
emerge, but also continue to be very expensive. KauaiLabs actively researches these technology
developments – efforts that led to the selection of the ISM330DHCX for navX2-MXP – and
projects that MEMS technology that is both (a) low noise (1 micro-g per square root hertz) and (b)
available at low cost will likely occur in the next decade, but technology has not advanced to this
point yet. KauaiLabs plans to develop a product which can be used for accurate accelerometer-
based dead-reckoning at that time.
All that said, the navX2-MXP Displacement estimates are far more accurate than those possible
wit the “Classic” navX-MXP, and with very careful mounting and under controlled
circumstances, navX2-MXP Displacement estimates may be sufficient for tracking robot position
in certain cases; however we believe other technologies are likely more appropriate for most FRC
teams.
8

Installation
Installation
Installation
Installation
Plug-n-play: navX2-MXP – just like the “Classic” navX-MXP – is designed for rapid,
plug-n-play installation on a National Instruments RoboRIO™, making it easy to install and integrate
onto robots including a FIRST FRC Robot. navX2-MXP and supports plug-n-play installation onto an
Android-based FTC Robot.
Orientation: Tips and tricks for ensuring navX2-MXP measurements are aligned with your robot,
including the new Omnimount flexible mounting feature.
I/O Expansion: In addition to sophisticated motion processing, navX2-MXP also provides analog and
digital I/O expansion on a RoboRIO.
Flexibility: To allow flexible customization, navX2-MXP also supports several alternative installation
options as well as several communication options, providing flexibility when integrating with other
components.
Enclosure: To protect an installed navX2-MXP, an enclosure is available – which can be either
purchased, or printed on a 3D printer using open-source design files.
RoboRIO Installation
navX2-MXP is designed for plug-n-play installation onto the National Instruments RoboRIO™. This
installation takes about only a minute. To install, simply place the 34-pin “MXP” Connector on the
bottom of the navX2-MXP circuit board into the corresponding MXP slot on the top of the RoboRIO, as
shown below.
9

Installation
RoboRIO Installation
10

Installation
RoboRIO Installation
Securing navX2-MXP to the RoboRIO
Next, secure navX2-MXP to the RoboRIO using two #4-40 screws, each with a length of 3/16th inch.
You can also use a 1/4 inch-long screw if you place a small washer between it and the top of the navX-
MXP circuit board.
Image not found
Securing the navX2-MXP circuit board and RoboRIO to the robot chassis
The navX2-MXP circuit board should be mounted such that it is firmly attached to the robot chassis. The
quality of this mounting will be directly reflected in the quality of navX2-MXP inertial measurements.
To ensure quality, carefully follow these guidelines:
The RoboRIO on which the navX2-MXP circuit board is placed should be tightly mounted; it
should be a part of the chassis mass, and should move exactly as the chassis moves. Avoid
mounting the navX2-MXP circuit board in an area of the chassis that might be flexible, as this
could introduce vibration to the inertial sensors that does not represent the chassis inertial
properties.
The navX2-MXP circuit board should be mounted in the center of the chassis, which ensures the
origin of the yaw/pitch/roll axes truly represent the chassis center.
Be sure to understand the orientation of the navX2-MXP circuit board, relative to the chassis, and
decide whether OmniMount is needed.
Housing the navX2-MXP circuit board in some form of protective enclosure is highly
recommended, to protect it from damage. This should both protect the circuit board from damage,
and provide strain relief for the cables that connect to the navX2-MXP circuit board.
(Note that there are several other installation options available.)
FTC Installation
navX2-MXP can be easily used with the FTC Android-Based Robot Control System. Both power to and
signaling to/from the navX2-MXP occurs via the I2C interface by way of either a Expansion Hub or
a Control Hub from REV Robotics.
11

Installation
FTC Installation
Electrical Wiring Instructions
Select one of the 4 I2C ports on the Hub, as shown above. Note that the ports are numbered from
0.
Using a I2C to JST PH Cable, connect the +5V, Data (SDA), Clock (SCL) and GND pins to the
corresponding pins on the navX2-MXP External I2C Port Connector.
NOTE: The I2C to JST PH Cable linked-to above has a different pin out on the .1? (“Molex”) black
plastic header-side than found on the navX2-MXP connector shown below. Therefore you likely need to
re-order the pins on this end of the connector to correctly match the navX2-MXP pinout, by carefully
removing and re-inserting the wire leads into the connector.
12

Installation
FTC Installation
Connect the Power (+), Data (SDA), Clock (SCL) and GND pins to the corresponding pins on the
navX2-MXP External I2C Port Connector.
The Harness wires are colored as follows:
Black: Ground
Red: Power
Yellow: SDA
Blue: SCL
NOTE: Although the navX2-MXP is typically powered via 5VDC when used with the RoboRIO,
navX2-MXP is fully 3.3V compatible, and thus may be powered via the Expansion or Control Hub.
Electrical Wiring Verification
If properly wired, when power is applied to the Expansion or Control Hub, the Red 3.3V LED on the
navX2-MXP should light up.
If trouble occurs communication with the navX2-MXP, double-check that the SDA and the SCL wires on
the Expansion Control Hub match the corresponding pins on the navX2-MXP.
Physical Installation on the Robot
The navX2-MXP circuit board should be mounted such that it is firmly attached to the robot chassis. The
quality of this mounting will be directly reflected in the quality of navX2-MXP inertial measurements.
To ensure quality, carefully follow these guidelines:
Whereever the navX2-MXP circuit board is placed, it should be tightly mounted; it should be a
part of the chassis mass, and should move exactly as the chassis moves. Avoid mounting the
navX2-MXP circuit board in an area of the chassis that might be flexible, as this could introduce
vibration to the inertial sensors that does not represent the chassis inertial properties.
The navX2-MXP circuit board should be mounted in the center of the chassis, which ensures the
origin of the yaw/pitch/roll axes truly represent the chassis center.
Be sure to understand the orientation of the navX2-MXP circuit board, relative to the chassis, and
13

Installation
FTC Installation
decide whether OmniMount is needed.
Housing the navX2-MXP circuit board in some form of protective enclosure is highly
recommended, to protect it from damage. This should both protect the circuit board from damage,
and provide strain relief for the cables that connect to the navX2-MXP circuit board.
Orientation
navX2-MXP measures a total of 9 sensor axes (3 gyroscope axes, 3 accelerometer axes and 3
magnetometer axes) and fuses them into a 3-D coordinate system. In order to effectively use the values
reported by navX2-MXP, a few key concepts must be understood in order to correctly
install navX2-MXP on a robot.
3-D Coordinate System
When controlling a robot in 3 dimensions a set of 3 axes are combined into a 3-D coordinate system, as
depicted below:
In the diagram above, the green rounded arrows represent Rotational motion, and the remaining arrows
represent Linear motion.
Axis Orientation Linear motion Rotational Motion
X (Pitch) Left/Right – Left / + Right + Tilt Backwards
Y (Roll) Forward/Backward + Forward / – Backward + Roll Left
Z (Yaw) Up/Down + Up / – Down + Clockwise/ – Counter-
wise
More details are available on the Terminology page.
14

Installation
Orientation
Reference Frames
Note that the 3-axis coordinate system describes relative motion and orientation; it doesn’t specify the
orientation with respect to any other reference. For instance, what does “left” mean once a robot has
rotated 180 degrees?
To address this, the concept of a reference frame was developed. There are three separate three-axis
“reference frames” that should be understood:
Coordinate
System Technical Term X Axis Y Axis
Field World Frame Side of Field Front (Head) of Field
Robot Body Frame Side of Robot Front (Head) of Robot
navX2 MXP Board Frame See diagram Below See diagram below
Joysticks and Reference Frames
Since a three-axis joystick is typically used to control a robot, the robot designer must select upon
which Reference Frame the driver joystick is based. This selection of Reference Frame typically
depends upon the drive mode used:
Drive mode Reference Frame Coordinate Orientation
Standard
Drive Body Frame Forward always points to the
front (head) of the robot
Field-oriented
Drive World Frame Forward always points to the
front (head) of the field
navX2-MXP Board Orientation (Board Frame)
Aligning Board Frame and Body Frame
15

Installation
Orientation
In order for the navX2-MXP sensor readings to be easily usable by a robot control application, the
navX2-MXP Coordinate System (Board Frame) must be aligned with the Robot Coordinate system (Body
Frame).
Aligning the Yaw (Z) axis and Gravity
The navX2-MXP motion processor takes advantage of the fact that gravity can be measured with its
onboard accelerometers, fusing this information with the onboard gyroscopes to yield a very accurate yaw
reading with a low rate of drift. In order to accomplish this, the yaw (Z) axis must be aligned with the
“gravity axis” (the axis that points directly up and down with respect to the earth).
When installing navX2-MXP on a robot, the navX-MXP yaw (Z) axis and the gravity axis must be
aligned.
Default navX2-MXP Board Orientation
The default navX2-MXP circuit board orientation is with the navX2-MXP logo on the Rear Left,
with the top of the circuit board pointing up (with respect to the earth).
Since Body Frame and Board Frame coordinates should be aligned, and because the Yaw axis must be
aligned with gravity, by default you must orient the navX2-MXP with the top of the board facing up, and
with the Y axis (on the circuit board) pointing to the front of the robot.
If you need to mount the navX2-MXP circuit board in a different orientation (vertically, horizontally,
or upside down), you can use the OmniMount feature to transform the orientation.
16

Installation
Orientation
17
Table of contents
Popular Robotics manuals by other brands

adept technology
adept technology Hornet 565 Quick setup guide

ROBOTIQ
ROBOTIQ CNC Machine Tending Kit instruction manual

Evil Mad Scientist
Evil Mad Scientist Egg-Bot Electro-Kistka operating instructions

Clementoni
Clementoni RoboMaker X5 DROID manual

Kitronik
Kitronik BULLDOZER 5671 manual

Kosmos
Kosmos ReBotz DUKE manual