-
Notifications
You must be signed in to change notification settings - Fork 138
Add ROS 2 Launch System + Documentation #138
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 2 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
2e77d02
Created ROS2 launch files for rosbridge and turtlesim demo, removed m…
stex2005 f7a0368
ruff format
stex2005 8b798fa
Modified documentation + modified launch file to be a template
stex2005 f0f5db7
Improved launch_mcp_tunnel to include default options for port and do…
stex2005 6f5a7df
Minor refactor for launch system
stex2005 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,81 @@ | ||
| # ROS2 Launch System | ||
|
|
||
| ## Overview | ||
|
|
||
| The ROS-MCP Server uses proper ROS2 launch files for process management. | ||
|
|
||
| ## Available Launch Files | ||
|
|
||
| ### `ros_mcp_rosbridge.launch.py` | ||
| **Purpose**: Launch only Rosbridge WebSocket server | ||
| **Use Case**: External robots, custom setups, testing | ||
|
|
||
| ```bash | ||
| # Basic usage | ||
| ros2 launch ros_mcp_rosbridge.launch.py | ||
|
|
||
| # Custom port | ||
| ros2 launch ros_mcp_rosbridge.launch.py port:=9091 | ||
|
|
||
| # Specific address | ||
| ros2 launch ros_mcp_rosbridge.launch.py address:=127.0.0.1 | ||
| ``` | ||
|
|
||
| ## Benefits | ||
|
|
||
| - ✅ **Proper process management** - Automatic cleanup on shutdown | ||
| - ✅ **Configuration options** - Parameter passing and validation | ||
| - ✅ **ROS2 integration** - Works with `ros2 launch` command | ||
| - ✅ **Logging control** - Configurable log levels | ||
| - ✅ **Signal handling** - Proper SIGINT/SIGTERM handling | ||
|
|
||
| ## Common Arguments | ||
|
|
||
| | Argument | Default | Description | | ||
| |----------|---------|-------------| | ||
| | `port` | 9090 | WebSocket server port | | ||
| | `address` | "" | Bind address (empty = all interfaces) | | ||
| | `log_level` | info | Log level (debug, info, warn, error) | | ||
|
|
||
| ## Examples | ||
|
|
||
| ### External Robot Connection | ||
| ```bash | ||
| # Start rosbridge for external robot | ||
| ros2 launch ros_mcp_server ros_mcp_rosbridge.launch.py port:=9090 | ||
|
|
||
| # Connect MCP server to robot IP | ||
| # (Configure in MCP client settings) | ||
| ``` | ||
|
|
||
| ### Debug Mode | ||
| ```bash | ||
| # Enable debug logging | ||
| ros2 launch ros_mcp_server ros_mcp_rosbridge.launch.py log_level:=debug | ||
| ``` | ||
|
|
||
| ## Troubleshooting | ||
|
|
||
| ### Port Already in Use | ||
| ```bash | ||
| # Check port usage | ||
| netstat -tulpn | grep :9090 | ||
|
|
||
| # Use different port | ||
| ros2 launch ros_mcp_server ros_mcp_rosbridge.launch.py port:=9091 | ||
| ``` | ||
|
|
||
| ### Missing Dependencies | ||
| ```bash | ||
| # Install required packages | ||
| sudo apt install ros-jazzy-rosbridge-server | ||
| ``` | ||
|
|
||
| ### Check Node Status | ||
| ```bash | ||
| # List running nodes | ||
| ros2 node list | ||
|
|
||
| # Check topics | ||
| ros2 topic list | ||
| ``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,86 @@ | ||
| #!/usr/bin/env python3 | ||
|
|
||
| """ | ||
| ROS2 Launch file for ROS-MCP Server | ||
| Replaces the functionality of scripts/launch_ros.sh with proper ROS2 launch system. | ||
|
|
||
| This launch file starts: | ||
| - rosbridge_websocket server | ||
| - turtlesim node | ||
| - Provides proper process management and cleanup | ||
| """ | ||
|
|
||
| from launch.actions import DeclareLaunchArgument, LogInfo | ||
| from launch.substitutions import LaunchConfiguration | ||
| from launch_ros.actions import Node | ||
|
|
||
| from launch import LaunchDescription | ||
|
|
||
|
|
||
| def generate_launch_description(): | ||
| """Generate the launch description for ROS-MCP Server.""" | ||
|
|
||
| # Declare launch arguments | ||
| rosbridge_port_arg = DeclareLaunchArgument( | ||
| "port", default_value="9090", description="Port for rosbridge websocket server" | ||
| ) | ||
|
|
||
| rosbridge_address_arg = DeclareLaunchArgument( | ||
| "address", | ||
| default_value="", | ||
| description="Address for rosbridge websocket server (empty for all interfaces)", | ||
| ) | ||
|
|
||
| turtlesim_name_arg = DeclareLaunchArgument( | ||
| "turtlesim_name", default_value="turtlesim", description="Name for the turtlesim node" | ||
| ) | ||
|
|
||
| # Rosbridge websocket server node | ||
| rosbridge_node = Node( | ||
| package="rosbridge_server", | ||
| executable="rosbridge_websocket", | ||
| name="rosbridge_websocket", | ||
| output="screen", | ||
| parameters=[ | ||
| { | ||
| "port": LaunchConfiguration("port"), | ||
| "address": LaunchConfiguration("address"), | ||
| "use_compression": False, | ||
| "max_message_size": 10000000, | ||
| "send_action_goals_in_new_thread": True, | ||
| "call_services_in_new_thread": True, | ||
| } | ||
| ], | ||
| arguments=["--ros-args", "--log-level", "info"], | ||
| ) | ||
|
|
||
| # Turtlesim node | ||
| turtlesim_node = Node( | ||
| package="turtlesim", | ||
| executable="turtlesim_node", | ||
| name=LaunchConfiguration("turtlesim_name"), | ||
| output="screen", | ||
| arguments=["--ros-args", "--log-level", "info"], | ||
| ) | ||
|
|
||
| # Log info about what's being launched | ||
| log_info = LogInfo( | ||
| msg=[ | ||
| "Starting ROS-MCP Server with:", | ||
| " - Rosbridge WebSocket on port: ", | ||
| LaunchConfiguration("port"), | ||
| " - Turtlesim node: ", | ||
| LaunchConfiguration("turtlesim_name"), | ||
| ] | ||
| ) | ||
|
|
||
| return LaunchDescription( | ||
| [ | ||
| rosbridge_port_arg, | ||
| rosbridge_address_arg, | ||
| turtlesim_name_arg, | ||
| log_info, | ||
| rosbridge_node, | ||
| turtlesim_node, | ||
| ] | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,76 @@ | ||
| #!/usr/bin/env python3 | ||
|
|
||
| """ | ||
| ROS2 Launch file for Rosbridge WebSocket Server only | ||
| Launches only the rosbridge server without turtlesim. | ||
|
|
||
| Use this when you want to connect to an external robot or simulation. | ||
| """ | ||
|
|
||
| from launch.actions import DeclareLaunchArgument, LogInfo | ||
| from launch.substitutions import LaunchConfiguration | ||
| from launch_ros.actions import Node | ||
|
|
||
| from launch import LaunchDescription | ||
|
|
||
|
|
||
| def generate_launch_description(): | ||
| """Generate the launch description for rosbridge only.""" | ||
|
|
||
| # Declare launch arguments | ||
| port_arg = DeclareLaunchArgument( | ||
| "port", default_value="9090", description="Port for rosbridge websocket server" | ||
| ) | ||
|
|
||
| address_arg = DeclareLaunchArgument( | ||
| "address", | ||
| default_value="", | ||
| description="Address for rosbridge websocket server (empty for all interfaces)", | ||
| ) | ||
|
|
||
| log_level_arg = DeclareLaunchArgument( | ||
| "log_level", default_value="info", description="Log level for rosbridge server" | ||
| ) | ||
|
|
||
| # Rosbridge websocket server node | ||
| rosbridge_node = Node( | ||
| package="rosbridge_server", | ||
| executable="rosbridge_websocket", | ||
| name="rosbridge_websocket", | ||
| output="screen", | ||
| parameters=[ | ||
| { | ||
| "port": LaunchConfiguration("port"), | ||
| "address": LaunchConfiguration("address"), | ||
| "use_compression": False, | ||
| "max_message_size": 10000000, | ||
| "send_action_goals_in_new_thread": True, | ||
| "call_services_in_new_thread": True, | ||
| "default_call_service_timeout": 5.0, | ||
| } | ||
| ], | ||
| arguments=["--ros-args", "--log-level", LaunchConfiguration("log_level")], | ||
| ) | ||
|
|
||
| # Log info | ||
| log_info = LogInfo( | ||
| msg=[ | ||
| "Starting Rosbridge WebSocket Server:", | ||
| " - Port: ", | ||
| LaunchConfiguration("port"), | ||
| " - Address: ", | ||
| LaunchConfiguration("address"), | ||
| " - Log level: ", | ||
| LaunchConfiguration("log_level"), | ||
| ] | ||
| ) | ||
|
|
||
| return LaunchDescription( | ||
| [ | ||
| port_arg, | ||
| address_arg, | ||
| log_level_arg, | ||
| log_info, | ||
| rosbridge_node, | ||
| ] | ||
| ) |
This file was deleted.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the intended audience for this instruction file?
Specifically the line "The ROS-MCP Server uses proper ROS2 launch files for process management." is a bit confusing since the ROS-MCP server does not explicitly need to use any launch files at all.
They are useful tools in the examples and tutorials, and having good, modern launch files for these is valuable. But do we need a document telling users of the MCP server about why we chose certain launch systems for the examples?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a guide that provides template launch files for developers to integrate their robots with the ROS-MCP Server. These templates demonstrate how to combine your robot's existing launch files with rosbridge for MCP communication.
Future Vision: As rosbridge becomes a standard ROS node, the ROS-MCP Server itself will be launchable through ROS2 launch files, making integration even more seamless.