top of page

Line Following and SLAM Integration for TurtleBot3 Autonomous Navigation (MAJOR-Project for MECE-3390U)

LiDAR and computer vision-based autonomous robot for mapping and navigation tasks.

Mission Statement

​This project explores the development of an autonomous navigation system for the TurtleBot-3 robot using both computer vision and SLAM (Simultaneous Localization and Mapping) techniques. The goal was to enhance the robot’s ability to navigate through unknown environments by integrating real-time mapping, localization, and line-following capabilities. In Phase 1, the team implemented a vision-based tracking system using OpenCV and ROS to enable line following on a defined track. Building on this, Phase 2 introduced LiDAR-based SLAM to allow the TurtleBot to explore and map its surroundings autonomously. The project demonstrates the potential of low-cost robotics for real-world applications such as search and exploration in complex terrains.

image.png
image.png

Methodologies of Line Tracking 

In Phase 1, the team implemented a vision-based line following system using OpenCV. Images were processed through grayscale conversion, Canny edge detection, and a PID controller was used for smooth navigation. ROS2 parameters were tuned to improve performance across various tracks.

image.png

Algorithms of Line Tracking 

The algorithm follows a structured loop where video frames are processed to detect line contours using HSV thresholds. Once detected, the centroid of the line guides directional commands (left, right, straight), enabling the TurtleBot to navigate autonomously on a predefined track.

  1. Start the process.

  2. Initialize HSV thresholds and variables.

  3. Loop for each frame:

    1. Capture, crop, convert to HSV, and apply morphological operations.

    2. Find contours.

  4. If no contours, set "No Line Detected", stop.

  5. If found, get the largest contour, calculate the centroid.

  6. If the centroid is invalid, retry. Else, smooth and update.

  7. Determine the movement’s direction 

    1. Left, right, and straight

  8. Send movement command.

  9. Display processed frame.

  10. If 'q' is pressed, exit; else, repeat.

image.png

Challenges and Solutions of Line Tracking 

Key challenges included lighting inconsistencies and slow camera updates. These were resolved by implementing adaptive HSV thresholds, reducing resolution for faster processing, and refining the region of interest (ROI) to improve contour accuracy and speed.

Methodologies of Simultaneous Localization and Mapping (SLAM)

Phase 2 focused on SLAM-based mapping. The team implemented automated logging, marker placement, and clean shutdown protocols using RViz and ROS to generate maps and track the TurtleBot’s path effectively.

image.png

Algorithms of Simultaneous Localization and Mapping (SLAM)

The SLAM algorithm used frontier-based exploration, identifying boundaries between known and unknown spaces. TurtleBot autonomously navigated to reachable frontiers until full map coverage was achieved. Bounding box corner data was recorded for localization reference.

image.png
image.png

Challenges and Solutions Simultaneous Localization and Mapping (SLAM)

Major issues like abrupt shutdowns, terminal overloads, and navigation crashes were addressed with clean exception handling, smarter logging, and proper command termination. These fixes made the code more robust and user-friendly.

Potential Applications with TurtleBot-3

The project demonstrates potential for planetary exploration scenarios, such as Mars or the Moon. TurtleBot could autonomously collect samples, add checkpoints, avoid obstacles, and localize itself using ROS and SLAM integration.

image.png
bottom of page