EECE 5554
Robotics Sensing and Navigation

Lab 4: Dead Reckoning with
an IMU, GPS, and LiDAR

Dr. Xian Li
Assistant Teaching Professor
Department of Electrical and Computer Engineering

Today

  1. What Lab 4 asks, and why
  2. The car and its two computers
  3. Before the drive: the launch file and the dry run
  4. In the car: roles, recordings, and the car files
  5. The analysis, including the new parts
  6. What to submit
2

How long can you dead-reckon?

In a tunnel, under a bridge, or between tall buildings, GNSS can vanish for minutes. A car then has to estimate its own motion. Each sensor in Lab 4 is good at one part of that, and fails in its own way.

RTK GNSS

Absolute position, to a few centimeters, once a second.
  • Drops to float or standalone near buildings and trees
  • Gone in a tunnel

IMU

Rotation, smoothly, 40 to 100 times a second.
  • Heading drifts slowly
  • Velocity from the accelerometer drifts fast: every error is integrated twice

LiDAR

How the car moved between two scans, from the walls, trees, and poles it sees.
  • Fails where there is nothing to match, or the scene moves
  • Its own turns drift slowly
You will measure each one against RTK, and see why real cars combine all three.
3

The Mustang Mach-E

base_footprint rear axle, on the ground LiDAR camera radar your GNSS antenna your VN-100 car PC in the back 1.82 m, and 1.78 m up front
SensorRate
Ouster OS1-64 LiDAR10 scans/s, 65,536 points each
Ouster's built-in IMU100 Hz
The car's own IMU100 Hz
The car's own GPS1 Hz, with its time
Wheel speeds, steering50 to 100 Hz
Your RTK and VN-1001 Hz and 40 Hz, on your laptop

The car PC runs ROS 2 Humble. The camera and radar are recorded too, but Lab 4 does not use them.

4

Two computers, never connected

Your laptop ROS 2 Jazzy, WiFi off your RTK and VN-100 drivers the data lead runs it The car PC ROS 2 Humble, offline LiDAR, IMUs, GPS, speeds the car PC operator runs it laptop bag/gps and /imu, about 15 MB car bagabout 30 GB, mostly LiDAR extract car fileabout 10 MB your drive your repository never connected
Each computer times its own bag by its own clock. The data lead and the car PC operator start and stop together by calling out to each other, and Part 5.6 lines the two clocks up afterward.
5

Five parts

PartWhat you doWhere
1. One launch filenav_bringup starts your Lab 2 RTK driver and your Lab 3 VN-100 driver togetherAt home, against the emulators
2. The dry runThe whole data collection on foot: walk_circle and walk_square, until the self-check says READY TO DRIVE: YESA park, with your team
3. The driveCalibration circles and a 2 to 3 km loop: car_circles and car_drive, on both computersThe Mach-E, near Kerry Park
4. The toolsReading your bags and the two car filesThe notebook
5. The analysisHeading, speed, and path from the IMU, then two clocks, LiDAR odometry, and an RTK outageThe notebook
The drive needs the car, booked by your team. Everything else you can do on your own time.
6

Part 1: one launch file

nav_bringup/launch/nav.launch.py
"""Start the Lab 2 RTK driver and the Lab 3 VN-100 driver together."""
import os

from ament_index_python.packages import get_package_share_directory
from launch import LaunchDescription
from launch.actions import DeclareLaunchArgument, IncludeLaunchDescription
from launch.launch_description_sources import PythonLaunchDescriptionSource
from launch.substitutions import LaunchConfiguration


def generate_launch_description():
    gps_launch = os.path.join(get_package_share_directory('gps_driver'),
                              'launch', 'rtk_driver.launch.py')
    return LaunchDescription([
        DeclareLaunchArgument('gps_port', default_value='/dev/ttyACM0'),
        IncludeLaunchDescription(
            PythonLaunchDescriptionSource(gps_launch),
            launch_arguments={'port': LaunchConfiguration('gps_port')}.items()),
        # TODO: declare imu_port, and include vn_driver's launch file
    ])
  • The GPS half is in the worked example. The VN-100 half is yours.
  • Each include passes its own port, so the two drivers can never end up on the same device.
  • The self-check runs both emulators, twice, with the ports swapped.
On the real sensors, use the /dev/serial/by-id/ names. They never change.
7

Part 2: the dry run on foot

walk_circle

Four slow circles around a landmark, about 10 m across, with the VN-100 held level. Practice for the calibration circles in the car.

walk_square

