This project is a full ROS2 SLAM stack for a TurtleBot3 navigating around cylindrical landmarks. It combines a custom 2D simulator, wheel-encoder odometry, lidar-based landmark detection, and an Extended Kalman Filter that estimates both the robot pose and landmark map online. In RViz, the red robot is simulation ground truth, the blue robot is raw odometry, and the green robot is the SLAM-corrected estimate.
The stack is split into reusable layers: a non-ROS math library, robot control and odometry nodes, a simulator, and SLAM nodes. Each layer communicates over normal ROS2 topics so the same logic can run in simulation or on the real TurtleBot3.
cmd_vel
|
v
turtle_control --> wheel_cmd --> nusim / TurtleBot hardware
^ |
| v
joint_states <-- sensor_data <-- wheel encoders
|
v
odometry --> /odom --> EKF predict
/scan --> landmarks --> detected cylinders --> EKF update
|
v
map -> odom TF + landmark mapThe robot is modeled as a differential-drive system. Wheel commands are converted into left/right wheel velocities, encoder ticks are converted back into wheel angles, and forward kinematics integrates those wheel angle changes into odometry. This creates the blue robot estimate in RViz.
left_encoder, right_encoder
|
v
wheel angles in radians
|
v
delta left/right wheel motion
|
v
body twist: [omega, vx, 0]
|
v
integrate SE(2) transform
|
v
odom -> base_footprintAdvantages
Limitations
The landmark detector turns raw LaserScan ranges into cylindrical landmark detections. It first converts scan rays into Cartesian points in the scan frame, clusters neighboring points, fits circles to candidate clusters, and rejects bad fits before publishing the landmark positions to SLAM.
LaserScan ranges
|
v
polar -> Cartesian points
|
v
cluster consecutive nearby points
|
v
fit circle to each cluster
|
v
filter by radius, RMSE, and circularity
|
v
publish detected landmark centersThe simulator can publish landmark observations with known IDs. This is useful for validating the EKF math because it removes the data-association problem and lets the filter focus only on prediction and correction.
Advantages
Limitations
The real SLAM pipeline uses only detected landmark positions from the laser scanner. This is harder because the robot has to decide whether a detection is a previously seen landmark or a new one.
Advantages
Limitations
The EKF state stores the robot pose followed by each landmark position: [x, y, theta, m1_x, m1_y, m2_x, m2_y, ...]. Odometry drives the predict step, and landmark observations drive the update step.
For every odometry update:
1. Compute odom-frame delta from the previous odom pose.
2. Rotate that delta into the robot body frame.
3. Predict the robot pose with the motion model.
4. Grow covariance based on movement uncertainty.
For every landmark observation:
1. Transform the observation into the current map frame.
2. Match it to the nearest known landmark or create a new one.
3. Compute expected observation from the current EKF state.
4. Apply the Kalman update to correct robot pose and landmark map.
5. Publish map -> odom so the green robot shows the corrected pose.Known data association uses simulator-provided landmark IDs. This version is the controlled experiment: if the EKF still behaves badly here, the issue is likely in the filter math, motion model, covariance, or TF publishing rather than the perception system.
Advantages
Limitations
Unknown data association projects each detected landmark into the current map frame and compares it against the existing map. If the nearest landmark is within a distance threshold, the observation updates that landmark. Otherwise, the EKF initializes a new landmark.
detected landmark in robot frame
|
v
transform into map frame using current SLAM pose
|
v
compare distance to all known landmarks
|
+-- nearest distance <= threshold --> update existing landmark
|
+-- nearest distance > threshold --> initialize new landmarkAdvantages
Limitations
In simulation, SLAM strongly outperformed wheel odometry after driving around the landmark field and returning near the start. The blue odometry robot drifted visibly, while the green SLAM robot stayed locked to the landmark map.
Simulation: green SLAM estimate correcting the blue odometry drift
The result is a direct comparison between dead reckoning and landmark-corrected localization. Odometry gives a smooth short-term estimate, but SLAM wins over longer paths because it can use landmarks to remove accumulated drift.
Advantages
Limitations
The same SLAM pipeline was deployed on a physical TurtleBot3. The robot-side launch brought up the hardware interface, wheel control, odometry, laser driver, landmark detector, and SLAM. The PC-side launch handled RViz and teleoperation.
TurtleBot:
hardware interface
laser driver
turtle_control
odometry
landmarks
slam_uda
Workstation:
RViz
teleop or circle command sourceReal TurtleBot3 deployment shown side by side with RViz SLAM output
# Landmark detection only
ros2 launch nuslam landmark_detect.launch.xml robot:=nusim
# EKF SLAM with unknown data association in simulation
ros2 launch nuslam unknown_data_assoc.launch.xml cmd_src:=teleop
# Real robot split deployment
ros2 launch nuslam turtlebot_bringup.launch.xml
ros2 launch nuslam pc_bringup.launch.xml cmd_src:=teleop