Skip to main content
Glama

robot_control

Control physical and virtual robots through a unified interface. Perform actions like movement, status checks, emergency stops, and synchronization between robot types.

Instructions

Unified robot control (works for both physical bot and virtual bot).

This portmanteau tool provides a unified interface for controlling both physical robots (via ROS) and virtual robots (via Unity/VRChat). The tool automatically routes commands to the appropriate handler based on robot type.

Args: robot_id: Robot identifier (e.g., "scout_01", "vbot_scout_01"). action: Operation to perform: - "get_status": Get robot status (battery, position, state) - "move": Control movement (linear/angular velocity) - "stop": Emergency stop - "return_to_dock": Return to charging dock (physical bot only) - "stand": Stand up (Unitree G1, physical bot only) - "sit": Sit down (Unitree G1, physical bot only) - "walk": Walking gait (Unitree, physical bot only) - "sync_vbot": Sync virtual bot with physical bot state linear: Linear velocity (m/s) for move action. angular: Angular velocity (rad/s) for move action. duration: Movement duration (seconds). **kwargs: Additional action-specific parameters.

Returns: Dictionary containing operation result.

Examples: Get robot status: result = await robot_control(robot_id="scout_01", action="get_status")

Move robot forward: result = await robot_control( robot_id="scout_01", action="move", linear=0.2, angular=0.0 ) Stop robot: result = await robot_control(robot_id="scout_01", action="stop")

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
robot_idYes
actionYes
linearNo
angularNo
durationNo