A 25 m square, with a 20 s still start. Practice for the drive, and a short, simple bag for testing your analysis.
The dry run is where problems are found: a loose CAT-6 loop, a wrong port, a dead battery. The car is not.
8

Part 3: The Drive

What happens in the car, step by step

Roles in the car

Driver

The instructor. Drives, and nothing else: never looks at a screen, and nobody asks them to.

Car PC operator

Types the car's commands on the car PC when the data lead calls for them. At the end, makes and copies the car files.

Data lead

Runs the laptop, calls the start and stop of each recording, and watches both topic rates and the fix quality.

Sensor lead

Mounts and checks the VN-100, the antenna, and the receiver, and owns the cables.

Navigator

Calls the route, keeps the hotspot on, and writes every stop and anything unusual, with the time.

With three people

The sensor lead also navigates. Pick roles before you leave, and write them in the field handout.
10

What to bring

Print the field handout, EECE5554_Lab4_field_handout.pdf. The car has no internet, and the handout has every step, a checklist, troubleshooting, and a page for your notes.
11

Safety first

12

Step 10: mount, and measure

base_link center of the rear axle VN-100 x y (right) GNSS antenna (roof) x_c front
  • VN-100: on a flat, rigid surface near the centerline, level, x axis straight ahead, taped down, away from speakers and phones
  • Antenna: on the roof mount, cable over a rear door seal, never through a window, taped to the roof
  • Receiver: on the floor or rear seat, WiFi antenna on, CAT-6 loop in, USB plugs taped
Measure xc, yc, xa, and ya from base_link, in cm, with y positive to the right. Take a photo of each.
13

The terminals you need

WhereTerminalStart it withUsed for
Laptop1: driverssource ~/EECE5554/Lab4/ros2_ws/install/setup.bashYour nav.launch.py, running the whole trip
Laptop2: recordingthe same line, then cd ~/EECE5554/Lab4/dataYour ros2 bag record
Laptop3: watchingthe same lineros2 topic hz /imu and /gps
Car PCthe carStaff opens itOnly ~/lab4/lab4_check.sh and ~/lab4/lab4_record.sh
The car PC operator types only the commands in the field handout. The car's own setup must never change.
14

Step 11: before the car moves

  1. Laptop WiFi off: nmcli radio wifi off. The receiver keeps its corrections through the hotspot
  2. Drivers running with both by-id ports: /imu near 40 Hz, /gps near 1 Hz
  3. A real fix: fix_quality 4 or 5, outside the garage, after a few minutes
  4. Car still: /imu linear acceleration z near -9.8, because the VN-100's z axis points down
  5. On the car PC: ~/lab4/lab4_check.sh ends with CAR READY: YES
  6. The checklist in the field handout
car PC
~/lab4/lab4_check.sh

/front_lidar/points      10.0  OK
/front_lidar/imu        100.1  OK
/vehicle/wheel_speeds   100.0  OK
...
Free disk space: 180 GB (OK)
CAR READY: YES
15

One recording, two computers

Car PCLaptop 1. "Start the car." lab4_record.sh start team3 car_drive 2. "Car recording." ros2 bag record -o car_drive /gps /imu 20 s still 20 s still drive the loop 3. Ctrl+C. "Laptop stopped." 4. lab4_record.sh stop
The car's recording starts first and stops last, so it covers all of yours. The data lead calls each step out loud, and the car PC operator answers when it is done.
16

Step 12: the calibration circles

car PC, then laptop terminal 2
~/lab4/lab4_record.sh start team3 car_circles
ros2 bag record -o car_circles /gps /imu

# 20 s still, 5 circles, 10 s still, then:
# laptop: Ctrl+C, and "Laptop stopped."
~/lab4/lab4_record.sh stop
These circles calibrate the magnetometer, and the same turns line up the two clocks in Part 5.6.
17

Step 13: the drive

car PC, then laptop terminal 2
~/lab4/lab4_record.sh start team3 car_drive
ros2 bag record -o car_drive /gps /imu

~/lab4/lab4_record.sh status   # watch it grow

# at the end: laptop Ctrl+C, then
~/lab4/lab4_record.sh stop
A rate drops to zero? Finish the loop, fix it parked, and drive it again as car_drive_2, on both computers.
18

Step 14: before you hand the car back

