You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For users who want to test the MCP server without needing to install ROS, this is an example that provides a dockerized ROS2 container preinstalled with the simplest possible 'robot' in the ROS ecosystem - TurtleSim.
2
+
3
+
For users who want to test the MCP server without needing to install ROS, this is an example that provides a dockerized ROS2 container preinstalled with the simplest possible 'robot' in the ROS ecosystem - TurtleSim.
3
4
4
5
Turtlesim is a lightweight simulator for learning ROS / ROS 2. It illustrates what ROS does at the most basic level to give you an idea of what you will do with a real robot or a robot simulation later on.
5
6
6
7
## Prerequisites
7
8
8
-
✅ **Note:** This tutorial is designed to be run on linux and has been tested with Ubuntu as well as [Ubuntu running on WSL](https://apps.microsoft.com/detail/9pn20msr04dw?hl=en-US&gl=US). Being a dockerized container, it is likely to work on other OS versions as well with the correct X11 forwarding settings.
9
+
✅ **Cross-Platform Support:** This tutorial works on Linux, macOS, and Windows with proper X11/display forwarding setup. Each platform has specific requirements detailed below.
9
10
10
11
Before starting this tutorial, make sure you have the following installed:
# Set DISPLAY for your Mac (use the display number from Step 3)
155
+
export DISPLAY=:1 # or :0 depending on what you found
156
+
157
+
# Allow X11 connections
158
+
xhost +
159
+
160
+
# Set DISPLAY for Docker (use your IP from Step 4 + display number)
161
+
export DOCKER_DISPLAY=<YOUR_IP># Replace with your actual IP
103
162
```
163
+
</details>
164
+
165
+
## Troubleshooting
104
166
105
-
### Display Issues (macOS)
167
+
### macOS Display Issues
106
168
107
-
For macOS users, make sure XQuartz is running and configured:
169
+
<details>
170
+
<summary><strong>Problem: <code>qt.qpa.xcb: could not connect to display</code></strong></summary>
171
+
172
+
**Solutions**:
173
+
174
+
1.**Check XQuartz is running**:
175
+
```bash
176
+
ps aux | grep X11
177
+
```
178
+
179
+
2.**Verify display number**:
180
+
```bash
181
+
# Look for :0 or :1 in the Xquartz process
182
+
ps aux | grep Xquartz | grep -o ":[0-9]"
183
+
```
184
+
185
+
3.**Check your IP address**:
186
+
```bash
187
+
ifconfig en0 | grep inet
188
+
```
189
+
190
+
4.**Set correct DOCKER_DISPLAY**:
191
+
```bash
192
+
export DOCKER_DISPLAY="YOUR_IP:DISPLAY_NUMBER"
193
+
# Example: export DOCKER_DISPLAY="10.1.56.72:1"
194
+
```
195
+
196
+
5.**Allow X11 connections**:
197
+
```bash
198
+
export DISPLAY=:1 # Use your display number
199
+
xhost +
200
+
```
201
+
</details>
202
+
203
+
<details>
204
+
<summary><strong>Problem: <code>xhost: unable to open display ":0"</code></strong></summary>
205
+
206
+
**Solution**: XQuartz might be using `:1` instead of `:0`:
108
207
109
208
```bash
110
-
# Start XQuartz
111
-
open -a XQuartz
209
+
export DISPLAY=:1
210
+
xhost +
211
+
```
212
+
</details>
112
213
113
-
# Allow connections from localhost
114
-
xhost +localhost
214
+
### Linux Display Issues
215
+
216
+
<details>
217
+
<summary><strong>Display issues on Linux</strong></summary>
218
+
219
+
If you encounter display issues on Linux, run:
220
+
221
+
```bash
222
+
xhost +local:docker
115
223
```
224
+
</details>
225
+
226
+
### Windows Display Issues
227
+
228
+
<details>
229
+
<summary><strong>Display issues on Windows</strong></summary>
116
230
117
-
### Display Issues (Windows/PowerShell)
118
231
For Windows users, make sure you install an X Server (X410) and set the DISPLAY:
119
232
120
233
```bash
121
-
$env:DISPLAY="host.docker.internal:0.0"
234
+
$env:DOCKER_DISPLAY="host.docker.internal:0.0"
122
235
```
236
+
</details>
237
+
238
+
### General Issues
239
+
240
+
<details>
241
+
<summary><strong>Problem: Container starts but no window appears</strong></summary>
123
242
124
-
### Container Networking
243
+
**Solutions**:
244
+
1. Check if the window is hidden behind other windows
245
+
2. Look in Mission Control (macOS) or Alt+Tab (Windows/Linux)
246
+
3. Verify your DOCKER_DISPLAY is set correctly for your platform
247
+
</details>
125
248
126
-
If you need to access the container from outside, the container uses host networking mode, so ROS2 topics should be accessible on localhost.
249
+
<details>
250
+
<summary><strong>Problem: <code>libGL error: No matching fbConfigs or visuals found</code></strong></summary>
127
251
128
-
### Manual Launch (Alternative)
252
+
**Solution**: This is just a warning and doesn't prevent the GUI from working. The turtlesim window should still appear.
253
+
</details>
254
+
255
+
## Manual Launch (Alternative)
129
256
130
257
If the automatic launch isn't working or you prefer to launch turtlesim manually, you can run these commands inside the container:
131
258
@@ -134,7 +261,7 @@ If the automatic launch isn't working or you prefer to launch turtlesim manually
134
261
docker exec -it ros2-turtlesim bash
135
262
136
263
# Source ROS2 environment
137
-
source /opt/ros/humble/setup.bash
264
+
source /opt/ros/${ROS_DISTRO}$/setup.bash
138
265
139
266
# Start turtlesim in one terminal
140
267
ros2 run turtlesim turtlesim_node
@@ -143,11 +270,11 @@ ros2 run turtlesim turtlesim_node
143
270
ros2 run turtlesim turtle_teleop_key
144
271
```
145
272
146
-
###Testing Turtlesim
273
+
## Testing Turtlesim
147
274
148
275
If you need to verify that turtlesim is working correctly:
149
276
150
-
####ROS2 Topic Inspection
277
+
### ROS2 Topic Inspection
151
278
152
279
In a separate terminal, you can inspect the ROS2 topics:
153
280
@@ -156,7 +283,7 @@ In a separate terminal, you can inspect the ROS2 topics:
156
283
docker exec -it ros2-turtlesim bash
157
284
158
285
# Source ROS2 environment
159
-
source /opt/ros/humble/setup.bash
286
+
source /opt/ros/${ROS_DISTRO}$/setup.bash
160
287
161
288
# List all topics
162
289
ros2 topic list
@@ -168,7 +295,7 @@ ros2 topic echo /turtle1/pose
168
295
ros2 topic echo /turtle1/cmd_vel
169
296
```
170
297
171
-
####ROS Bridge WebSocket Server
298
+
### ROS Bridge WebSocket Server
172
299
173
300
The rosbridge websocket server is automatically started and available at `ws://localhost:9090`. You can test the connection using a WebSocket client or the MCP server.
1.**Try more complex commands** like drawing shapes or following paths
201
327
2.**Install ROS Locally** to add more nodes and services
202
328
3.**Explore other examples in this repository**
203
329
204
-
205
-
This example provides a foundation for understanding how the MCP server can interact with ROS2 systems, from simple simulators like turtlesim to complex robotic platforms.
330
+
This example provides a foundation for understanding how the MCP server can interact with ROS2 systems, from simple simulators like turtlesim to complex robotic platforms.
0 commit comments