自己位置推定とマッピング(Localization & Mapping) 
This tutorial introduces LiDAR-SLAM in Minecraft with ROS 2 (Humble) to help you experience how a robot estimates its own position and builds a map of the environment.
What is Localization? 
Localization is the technique that allows a robot to estimate where it is in the world.
It combines sensor data such as wheel odometry, IMU, LiDAR, and camera, to estimate the robot’s pose (position x, y, z and orientation yaw/pitch/roll).
If a map already exists, the robot can match its sensor observations against the map to determine its current location.
Analogy: Like your smartphone maps app showing your current position on the map using GPS and sensors.
What is SLAM? 
SLAM (Simultaneous Localization And Mapping) is used when no prior map exists. It allows the robot to build a map and localize itself within that map at the same time.
- Localization: Needs an existing map, only estimates the robot’s position.
 - SLAM: Builds the map while simultaneously estimating the position.
 
In this tutorial, you will run LiDAR-SLAM in the Minecraft world.
Tutorial Overview 
- Install ROS 2 Humble and developer tools
 - Fetch and build the sample workspace
 - Run SLAM in one terminal
 - Run the Minecraft client in another terminal
 - Move the robot and observe how 
/mapand/tfupdate in real time 
Requirements 
- ROS 2 Humble (Ubuntu 22.04)
 - Tools: 
git,vcstool,colcon,rosdep - Repository: 
minecraft_ros2_example - Packages: 
minecraft_ros2(via.reposfile) - Minecraft client (
runClient.shscript) 
Setup 
0. Install Development Tools 
sudo apt update
sudo apt install -y git python3-vcstool python3-colcon-common-extensions python3-rosdep
# rosdep initialization (only once)
sudo rosdep init || true
rosdep update1. Source ROS 2 Environment 
source /opt/ros/humble/setup.bash2. Fetch the Sample Workspace 
Follow the sample setup guide to fetch and build the example.
How to Run 
Terminal 1: Start SLAM 
source ~/ros2_java_ws/install/setup.bash
source ~/minecraft_ros2_example_ws/install/setup.bash
ros2 launch minecraft_ros2_example lidarslam_ros2.launch.xml- SLAM and bridge nodes will start
 - Topics like 
/scan,/map,/tfwill be published 
Terminal 2: Start Minecraft Client 
cd ~/minecraft_ros2
./runClient.sh- Minecraft client starts in ROS-connected mode
 
How to Verify 
Check Topics 
source ~/minecraft_ros2/install/setup.bash
ros2 topic listCheck Map Updates 
ros2 topic echo /map --qos-durability=transient_localCheck TF Tree 
ros2 run tf2_tools view_frames
# Open frames.pdf to see map -> odom -> base_linkVisualization (Optional) 
rviz2In RViz, add:
- Map (
/map) - LaserScan / PointCloud (
/scan) - TF
 
Troubleshooting 
command not found: ros2/colcon→ Make sure you sourced/opt/ros/humble/setup.bash.rosdeperrors → Runsudo rosdep initandrosdep update.- Missing or non-executable 
runClient.sh→chmod +x runClient.sh. - Build fails (missing deps) → Run 
rosdep install ...again. - No topics appearing → Ensure Terminal 1 (SLAM) is running and Terminal 2 (client) is connected.
 
Summary 
- Localization: Estimate your position on an existing map.
 - SLAM: Build a map and localize at the same time.
 - With this tutorial, you can run LiDAR-SLAM in Minecraft, and watch how 
/mapand/tfupdate with the robot’s movement. 
Try visualizing with RViz for deeper understanding.