Skip to content

Conversation

@itsbharatj
Copy link

Overview

This PR addresses issue #101 and supersedes PR #153 for turtlesim Docker GUI testing.

Changes Made

1. Cross-Platform Launch System

  • Added launch.sh main script that automatically detects the host OS
  • Created platform-specific launch scripts:
    • launch_macos.sh for macOS with XQuartz support
    • launch_linux.sh for native Linux X11 environments
    • launch_windows.sh for Windows using VcXsrv, X410 or other X servers
  • Improved error handling and user feedback throughout the launch process

2. macOS XQuartz Integration

  • Implemented automatic XQuartz startup detection and initialization
  • Fixed X11 authorization issues that caused first-run failures
  • Added proper display detection using hostname -I fallback for IP resolution
  • Removed hard-coded IP addresses and display numbers

3. Documentation Improvements

  • Updated README.md with platform-specific setup instructions
  • Added comprehensive troubleshooting section covering:
    • XQuartz configuration requirements
    • Common X11 connection errors and solutions
    • Docker permissions and display issues
    • Step-by-step debugging guide

4. Error Handling

  • Added validation for required commands (xhost, docker, etc)
  • Improved error messages with actionable troubleshooting steps
  • Added graceful fallbacks for authorization methods

Testing

Thoroughly tested on:

  • macOS with XQuartz
  • Verified container GUI display functionality
  • Tested cold-start scenarios (XQuartz not running)
  • Validated error messages and troubleshooting steps

Resolves

Works on #101
Supersedes #153

itsbharatj and others added 10 commits October 7, 2025 21:47
- Fix macOS XQuartz display issues with dynamic DOCKER_DISPLAY variable
- Add platform-specific setup instructions for macOS, Linux, Windows
- Remove hard-coded IP addresses and display numbers
- Add comprehensive troubleshooting for common X11 connection errors

Resolves Docker GUI display issues on macOS and improves cross-platform compatibility.
mcp_json.txt Outdated
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be removed. It also contains your personal information.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I have removed it

xhost +

# Set DISPLAY for Docker (use your IP from Step 4 + display number)
export DOCKER_DISPLAY="10.1.56.72:1" # Replace with your actual IP
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

<YOUR_IP> instead of a random number

Copy link
Author

@itsbharatj itsbharatj Nov 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This has now been updated


```bash
docker compose up
./launch.sh
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am confused, the entire point of having docker compose up is that it doesn't need external configuration. I am not sure how I feel about having custom launch.sh floating around the repository, but I am no expert.

@rjohn-v?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand your concern @stex2005. However, the launch.sh script addresses host-side X11/GUI configuration, which is separate from the Docker container setup.

The problem:
On macOS (and some Linux systems), docker compose up alone isn't sufficient because:

  1. DISPLAY environment variable - Needs to be dynamically determined (varies by machine/network)
  2. XQuartz permissions - Requires xhost authorization before Docker can connect
  3. XQuartz startup - Must be running and properly configured with "Allow connections from network clients"
  4. IP-based display - macOS requires <IP>:<DISPLAY_PORT>

The script automates these host-side prerequisites before running docker compose up.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure how I feel about encapsulating multiple .sh files instead of the cleaner docker compose up.
Asking for input from others.

stdin_open: true
tty: true
command: bash -c "/ros2_ws/scripts/launch_turtlesim.sh"
command: ["/bin/bash", "/ros2_ws/scripts/launch_turtlesim.sh"]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This has actually been removed, there should be a proper ros2 launch file instead.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The scripts folder doesn't exist anymore, there is only a launch folder:

There is a template launch_rosbridge.launch.py, we can create inside 5_docker_turtlesim another simple launch file based on launch_rosbridge + the turtlesim node

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, let me make that change. Thanks!

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you briefly explain what this does? Does it have to be run at each push? This is just an example: I would trigger it the on workflow_dispatch ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I was using it for internal testing, I had removed it in a recent commit

@stex2005
Copy link
Collaborator

stex2005 commented Nov 4, 2025

@itsbharatj I think we could have kept the CI workflow in the example, but have it triggered only by on_dispatch, does it make sense?

@itsbharatj itsbharatj requested a review from stex2005 November 5, 2025 13:33
@itsbharatj
Copy link
Author

Hey @stex2005, based on your comments, I have pushed the respective changes:

  1. Changed the path in docker-compose.yml from scripts to launch
  2. From the launch_rosbridge.launch.py template, I have created the launch_turtlesim.launch.py which I have tested on my machine

The struggle is that I want to test the turtelsim ui being displayed using the websocket on multiple OS. I am not sure how can I test it using GitHub CI.

Also, please look at my reply for the using a singular launch.sh.

Let me know your thoughts,

Best
Bharat Jain

@itsbharatj itsbharatj changed the title Fix Docker GUI display issues for turtlesim on macOS with XQuartz Cross Platform Docker Launch for example 5 and fix for GUI display issues on macOS with XQuartz Nov 5, 2025
@itsbharatj itsbharatj changed the title Cross Platform Docker Launch for example 5 and fix for GUI display issues on macOS with XQuartz Cross platform docker launch system and fix for GUI display issues on macOS with XQuartz for example 5 Nov 5, 2025
@itsbharatj
Copy link
Author

itsbharatj commented Nov 6, 2025

Hey @stex2005, wanted to follow up and see if you’ve had a chance to go through the recent commits.

Thanks,
Bharat

@stex2005 stex2005 merged commit e578f48 into robotmcp:develop Nov 10, 2025
1 check passed
@itsbharatj
Copy link
Author

@stex2005, thank you for merging the PR.
Because the docker folder was removed, the paths in the run scripts also had to be changed.
I have fixed the following bug in #195.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants