Skip to main content
Glama
ROSClaw UR ROS2 MCP Server

ROSClaw UR ROS2 MCP Server

by ros-claw
README.md
# rosclaw-ur-ros2-mcp

🌐 **English** | [δΈ­ζ–‡](./README.zh.md)

ROSClaw MCP Server for **Universal Robots UR5/UR5e Robotic Arm** via ROS2.

Part of the [ROSClaw](https://github.com/ros-claw) Embodied Intelligence Operating System.

## Overview

This MCP server enables LLM agents to control a UR5/UR5e robotic arm through the Model Context Protocol. It integrates with ROS2 (Robot Operating System 2) and supports MoveIt 2 for motion planning.

```
LLM Agent  ──MCP──►  rosclaw-ur-ros2-mcp  ──ROS2──►  UR5/UR5e
```

## SDK Information

| Property | Value |
|----------|-------|
| **SDK Name** | Universal Robots ROS2 Driver |
| **SDK Version** | 2.4.0+ |
| **Protocol** | ROS2 (Robot Operating System 2) |
| **Source Repository** | [UniversalRobots/Universal_Robots_ROS2_Driver](https://github.com/UniversalRobots/Universal_Robots_ROS2_Driver) |
| **Documentation** | [ROS2 Driver Docs](https://docs.universal-robots.com/Universal_Robots_ROS2_Documentation/doc/ur_robot_driver/ur_robot_driver/doc/index.html) |
| **ROS2 Version** | Humble / Jazzy |
| **License** | Apache-2.0 |
| **Generated** | 2026-04-07 |

## Hardware Specification

| Specification | Value |
|--------------|-------|
| **Robot Model** | Universal Robots UR5 / UR5e |
| **Degrees of Freedom** | 6 |
| **Payload** | 5 kg (UR5) / 5 kg (UR5e) |
| **Reach** | 850 mm |
| **Repeatability** | Β±0.03 mm (UR5e) |
| **Weight** | 20.5 kg (UR5) / 20.5 kg (UR5e) |
| **Footprint** | Ø 149 mm |
| **Joint Range** | Β±360Β° (all joints) |
| **Max Joint Speed** | 3.15 rad/s (base joints), 6.28 rad/s (wrist) |
| **Protocol** | ROS2 Topics & Services |
| **Controller** | UR Control Box (CB3 or e-Series) |

### Joint Configuration

| Joint | Type | Range | Max Speed |
|-------|------|-------|-----------|
| shoulder_pan | Revolute | Β±360Β° | 3.15 rad/s |
| shoulder_lift | Revolute | Β±360Β° | 3.15 rad/s |
| elbow | Revolute | Β±360Β° | 3.15 rad/s |
| wrist_1 | Revolute | Β±360Β° | 6.28 rad/s |
| wrist_2 | Revolute | Β±360Β° | 6.28 rad/s |
| wrist_3 | Revolute | Β±360Β° | 6.28 rad/s |

## Features

- **6-DOF joint control**: Direct joint position commands
- **Cartesian control**: End-effector pose (with MoveIt IK)
- **Gripper control**: Open/close with force control
- **Pick & Place**: High-level pick and place sequences
- **Safety guards**: Joint limits and workspace limits enforced
- **ROS2 integration**: Native rclpy node, subscribes to `/joint_states`
- **Async design**: Background ROS2 spin thread

## Installation

```bash
# Requires ROS2 Humble or Jazzy
source /opt/ros/humble/setup.bash

# Clone
git clone https://github.com/ros-claw/rosclaw-ur-ros2-mcp.git
cd rosclaw-ur-ros2-mcp

# Install with uv (recommended)
uv venv --python /usr/bin/python3.10
source .venv/bin/activate
uv pip install -e .

# Or with pip
pip install -e .
```

### Dependencies

```bash
# Install UR ROS2 driver
sudo apt install ros-humble-ur

# Launch UR5 driver (real robot)
ros2 launch ur_robot_driver ur_control.launch.py \
  ur_type:=ur5 robot_ip:=192.168.1.102

# Or simulation
ros2 launch ur_simulation_gazebo ur_sim_control.launch.py
```

## Quick Start

### Run as MCP Server

```bash
source /opt/ros/humble/setup.bash
python src/ur_mcp_server.py
```

### Claude Desktop Configuration

```json
{
  "mcpServers": {
    "rosclaw-ur": {
      "command": "bash",
      "args": ["-c", "source /opt/ros/humble/setup.bash && python /path/to/rosclaw-ur-ros2-mcp/src/ur_mcp_server.py"],
      "transportType": "stdio",
      "description": "UR5 via ROS2",
      "sdk_version": "2.4.0+",
      "sdk_source": "https://github.com/UniversalRobots/Universal_Robots_ROS2_Driver"
    }
  }
}
```

## Available Tools

| Tool | Description |
|------|-------------|
| `connect_ur5` | Connect to UR5 via ROS2 |
| `disconnect_ur5` | Disconnect from UR5 |
| `move_to_home` | Move to safe home position |
| `move_joint` | Move a single joint |
| `move_joints` | Move multiple joints simultaneously |
| `move_ee_to_pose` | Move end-effector to Cartesian pose |
| `close_gripper` | Close gripper with force control |
| `open_gripper` | Open gripper |
| `pick_object` | Pick object at specified position |
| `place_object` | Place object at specified position |
| `stop_motion` | Stop all robot motion |

## Available Resources

| Resource | Description |
|----------|-------------|
| `ur5://status` | Joint positions, velocities, EE pose |
| `ur5://joints` | Joint limits and velocity limits |
| `ur5://workspace` | Workspace (cylinder) limits |
| `ur5://connection` | ROS2 connection status |
| `ur5://sdk_info` | SDK metadata and version |

## Joint Reference

| Joint | Range | Max Velocity |
|-------|-------|-------------|
| shoulder_pan_joint | Β±360Β° | 3.15 rad/s |
| shoulder_lift_joint | Β±360Β° | 3.15 rad/s |
| elbow_joint | Β±360Β° | 3.15 rad/s |
| wrist_1_joint | Β±360Β° | 6.28 rad/s |
| wrist_2_joint | Β±360Β° | 6.28 rad/s |
| wrist_3_joint | Β±360Β° | 6.28 rad/s |

## Workspace

```
Cylindrical workspace:
  Radius: 0.0 β†’ 0.85 m
  Height: 0.05 β†’ 1.2 m
```

## Home Position

```python
HOME = {
    "shoulder_pan_joint":  0.0,
    "shoulder_lift_joint": -1.57,  # -90Β°
    "elbow_joint":         0.0,
    "wrist_1_joint":       -1.57,
    "wrist_2_joint":       0.0,
    "wrist_3_joint":       0.0,
}
```

## Safety Information

**WARNING:** This MCP server controls a 20+ kg industrial robot arm. Improper use can cause:
- Serious injury or death
- Equipment damage
- Property damage

### Safety Features

| Feature | Description |
|---------|-------------|
| **Joint Limits** | Β±360Β° enforced in software |
| **Velocity Limits** | Base: 3.15 rad/s, Wrist: 6.28 rad/s |
| **Workspace Limits** | Cylinder: 0.85m radius, 0.05-1.2m height |
| **Emergency Stop** | Physical E-stop on pendant and controller |

### Safety Levels

| Level | Color | Description | Example |
|-------|-------|-------------|---------|
| **CRITICAL** | πŸ”΄ | Immediate danger | Collision, excessive force |
| **HIGH** | 🟠 | Potential damage | Near workspace boundary |
| **MEDIUM** | 🟑 | Caution needed | High-speed motion |
| **LOW** | 🟒 | Informational | Normal operation |

### Emergency Procedures

1. **Immediate Stop**: Press physical E-stop button
2. **Power Off**: Disconnect controller power if needed
3. **Reset**: Release E-stop and restart program

## ROS2 Topics

| Topic | Type | Description |
|-------|------|-------------|
| `/joint_states` | sensor_msgs/JointState | Joint positions, velocities, efforts |
| `/tf` | tf2_msgs/TFMessage | Transform tree |
| `/joint_group_position_controller/commands` | std_msgs/Float64MultiArray | Joint commands |

## Error Handling

### Error Codes

| Code | Name | Severity | Description |
|------|------|----------|-------------|
| -1 | CONNECTION_FAILED | 🟠 error | ROS2 node initialization failed |
| -2 | INVALID_JOINT | 🟠 error | Unknown joint name |
| -3 | JOINT_LIMIT | πŸ”΄ critical | Position outside limits |
| -4 | WORKSPACE_VIOLATION | πŸ”΄ critical | Pose outside workspace |
| -5 | SPEED_LIMIT | 🟠 error | Speed exceeds maximum |
| -6 | PROTECTIVE_STOP | πŸ”΄ critical | Robot in protective stop |

### Troubleshooting

| Issue | Possible Cause | Solution |
|-------|---------------|----------|
| Connection failed | ROS2 not running | Start ROS2 daemon |
| Connection failed | Driver not launched | Launch UR ROS2 driver |
| Command rejected | Protective stop | Release E-stop, unlock |
| Command rejected | Joint limit | Check joint position limits |
| Slow response | Network latency | Check Ethernet connection |

## Dependencies

- Python 3.10+
- ROS2 Humble or Jazzy
- `mcp[fastmcp]` β€” MCP framework
- `rclpy` β€” ROS2 Python client library
- `geometry_msgs`, `sensor_msgs`, `std_msgs` β€” ROS2 message types
- `moveit_msgs` β€” MoveIt 2 (for IK planning)

## Architecture

```
ur_mcp_server.py
β”œβ”€β”€ SDK_METADATA      β€” SDK version and source info
β”œβ”€β”€ UR5State          β€” Robot state dataclass
β”œβ”€β”€ UR5ROS2Bridge     β€” ROS2 Node (extends rclpy.Node)
β”‚   β”œβ”€β”€ _joint_state_callback() β€” /joint_states subscriber
β”‚   β”œβ”€β”€ publish_joint_command() β€” /joint_group_position_controller publisher
β”‚   β”œβ”€β”€ _validate_joint_positions() β€” Safety check
β”‚   └── _validate_cartesian_pose() β€” Workspace check
└── MCP Tools         β€” FastMCP tool definitions
```

## References

- [UR ROS2 Driver GitHub](https://github.com/UniversalRobots/Universal_Robots_ROS2_Driver)
- [UR ROS2 Documentation](https://docs.universal-robots.com/Universal_Robots_ROS2_Documentation/)
- [Universal Robots Official](https://www.universal-robots.com/)
- [ROS2 Documentation](https://docs.ros.org/)
- [MCP Protocol](https://modelcontextprotocol.io/)

## License

MIT License β€” See [LICENSE](LICENSE)

The underlying UR ROS2 Driver is licensed under Apache-2.0.

## Part of ROSClaw

- [rosclaw](https://github.com/ros-claw/rosclaw) β€” Core framework (see [arXiv paper](https://arxiv.org/pdf/2604.04664))
- [rosclaw-g1-dds-mcp](https://github.com/ros-claw/rosclaw-g1-dds-mcp) β€” Unitree G1 (DDS)
- [rosclaw-ur-ros2-mcp](https://github.com/ros-claw/rosclaw-ur-ros2-mcp) β€” UR5 arm (ROS2)
- [rosclaw-gimbal-mcp](https://github.com/ros-claw/rosclaw-gimbal-mcp) β€” GCU Gimbal (Serial)
- [rosclaw-ur-rtde-mcp](https://github.com/ros-claw/rosclaw-ur-rtde-mcp) β€” UR5 via RTDE

---

**Generated by ROSClaw SDK-to-MCP Transformer**

*SDK Version: Universal Robots ROS2 Driver 2.4.0+ | Protocol: ROS2*