Arduino GPS and Compass Support
Arduino GPS and Compass Support
Hardware
A simple solution for outdoor localization and basic navigation is an Arduino board, such as the Adafruit Feather nRF52840 Sense with a GPS shield, such as the Adafruit Ultimate GPS FeatherWing. The Sense
provides a micro controller, Bluetooth, a 6DoF IMU, and a magnetometer (a LIS3MDL). The FeatherWing
provides a GPS.
Assembly
Solder the FeatherWing
to the Sense
. Add support for the nRF52 to the Arduino IDE. Then, add the board - it’s the Adafruit nRF52840 Sense
. The Arduino IDE will probably need to also install the nRF core library (adafruit:nrf52@1.6.1
). You should now be able to connect to the board.
Software
Add the following libraries to the Arduino IDE:
Adafruit GPS library
Adafruit LIS3MDL
Adafruit_LSM6DS
Run the sketch provided in /system_hw_test/gps_mag
. It yields all the data for tilt compensated magnetic heading, a full AHRS solution (yaw, tilt, roll) and a GPS location, as well as altitude and velocity.
WARNING The direction and AHRS data will be entirely incorrect unless you calibrate your magnetometer, gyro, and accelerometer.
Calibration
In the /system_hw_test/gps_mag.ino
, see:
Once you have established your 15 (3+9+3) calibration coefficients (see https://github.com/PaulStoffregen/MotionCal), determine the device string of your sensor (provided in the initial serial debug output), and add your calibration coefficients following the example given in gap_mag.ino
:
WARNING If you use different sensor hardware (and not the nRF52840 Sense with the FeatherWing), you will need to adapt all data flowing from your gyros, accelerators, and magnetometer to (1) have the correct units, (2) follow the correct sign conventions, and (3) accommodate your pcb/sensor geometry as well as how the sensors are mounted relative to your robot. This tends to be extremely tedious and time consuming, so we recommend using the Sense/FeatherWing for which this driver has been developed.
Usage
Once your Sense/FeatherWing is streaming data on the serial line, it can be fed into OM1. See src/inputs/plugins/serial_reader
for an example of how to do that.
Finding the Arduino on Linux
When connecting to the Arduino via USB, you should see the Arduino serial port appear as /dev/ttyACM0
(sometimes the number can be different, for example /dev/ttyACM1
). Run:
and you should see it. If you’re not sure which tty device is the Arduino board, run sudo dmesg
and looks for entries with “Arduino” in it. This way you will easily spot the serial device name of your Arduino. You can read the data with:
Note: on a typical TurtleBot4, the RPLIDAR uses /dev/ttyUSB0
. The TurtleBot4 assumes that the RPLIDAR is accessible at /dev/ttyUSB0
. If you change which USB port the LIDAR is plugged into, the LIDAR will fail.
Finding the Arduino GPS Feather on Mac
Determine the serial port the sensor is using:
It should be something similar to /dev/cu.usbmodem8401
.
RTCM / RTK Precision GPS
An RTK GPS system can provide centimeter accuracy localization. In a typical setup, an RTK-compatible GPS receiver (such as the u-blox ZED-F9P/simpleRTK2B accepts RTCM
messages over XBee or the internet, and uses those data to correct (and greatly improve) its location estimate. The simpleRTK2B
has two usb ports, one labeled power + GPS
and the other power + XBee
. The first port provides a full set of NEMA and UBX messages, including GPGGA, GNRMC, GNGLL, and UBX(NAV-PVT). The power + XBee
port provides direct access to received RTK correction messages, such as 1005
and 1074
. In standard usage, a rover would use the NEMA messages to track its location whilst monitoring the status, mode, and quality fields.
This GNGGA message shows a high quality RTK fix (quality=5):
- 1 autonomous (standard accuracy) solution
- 2 code-differential (DGNSS, SBAS) solution
- 4 fixed RTK
- 5 float RTK
This GNRC message shows a valid status(A
) using RTK mode with fixed integers (posMode=R
)
Status indicator: A: Data valid V: Data not valid
Mode indicator: A: Autonomous mode D: Differential mode P: Precise E: Estimated (dead reckoning) mode M: Manual input mode S: Simulator mode R: Fixed RTK. RTK mode with fixed integers F: Float RTK. RTK mode with floating integers. N: Data not valid