An indoor mobile robot simulation project integrating MATLAB, Simulink, ROS 1 Noetic, Gazebo 11, and TurtleBot3 Waffle. It implements an end-to-end workflow from sensor interaction and 2-D lidar SLAM to reactive obstacle avoidance and custom A* multi-goal patrol. The repository includes the control and navigation code, a custom Gazebo world, reproducible map and goal data, and simulation results.
Scope note: the navigation algorithms and controllers are implemented in MATLAB; the ROS Navigation Stack, AMCL, and gmapping are not used.
- Turtlesim motion control with both a MATLAB script and a Simulink model.
- A custom 8 m x 6 m Gazebo indoor world with a TurtleBot3 Waffle launcher.
- Keyboard teleoperation with live LaserScan and camera visualization in MATLAB.
- Online 2-D lidar SLAM using MATLAB
lidarSLAM. - Interactive waypoint selection and sequential patrol with reactive obstacle avoidance.
- A custom 8-connected A* planner with Euclidean heuristic, obstacle inflation, waypoint tracking, and multi-goal patrol.
- Best-effort zero-velocity cleanup guards for interrupted controller runs.
Gazebo 11 / TurtleBot3 Waffle (Ubuntu, ROS 1 Noetic)
| /scan, /odom, camera topics
v
MATLAB ROS Toolbox (Windows host)
|-- teleoperation and sensor display
|-- lidarSLAM -> occupancyMap
|-- interactive goal selection
`-- reactive patrol / custom A* patrol -> /cmd_vel
matlab/
task1_turtlesim/ MATLAB turtlesim controller
task2_teleoperation/ Keyboard control and sensor dashboard
task3_slam_navigation/ SLAM, waypoint patrol, and A* pipeline
ros_network_config.m Environment-based ROS network configuration
simulink/task1_turtlesim/ Final two-lap Simulink model
ros1_ws/src/my_robot_sim/ Catkin package with launch and world files
assets/images/ Result figures
assets/demos/ Demonstration recordings
tests/ MATLAB tests for the standalone A* planner
- MATLAB R2024b
- Simulink
- ROS Toolbox
- Robotics System Toolbox
- Navigation Toolbox
- Ubuntu 20.04.6 LTS with ROS 1 Noetic and Gazebo 11
- TurtleBot3 Waffle packages
- VMware NAT networking between the Windows host and Ubuntu guest
The ROS environment can be reproduced on Ubuntu 20.04 / ROS 1 Noetic when the dependencies below are installed.
Copy ros1_ws/src/my_robot_sim into a Catkin workspace, then run:
cd ~/catkin_ws
catkin_make
source devel/setup.bash
export TURTLEBOT3_MODEL=waffle
roslaunch my_robot_sim start_world.launchRequired ROS packages include gazebo_ros, xacro, and turtlebot3_description. The launch file loads worlds/my_world.world, publishes the robot description, and spawns a TurtleBot3 Waffle at the world origin.
In MATLAB, from the repository root:
addpath(genpath(fullfile(pwd, "matlab")));
setenv("ROS_MASTER_URI", "http://<ubuntu-vm-ip>:11311");
setenv("ROS_IP", "<windows-vmnet-ip>");The two IP addresses must belong to the same VMware NAT subnet; network addresses are configured through environment variables rather than fixed in the source code.
Task 1 — turtlesim script:
- Start
roscoreandturtlesim_nodein Ubuntu. - Run
matlab/task1_turtlesim/turtlebot.min MATLAB. - For Simulink, run
simulink/task1_turtlesim/prepare.m, then openturtle_circle_2laps.slx.
Task 2 — teleoperation and live sensors:
- Launch the custom world as shown above.
- Run
control_turtlebotfrommatlab/task2_teleoperation. - Use
W/S/A/Dto move,Xto stop, andQto quit.
Task 3 — mapping and navigation:
rosconnect.m
step1_check_lidar.m
step2_online_slam.m # move the robot while scans are collected
step3_build_save_map.m
task2_step1_show_map_pose.m
task2_step2_select_goals.m
auto_patrol.m # reactive patrol
task3_step1_astar_planning.m # offline path preview
task3_step2_astar_nav.m # single-goal navigation
task3_step3_astar_patrol.m # multi-goal patrol
The included gazebo_map_20251103_1956.mat contains a MATLAB occupancyMap. The included task2_goal_points.mat contains five sample world-coordinate goals; selecting goals again overwrites this file.
| Component | Configuration |
|---|---|
| Lidar SLAM | 20 cells/m, 3.5 m maximum range |
| Loop closure | threshold 200, search radius 3.5 m |
| Reactive patrol | front sector +/-30 degrees, 0.35 m safety distance |
| A* | 8-connected grid, Euclidean heuristic, no diagonal corner cutting |
| Planning safety | occupancy threshold 0.65, 0.25 m map inflation |
| Path following | every fourth grid point used as a waypoint |
| Stage | Result |
|---|---|
| Simulink two-lap controller | ![]() |
| Teleoperation and sensors | ![]() |
| SLAM occupancy map | ![]() |
| Reactive patrol | ![]() |
| A* patrol | ![]() |
The screenshots and videos were captured from completed simulation runs. The included five-goal MAT file is a reproducible sample and is not asserted to be the exact waypoint set used in every recorded run.
Automated tests cover ROS environment configuration and standalone A* planning, including straight-line planning, routing around a wall, blocked endpoints, and diagonal corner blocking:
results = runtests("tests");
assertSuccess(results);All ROS package XML files are well formed. Runtime reproduction additionally requires a running ROS/Gazebo environment and correct host/guest networking.
The ROS package was also verified in a clean temporary Catkin workspace on Ubuntu 20.04.6 / ROS Noetic / Gazebo 11.13.0. catkin_make completed successfully, roslaunch started a fresh ROS master, Gazebo server/client, and spawn_tb3; the TurtleBot3 laser, differential-drive, joint-state, and odometry plugins initialized before the bounded validation run was shut down.
- The reactive controller can enter local minima in concave or tightly constrained environments.
- The A* follower uses simple waypoint tracking plus a short-range front-sector check; it is not a full local planner.
- The saved occupancy map and goals assume the same Gazebo world frame and initial robot placement.
- AVI demonstration files may need to be downloaded because GitHub does not preview every codec.
Jiaxin Wu — @5Elaine