car PC
~/lab4/lab4_record.sh list team3
~/lab4/lab4_record.sh extract team3
# plug your team's drive into the car PC, then:
~/lab4/lab4_record.sh copy team3
your laptop, later
mkdir -p ~/EECE5554/Lab4/data/car
cp /media/$USER/<drive>/EECE5554_Lab4_team3/*.npz \
   ~/EECE5554/Lab4/data/car/
  • ros2 bag info on both laptop bags: both topics, about 40 IMU and 1 GPS message per second
  • extract turns each 30 GB car bag into a 10 MB car file, in a few minutes
  • copy finds your drive, copies the files, and ejects it. --raw also copies the whole bags, if the drive has 40 GB free
  • Everything of yours out of the car, WiFi back on, problems reported
Commit the two car files, and give a copy to each teammate. Never commit the car's own bags.
19

If something goes wrong

ProblemWhat to do
A rate drops to zeroKeep driving normally, finish the loop, fix it parked, and record the loop again
Something comes looseDo not touch it while the car moves. Stop somewhere legal and safe first
fix_quality stays at 1Corrections are not arriving: hotspot on, CAT-6 loop in, Corrections tab live
A driver dies at launchDevice busy: close minicom. Permission denied: the dialout group
CAR READY: NOTell staff, and do not drive
start says the bag existsIt never overwrites. Use the name it suggests, such as car_drive_2, on the laptop too
copy cannot write to the driveFormat it exFAT. A Mac's own format, APFS, does not work on the car PC
Anyone feels unsafeStop the drive. A data set can be recollected
20

Part 5: the analysis

SectionThe questionFigures
5.1 MagnetometerHard and soft iron, on foot and in the car1 to 5
5.2 HeadingA complementary filter: the gyro for fast changes, the magnetometer for the long run6, 7
5.3 VelocityThe accelerometer against RTK and the car's own speed, with bias, hill, and stop corrections8
5.4 Motion modelWhere the VN-100 sits, from the data9
5.5 Dead reckoningThe IMU track against RTK: how long within 2 m, and within 10 m10
5.6 Two clocksLine up the laptop and the car PC by matching two gyros11
5.7 LiDAR odometryThe car's path from scan matching, with an ICP you write12
5.8 An RTK outageIMU, LiDAR, and the two together, through 90 s without GNSS13
21

Try it: line up two gyros

Part 5.6

Shift the laptop's gyro

-6.00 s
Correlation0
True Lhidden

A made-up drive: turns of different lengths, a car gyro at 100 Hz with z up, and a laptop gyro at 40 Hz with z down, whose recording started a few seconds later.

22

LiDAR odometry

Part 5.7

  1. Two scans, half a second apart, as x and y points 1 to 3 m above the ground
  2. Move the new scan by a guess, and pair each point with its nearest neighbor in the old one
  3. Find the turn and shift that best fit the pairs, with an SVD
  4. Repeat until it settles: that is ICP, iterative closest point
  5. Chain the steps into the car's path, and compare it with RTK
The guess matters: give ICP the gyro's turn and the car's speed.
two walls: every spot along them looks the same poles and corners pin down where along the street
On a simulated drive, LiDAR odometry drifted about 1 percent of the distance driven, mostly through its heading.
23

An RTK outage

Part 5.8

Pick 90 s of car_drive with a fixed RTK, pretend it is lost, and estimate the path three ways from the last good fix. The distance from RTK after 90 s, over three stretches of a simulated drive, on a log scale:

IMU onlyLiDAR onlyLiDAR steps, gyro heading 1 m10 m100 m 55 to 83 m 5 to 9 m 1.4 to 3.4 m
The LiDAR measures distance well and the gyro measures turns well. Together, they beat either one alone. Your own numbers go in Question 10.
24

What to submit

  • GitHub: your workspace, four laptop bags, two car files in data/car/, the analysis notebook, the README with the results table and answers, and the self-check report
  • Canvas: one PDF with Figures 1 to 13
  • Never commit build/, install/, log/, videos, or the car's own bags
ItemPoints
Software and data sets, from the self-check25
Figures 1 to 1349
Results table5
Questions A1, A2, and 1 to 1041
Total120

Lab 4 is 20 percent of the final grade. The LiDAR, the clocks, and the outage are 36 of the 120 points.

25

Where to find help

Stuck for more than 30 minutes? Post the exact error and what you tried, or come to office hours.
26

Three takeaways

1Rehearse on foot, then drive once. READY TO DRIVE: YES comes before the car, and check_bag runs before you leave each site.
2Two computers, one call. The car's recording starts first and stops last, the data lead calls each step, and the clocks are lined up afterward from the data.
3No sensor wins alone. RTK is absolute, the IMU knows turns, the LiDAR knows distance. You will measure how long each lasts without the others.
27