The EKF SLAM state
EKF SLAM keeps a Gaussian belief over a state that stacks the robot pose and every landmark found so far: The state has entries and grows as the robot finds landmarks. The covariance holds the uncertainty of the pose and of each landmark, and the cross terms between every pair. The cross terms are nonzero because the map was built from an uncertain pose. Through them, a correction to one landmark also moves the pose and every other landmark. The prediction step moves only the pose, because landmarks do not move. With the velocity motion model from the EKF localization section and its Jacobians (state) and (wheel speeds), where is the covariance of the wheel-speed noise. The pose block, the pose’s cross terms with the map, and nothing else change. The robot model is copied from the EKF localization section.Measurements, new landmarks and correspondences
A landmark is measured as a range and bearing, , the same model as in localization. The difference is that the landmark position is now part of the state, so the Jacobian has two nonzero blocks: one for the pose and one for landmark . For the innovation covariance and the gain the filter builds the full matrix where is the measurement noise. The bearing part of the innovation is wrapped to : a landmark straight behind the robot can be measured at and predicted at , and without wrapping, the raw difference of almost would enter the update as a large wrong innovation.Unknown correspondences
The algorithm of Thrun, Burgard and Fox (Table 10.2) picks, for each measurement , the landmark with the smallest Mahalanobis distance the quantity of the correspondence estimation section. It also considers one extra hypothesis, that comes from a landmark not yet in the map, and gives that hypothesis the fixed score . If every existing landmark scores above , the measurement starts a new landmark. The code uses , the 99.9th percentile of the distribution with 2 degrees of freedom: a measurement of a known landmark scores above it only once in a thousand times.Adding a landmark
The new landmark’s mean is the measured point placed in the world from the predicted pose, Its covariance must contain both the measurement noise and the pose uncertainty, and it must be correlated with the pose. Thrun, Burgard and Fox start every landmark with infinite variance (their equation 10.10), which a computer cannot store. The code instead extends with the two Jacobians of this placement function, with respect to the pose and with respect to the measurement, as Corke does in sections 6.3 and 6.4 (Corke, 2023): With landmarks in the map, the quantities above have these sizes:
The block matrix that multiplies in the prediction is , with in the pose block and the identity on the landmarks. Adding a landmark grows the state by 2 and the covariance by two rows and two columns.
A measurement that creates a landmark is not used to update the pose: it carries no information about the pose until the landmark is seen again. The function
ekf_slam below performs one prediction and then processes the measurements one at a time, updating the belief after each.
The room and the drive
The TurtleBot drives a counterclockwise circle of radius 2.4 m at 0.2 m/s in a room with walls at m. Eight pillars of radius 10 cm stand on a ring of radius 2.8 m, just outside the path. Only pillars within 2.5 m are used. The drive lasts 1.6 laps, 603 steps of 0.2 s, so the robot passes its first landmarks again. The robot follows the circle exactly. The noise is in the wheel encoder readings: each step the reported wheel speeds differ from the true ones by the noise used in the EKF localization section, a standard deviation of 5% of each wheel speed plus 0.1 rad/s. Dead reckoning integrates these reports, and so does the filter’s prediction.Pillars from a LIDAR scan
The simulated LIDAR matches the one on the course simulator’s TurtleBot3: 360 beams, one per degree, five scans a second, range noise of 1 cm. A scan is a list of ranges, so the front end has to find the pillars in it. It splits the scan wherever the range jumps by more than 15 cm between neighboring beams. A pillar in front of a wall shows up as a short run of beams with a jump on both sides. A cluster wider than 25 cm is a stretch of wall and is dropped, and so is a cluster farther than 2.5 m. The pillar’s bearing is the mean bearing of its beams, and its range is the shortest range in the cluster plus the pillar radius, because the beams hit the near surface. The same steps apply to a real scan, with three refinements. The jump threshold should grow with range, because neighboring beams land farther apart on distant surfaces. A pole of unknown size is better handled by fitting a circle to the cluster’s points and reporting the range and bearing of its center. Walls and corners, the other common landmarks, are found by fitting lines to the clusters. For ROS 2, laser_segmentation segments laser scans this way. A 3D point cloud is usually treated as an unordered set of points instead. The common pipeline removes the ground plane with RANSAC and groups the remaining points by their Euclidean distance. Open3D provides the two steps assegment_plane and cluster_dbscan, and the Point Cloud Library as SACSegmentation and EuclideanClusterExtraction.
A LIDAR feature carries a weaker signature than a camera’s. The cluster’s width and shape separate a pillar from a wall, and the intensity of the returns separates a retroreflector from paint or concrete. The Point Cloud Library also computes shape descriptors that serve as a 3D signature, such as FPFH for the neighborhood of a point and VFH for a whole cluster. These attributes identify the kind of landmark that was hit, but not the individual landmark. Identical pillars still look alike, which is why this section has to estimate the correspondences.
Pillars from the D435i
The D435i sees only what is in front of it, within its field of view. The front end projects each pillar’s center into the color image with the intrinsics from the course’s D435i configuration ( px, px, 640 pixels wide) and adds one pixel of noise to the column. The depth image gives the distance to the pillar’s near surface. Stereo depth error grows with the square of the distance, so the code uses a standard deviation of m, an assumed model rather than a datasheet value. From the column and the depth, the bearing and range in the camera frame are The camera sits at the robot’s origin, looking forward. On a real robot the camera-to-base transform from the D435i section moves the measurement into the base frame first.Measurement noise of the front ends
The filter needs , the covariance of the range and bearing a front end reports. The code below places the robot at 400 random poses and compares each detection with the true pillar.Running the filter
The code below drives the loop once with each front end. Both runs use the same wheel noise, so dead reckoning is the same in both.Watching a run step by step
The recording below replays both runs, the LIDAR run on the left and the camera run on the right. In each map the green arrow is the true pose and the orange arrow is the filter’s estimate, with its ellipse. The gray line is dead reckoning. Blue dots are the landmarks in the map, each with its own ellipse, and the gold lines are the current step’s measurements. The gray dots in the LIDAR map are the current scan, and the gold wedge in the camera map is the field of view. The plots underneath show the position error and the number of landmarks in the map for both runs.
Press play or drag the time marker. Scroll to zoom a map and double-click to reset it. The button at the top right of each panel opens it full size.
Limits of EKF SLAM
The covariance has entries, and every update touches all of them, so each step costs . A few hundred landmarks is the practical limit. Maximum likelihood correspondence has a second weakness: it selects one assignment and never reconsiders it, so a single wrong association stays in the map permanently. Thrun, Burgard and Fox (section 10.3.3) list the usual defenses: a provisional list where new landmarks wait until they have been seen several times, a counter that removes landmarks the robot should see but does not, and landmarks spaced far enough apart that they cannot be confused. The pillars here are 2.1 m apart and are seen within 2.5 m, so the association is easy. In this section the LIDAR and the camera only produce landmarks for the same filter. A camera can also estimate its own motion without any depth, from how image features move, and that is what the visual-inertial odometry and visual SLAM sections build on. Visual SLAM systems also replace the single growing filter with a graph of keyframes optimized in batches, which removes the limit.Lectures
Key references: (Burgard & Thrun, n.d.; Corke, 2023)
References
- Burgard, W., Thrun, S. (n.d.). Probabilistic Robotics.
- Corke, P. (2023). Robotics, vision and control: Fundamental algorithms in python.
Found an error on this page? Report an issue.