Implementation Reference

  • The core handler function for the 'robot_control' tool. It handles input parameters, retrieves the robot state, routes to physical or virtual robot handlers, and includes error handling.
    @self.mcp.tool() async def robot_control( robot_id: str, action: Literal[ "get_status", "move", "stop", "return_to_dock", "stand", "sit", "walk", "sync_vbot", ], linear: Optional[float] = None, angular: Optional[float] = None, duration: Optional[float] = None, ) -> Dict[str, Any]: """Unified robot control (works for both physical bot and virtual bot). This portmanteau tool provides a unified interface for controlling both physical robots (via ROS) and virtual robots (via Unity/VRChat). The tool automatically routes commands to the appropriate handler based on robot type. Args: robot_id: Robot identifier (e.g., "scout_01", "vbot_scout_01"). action: Operation to perform: - "get_status": Get robot status (battery, position, state) - "move": Control movement (linear/angular velocity) - "stop": Emergency stop - "return_to_dock": Return to charging dock (physical bot only) - "stand": Stand up (Unitree G1, physical bot only) - "sit": Sit down (Unitree G1, physical bot only) - "walk": Walking gait (Unitree, physical bot only) - "sync_vbot": Sync virtual bot with physical bot state linear: Linear velocity (m/s) for move action. angular: Angular velocity (rad/s) for move action. duration: Movement duration (seconds). **kwargs: Additional action-specific parameters. Returns: Dictionary containing operation result. Examples: Get robot status: result = await robot_control(robot_id="scout_01", action="get_status") Move robot forward: result = await robot_control( robot_id="scout_01", action="move", linear=0.2, angular=0.0 ) Stop robot: result = await robot_control(robot_id="scout_01", action="stop") """ try: robot = self.state_manager.get_robot(robot_id) if not robot: return format_error_response( f"Robot {robot_id} not found", error_type="not_found", robot_id=robot_id, action=action, ) # Route to appropriate handler if robot.is_virtual: return await self._handle_virtual_robot(robot, action, linear, angular, duration) else: return await self._handle_physical_robot(robot, action, linear, angular, duration) except Exception as e: return handle_tool_error("robot_control", e, robot_id=robot_id, action=action)
  • Input schema defined by type hints and Literal enum for the action parameter, used by MCP for validation.
    async def robot_control( robot_id: str, action: Literal[ "get_status", "move", "stop", "return_to_dock", "stand", "sit", "walk", "sync_vbot", ], linear: Optional[float] = None, angular: Optional[float] = None, duration: Optional[float] = None, ) -> Dict[str, Any]:
  • Registration of the robot_control tool instance during server initialization by calling its register() method.
    # Register portmanteau tools self.robot_control.register() self.virtual_robotics.register() self.vbot_crud.register()
  • Helper method for handling commands on physical robots (ROS integration placeholder).
    async def _handle_physical_robot( self, robot: Any, action: str, linear: Optional[float], angular: Optional[float], duration: Optional[float], ) -> Dict[str, Any]: """Handle physical robot commands. Args: robot: Robot state. action: Action to perform. linear: Linear velocity. angular: Angular velocity. duration: Movement duration. **kwargs: Additional parameters. Returns: Operation result. """ try: # TODO: Implement ROS bridge integration logger.info("Physical robot command", robot_id=robot.robot_id, action=action) return format_success_response( f"Physical robot {action} command sent (mock - ROS integration pending)", robot_id=robot.robot_id, action=action, data={ "note": "ROS bridge integration not yet implemented", "mock": True, }, ) except Exception as e: return handle_tool_error("_handle_physical_robot", e, robot_id=robot.robot_id, action=action)
  • Helper method for handling virtual robot commands by proxying to mounted MCP servers (avatar-mcp, unity3d-mcp, vrchat-mcp) using Client.call_tool.
    async def _handle_virtual_robot( self, robot: Any, action: str, linear: Optional[float], angular: Optional[float], duration: Optional[float], ) -> Dict[str, Any]: """Handle virtual robot commands. Args: robot: Robot state. action: Action to perform. linear: Linear velocity. angular: Angular velocity. duration: Movement duration. **kwargs: Additional parameters. Returns: Operation result. """ from fastmcp import Client logger.info("Virtual robot command", robot_id=robot.robot_id, action=action, platform=robot.platform) try: if action == "move": if robot.platform == "unity": # Use avatar-mcp or unity3d-mcp for movement async with Client(self.mcp) as client: # Try avatar-mcp first for smooth locomotion try: await client.call_tool( "avatar_movement_walk", avatar_id=robot.robot_id, direction="forward", speed=linear or 0.0, ) if angular: await client.call_tool( "avatar_movement_turn", avatar_id=robot.robot_id, angle=angular, ) return { "status": "success", "message": f"Virtual robot moved via avatar-mcp", "robot_id": robot.robot_id, "action": action, "linear": linear, "angular": angular, } except Exception: # Fallback to Unity direct control await client.call_tool( "unity_execute_method", class_name="RobotController", method_name="Move", parameters={ "robotId": robot.robot_id, "linear": linear or 0.0, "angular": angular or 0.0, }, ) return { "status": "success", "message": f"Virtual robot moved via Unity", "robot_id": robot.robot_id, "action": action, } elif robot.platform == "vrchat": # Use VRChat OSC for movement async with Client(self.mcp) as client: await client.call_tool( "vrchat_send_osc_message", address=f"/robot/{robot.robot_id}/move", args=[linear or 0.0, angular or 0.0], ) return { "status": "success", "message": f"Virtual robot moved via VRChat OSC", "robot_id": robot.robot_id, "action": action, } elif action == "stop": async with Client(self.mcp) as client: if robot.platform == "vrchat": await client.call_tool( "vrchat_send_osc_message", address=f"/robot/{robot.robot_id}/stop", args=[1], ) else: await client.call_tool( "avatar_movement_walk", avatar_id=robot.robot_id, direction="forward", speed=0.0, ) return { "status": "success", "message": f"Virtual robot stopped", "robot_id": robot.robot_id, "action": action, } elif action == "get_status": return { "status": "success", "robot": robot.to_dict(), "action": action, } else: return { "status": "success", "message": f"Virtual robot {action} command sent", "robot_id": robot.robot_id, "action": action, } except Exception as e: return handle_tool_error("_handle_virtual_robot", e, robot_id=robot.robot_id, action=action)

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/sandraschi/robotics-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server