Skip to content

Commit ddcfff1

Browse files
Yutaroprjohn-v
andauthored
Add turtlebot3 example (#193)
* add images of examples using turtlebot3 * add example tutorial of turtlebot3 * change turtlebot3 image and add gif to show example3 image * fix image file path * compress gif file * add specification i used for the demo * add launch file for turtlebot3 and mcp server --------- Co-authored-by: Rohit John Varghese <rohit@contoro.com>
1 parent 693221a commit ddcfff1

File tree

7 files changed

+185
-0
lines changed

7 files changed

+185
-0
lines changed

examples/9_turtlebot3/README.md

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
# Example - Turtlebot3 (Real)
2+
3+
![Static Badge](https://img.shields.io/badge/ROS2-Available-green)
4+
5+
This example demonstrates the use of a real TurtleBot3 Burger robot with ROS2.
6+
The TurtleBot3 is a compact, customizable mobile robot designed for education and research. It supports applications such as SLAM, navigation, and autonomous control, and comes in various hardware configurations.
7+
8+
9+
## Prerequisites
10+
11+
For this example, the TurtleBot3 Burger version with Ubuntu 22.04 and ROS2 Humble is used. Depending on your TurtleBot3 model and installed hardware (e.g., LDS-01 LiDAR), make sure to install the corresponding packages required for your specific configuration.
12+
13+
### Turtlebot3
14+
15+
For more details, please refer to the [TurtleBot3 Documentation](https://emanual.robotis.com/docs/en/platform/turtlebot3/overview/).
16+
17+
<img src="images/turtlebot3_image.png" width="300">
18+
19+
- **Specification**
20+
- **OS** : Ubuntu 22.04
21+
- **ROS** : ROS2 Humble
22+
- **TurtleBot3 Model** : Burger
23+
- **LiDAR** : LDS-01
24+
- **Computer** : Raspberry Pi 3 Model B+ (1GB RAM)
25+
- **Motor Controller** : OpenCR 1.0 (Firmware v0.2.1)
26+
27+
## Quick Start
28+
29+
### 1. Network Setup
30+
31+
Since the TurtleBot3 is controlled via ROS-MCP from the user PC, it is important to connect both the user PC and the TurtleBot3 to the same network.
32+
> **Note:** You can check your network IP address with the `ifconfig` command.
33+
34+
**Ping Test**
35+
36+
After connecting them to the same network, perform a ping test from the user PC to TurtleBot3 to verify that the connection is established correctly:
37+
**[User's PC]**
38+
```bash
39+
ping <TURTLEBOT3_IP> # e.g., ping 192.168.101.166
40+
```
41+
42+
**ROS2 Network Setup**
43+
44+
In ROS2, environment variables are used to configure Domain ID and ROS middleware behavior.
45+
On both the user PC and TurtleBot3, export:
46+
**[User's PC]** **[Turtlebot3 SBC]**
47+
```bash
48+
echo "export ROS_DOMAIN_ID=30" >> ~/.bashrc
49+
echo "export RMW_IMPLEMENTATION=rmw_fastrtps_cpp" >> ~/.bashrc
50+
source ~/.bashrc
51+
```
52+
53+
### 2. Bringup Turtlebot3
54+
55+
Open a new terminal on the user PC and connect to the Raspberry Pi via SSH using its IP address. Enter your Ubuntu OS password for the Raspberry Pi.
56+
57+
**[User's PC]**
58+
```bash
59+
ssh ubuntu@{IP_ADDRESS_OF_RASPBERRY_PI}
60+
```
61+
62+
Bring up basic packages to start essential TurtleBot3 applications. You will need to specify your TurtleBot3 model.
63+
64+
**[Turtlebot3 SBC]**
65+
```bash
66+
export TURTLEBOT3_MODEL=burger
67+
ros2 launch turtlebot3_bringup robot.launch.py
68+
```
69+
70+
### 3. Launch Node on Your Turtlebot3 SBC and Open claude-desktop on Your PC
71+
72+
**[Turtlebot3 SBC]**
73+
```bash
74+
ros2 launch rosbridge_server rosbridge_websocket_launch.xml
75+
```
76+
77+
**[User's PC]**
78+
```bash
79+
claude-desktop
80+
```
81+
82+
## **Example Walkthrough**
83+
You're now ready to interact with the TurtleBot3 via the ROS MCP server. Follow these examples step-by-step:
84+
85+
### **Example 1**: Connect to Robot
86+
87+
<img src="images/turtlebot3_connect.png" width="500">
88+
89+
### **Example 2**: Check Available Topics
90+
91+
<img src="images/turtlebot3_gettopics_1.png" width="500">
92+
<img src="images/turtlebot3_gettopics_2.png" width="500">
93+
94+
### **Example 3**: Move the Robot Back and Forth
95+
<img src="images/turtlebot3_example3.gif" width="500">
96+
97+
98+
## **Next Steps**
99+
If your TurtleBot3 is equipped with a Raspberry Pi camera, you can now start streaming visual data. Try integrating camera feeds into your pipeline for more advanced robot control demos.
85.9 KB
Loading
2.73 MB
Loading
108 KB
Loading
49.8 KB
Loading
257 KB
Loading
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
#!/usr/bin/env python3
2+
3+
"""
4+
ROS2 Launch file for ROS-MCP Server with TurtleBot3
5+
This launch file starts:
6+
- rosbridge_websocket server
7+
- TurtleBot3 robot
8+
- Provides proper process management and cleanup
9+
"""
10+
11+
import os
12+
13+
from launch.actions import DeclareLaunchArgument, IncludeLaunchDescription, LogInfo
14+
from launch.launch_description_sources import PythonLaunchDescriptionSource
15+
from launch.substitutions import LaunchConfiguration
16+
from launch_ros.actions import Node
17+
from launch_ros.substitutions import FindPackageShare
18+
19+
from launch import LaunchDescription
20+
21+
22+
def generate_launch_description():
23+
"""Generate the launch description for ROS-MCP Server with TurtleBot3."""
24+
25+
# Declare launch arguments
26+
rosbridge_port_arg = DeclareLaunchArgument(
27+
"port", default_value="9090", description="Port for rosbridge websocket server"
28+
)
29+
30+
rosbridge_address_arg = DeclareLaunchArgument(
31+
"address",
32+
default_value="",
33+
description="Address for rosbridge websocket server (empty for all interfaces)",
34+
)
35+
36+
# Rosbridge websocket server node
37+
rosbridge_node = Node(
38+
package="rosbridge_server",
39+
executable="rosbridge_websocket",
40+
name="rosbridge_websocket",
41+
output="screen",
42+
parameters=[
43+
{
44+
"port": LaunchConfiguration("port"),
45+
"address": LaunchConfiguration("address"),
46+
"use_compression": False,
47+
"max_message_size": 10000000,
48+
"send_action_goals_in_new_thread": True,
49+
"call_services_in_new_thread": True,
50+
}
51+
],
52+
arguments=["--ros-args", "--log-level", "info"],
53+
)
54+
55+
# Include TurtleBot3 bringup launch file
56+
turtlebot3_bringup_launch = IncludeLaunchDescription(
57+
PythonLaunchDescriptionSource(
58+
[
59+
os.path.join(
60+
FindPackageShare("turtlebot3_bringup").find("turtlebot3_bringup"),
61+
"launch",
62+
"robot.launch.py",
63+
)
64+
]
65+
)
66+
)
67+
68+
# Log info about what's being launched
69+
log_info = LogInfo(
70+
msg=[
71+
"Starting ROS-MCP Server with:",
72+
" - Rosbridge WebSocket on port: ",
73+
LaunchConfiguration("port"),
74+
" - TurtleBot3 robot bringup",
75+
]
76+
)
77+
78+
return LaunchDescription(
79+
[
80+
rosbridge_port_arg,
81+
rosbridge_address_arg,
82+
log_info,
83+
rosbridge_node,
84+
turtlebot3_bringup_launch,
85+
]
86+
)

0 commit comments

Comments
 (0)