Table of Contents
Overview#
SLAM (Simultaneous Localization and Mapping) allows a robot to build a map while tracking its position. This guide covers the initialization commands for TurtleBot3.
System Architecture#
┌─────────────────────────────────┐
│ PC │
│ ┌─────────┐ ┌──────────────┐ │
│ │ roscore │ │ SLAM + RViz │ │
│ └────┬────┘ └──────┬───────┘ │
│ │ │ │
└───────┼──────────────┼──────────┘
│ WiFi │
┌───────┼──────────────┼──────────┐
│ │ │ │
│ ┌────┴────────┐ │ │
│ │ Bringup │ │ │
│ │ (sensors) │←────┘ │
│ └────────────┘ │
│ TurtleBot3 │
└─────────────────────────────────┘Step 1: Start ROS Master (PC)#
roscoreExpected output:
... logging to /home/user/.ros/log/...
started roslaunch server http://192.168.0.3:xxxxx/
ros_comm version 1.16.0
SUMMARY
========
PARAMETERS
* /rosdistro: noetic
* /rosversion: 1.16.0
NODES
auto-starting new master
process[master]: started with pid [xxxx]
ROS_MASTER_URI=http://192.168.0.3:11311
...Step 2: Launch Robot (TurtleBot3)#
SSH into TurtleBot3:
ssh ubuntu@<TURTLEBOT_IP>Set model and launch:
export TURTLEBOT3_MODEL=burger
roslaunch turtlebot3_bringup turtlebot3_robot.launchExpected output:
SUMMARY
========
PARAMETERS
...
NODES
/
turtlebot3_core (rosserial_python/serial_node.py)
turtlebot3_diagnostics (turtlebot3_bringup/turtlebot3_diagnostics)
turtlebot3_lds (hls_lfcd_lds_driver/hlds_laser_publisher)
...
[INFO] Calibration EndKey nodes:
- turtlebot3_core: Serial communication with OpenCR
- turtlebot3_lds: Laser scanner driver
- turtlebot3_diagnostics: System health monitoring
Step 3: Launch SLAM (PC)#
export TURTLEBOT3_MODEL=burger
roslaunch turtlebot3_slam turtlebot3_slam.launchThis launches:
- SLAM algorithm (gmapping by default)
- RViz for visualization
Alternative SLAM Methods#
# Gmapping (default)
roslaunch turtlebot3_slam turtlebot3_slam.launch slam_methods:=gmapping
# Cartographer
roslaunch turtlebot3_slam turtlebot3_slam.launch slam_methods:=cartographer
# Hector SLAM
roslaunch turtlebot3_slam turtlebot3_slam.launch slam_methods:=hectorStep 4: Launch Teleop (PC)#
In a new terminal:
export TURTLEBOT3_MODEL=burger
roslaunch turtlebot3_teleop turtlebot3_teleop_key.launchControl keys:
w
a s d
x
w/x: Increase/decrease linear velocity
a/d: Increase/decrease angular velocity
s: Stop
CTRL+C: QuitVerification#
Check Topics#
rostopic listImportant topics:
/scan: Laser data/odom: Odometry/map: Generated map/cmd_vel: Velocity commands
Monitor Laser#
rostopic echo /scanView TF Tree#
rosrun rqt_tf_tree rqt_tf_treeSaving the Map#
After exploring:
rosrun map_server map_saver -f ~/mapCreates:
map.pgm: Image filemap.yaml: Metadata
Troubleshooting#
| Issue | Solution |
|---|---|
| No laser data | Check LDS connection |
| Robot not moving | Verify OpenCR power |
| Map drifting | Move slower, better loop closure |
| RViz not showing | Check Fixed Frame = “map” |
Complete Command Summary#
| Terminal | Machine | Command |
|---|---|---|
| 1 | PC | roscore |
| 2 | TB3 (SSH) | roslaunch turtlebot3_bringup turtlebot3_robot.launch |
| 3 | PC | roslaunch turtlebot3_slam turtlebot3_slam.launch |
| 4 | PC | roslaunch turtlebot3_teleop turtlebot3_teleop_key.launch |