A simple Python/ROS controller for solving a maze using the TurtleBot3 Burger.
This repository contains a single-node ROS program (main.py) that reads laser scans
and odometry to perform wall-following, detect openings (doors), and navigate around
cylindrical obstacles. The code was written for educational/demo purposes (assignment
artifact in Docs/).
Quick summary:
- Language: Python 2/3 with
rospy(script currently uses Python-style ROS APIs) - Robot: TurtleBot3 Burger (uses
/cmd_vel,/scan,/odomtopics) - Main file:
main.py
Note about platforms: This project is intended to run in a ROS environment (typically Ubuntu with ROS). If you're on Windows, run it inside WSL2/Ubuntu or a Linux VM with ROS installed.
Tested / expected environment
- Ubuntu 18.04/20.04 with ROS Melodic/Noetic (the code uses
rospyandtf.transformations) - TurtleBot3 packages installed (
turtlebot3andturtlebot3_simulationsif using Gazebo)
Contents
main.py- controller node: subscribes to/scanand/odom, publishes to/cmd_vel.Docs/- assignment PDF and screenshots documenting the original work.
Prerequisites
- ROS installed (Melodic/Noetic as appropriate for your Ubuntu version)
turtlebot3packages (for robot definitions, URDF, and simulation launch files)- Python
rospyandtfpackages (installed with ROS)
Installation / Setup
- Clone this repository into your ROS workspace (example
~/catkin_ws/src):
cd ~/catkin_ws/src
git clone https://github.com/lakizuru/Turtlebot3-Maze-Solver.git
cd ~/catkin_ws
catkin_make
source devel/setup.bash- Install TurtleBot3 packages (if not already installed):
# Example for ROS Noetic on Ubuntu 20.04
sudo apt update
sudo apt install ros-noetic-turtlebot3 ros-noetic-turtlebot3-simulations- Set the TurtleBot3 model environment variable (example):
export TURTLEBOT3_MODEL=burgerRunning the node
The main.py script is a standalone ROS node. You can either run it from a ROS package
using rosrun (recommended) or run it directly after sourcing your workspace. Example steps
for simulation using TurtleBot3 in Gazebo:
# start roscore (if not already running)
roscore &
# in a new terminal: launch turtlebot3 world (Gazebo)
export TURTLEBOT3_MODEL=burger
roslaunch turtlebot3_gazebo turtlebot3_world.launch
# in another terminal: run this node (assumes repo is in a sourced workspace)
rosrun Turtlebot3-Maze-Solver main.pyIf you do not have the code inside a ROS package, create a small package and place
main.py in the scripts/ folder with executable permissions, then catkin_make.
Notes & configuration
- Goal positions used by the node are hard-coded near the top of
main.pyin theDES_POS1..DES_POS5variables. Adjust these if you want to change target coordinates. - The node expects a standard
sensor_msgs/LaserScanon/scanandnav_msgs/Odometryon/odom. - The logic is simple and geared toward demonstration; you may want to harden it for production (robustness to NaNs/inf, dynamic reconfiguration, parameterization).
Contributing
- If you want to contribute, consider:
- Moving the code into a proper ROS package with
package.xmlandCMakeLists.txt. - Adding a ROS launch file and command-line parameters for configurable goals.
- Adding unit tests for helper functions and simulation CI.
- Moving the code into a proper ROS package with
Acknowledgements
- This repository contains an assignment PDF in
Docs/which documents the original coursework that this code was created for.
License
- No license is included. If you want to make this repository public, add a suitable
open-source license (e.g., MIT, Apache-2.0) in a
LICENSEfile.