| Crates.io | mecha10-nodes-llm-command |
| lib.rs | mecha10-nodes-llm-command |
| version | 0.1.39 |
| created_at | 2025-11-25 02:47:51.368456+00 |
| updated_at | 2026-01-09 17:09:03.337274+00 |
| description | Natural language command parsing via LLM APIs (OpenAI, Claude, Ollama) |
| homepage | |
| repository | https://github.com/mecha-industries/mecha10 |
| max_upload_size | |
| id | 1949107 |
| size | 120,927 |
Natural language command parsing via LLM APIs (OpenAI, Claude, Ollama) with dashboard control.
Copy .env.example to .env and add your API key:
cp .env.example .env
# Edit .env and set: OPENAI_API_KEY=sk-...
Start development mode:
mecha10 dev
Open the dashboard at http://localhost:3000/dashboard/robot-control
Send commands via the AI Command Control panel!
The LLM Command node allows users to control robots using natural language commands. It leverages large language models (LLMs) to parse commands and convert them into structured actions.
The node is configured via configs/*/llm-command.toml (or through mecha10.json):
# LLM Provider Configuration
provider = "openai" # Options: "openai", "claude", "local"
model = "gpt-4o-mini"
temperature = 0.7
max_tokens = 500
vision_enabled = false
# Topic Configuration
[topics]
command_in = "/ai/command"
response_out = "/ai/response"
camera_in = "/robot/sensors/camera/rgb"
nav_goal_out = "/nav/goal"
motor_cmd_out = "/motor/cmd_vel"
behavior_out = "/behavior/execute"
# Behavior Interrupt Configuration
[behavior_interrupt]
enabled = true
mode = "interrupt_with_auto_resume" # Options: "disabled", "interrupt_only", "interrupt_with_auto_resume"
timeout_secs = 30 # Auto-resume timeout (for interrupt_with_auto_resume mode)
await_completion = false
control_topic = "/behavior/control"
When the LLM issues motor or navigation commands, it can automatically interrupt autonomous behaviors:
enabled: Enable/disable behavior interruption (default: true)mode: Interrupt behavior (options below):
"disabled": Never interrupt behavior tree"interrupt_only": Interrupt but don't auto-resume (manual resume required)"interrupt_with_auto_resume": Interrupt and automatically resume after timeouttimeout_secs: Seconds before auto-resume (default: 30)await_completion: Wait for command completion before resuming (not yet implemented)control_topic: Topic for behavior control commands (default: "/behavior/control")Recommended: Use .env file in your project root
Copy .env.example to .env and add your API keys:
# Copy the example file
cp .env.example .env
# Edit .env and add your API key
# .env
OPENAI_API_KEY=sk-...
ANTHROPIC_API_KEY=sk-ant-...
The .env file is automatically loaded by mecha10 dev and passed to all nodes.
Alternative: Set environment variables directly
# For OpenAI
export OPENAI_API_KEY="sk-..."
# For Claude
export ANTHROPIC_API_KEY="sk-ant-..."
# For local Ollama (no key needed)
# Ensure Ollama is running on localhost:11434
/ai/command (CommandMessage): Natural language command from user
{
"text": "move forward",
"timestamp": 1234567890,
"user_id": "optional_user_id"
}
/ai/response (ResponseMessage): LLM response with action feedback
{
"text": "Moving the robot forward",
"timestamp": 1234567890,
"action_taken": true,
"error": null
}
/motor/cmd_vel (MotorCommand): Motor velocity commands
{
"linear": 0.5,
"angular": 0.0,
"timestamp": 1234567890
}
/nav/goal (NavigationGoal): Navigation waypoint goals
{
"x": 5.0,
"y": 3.0,
"theta": 0.0,
"timestamp": 1234567890
}
/behavior/execute (BehaviorCommand): Behavior execution commands
{
"name": "follow_person",
"params": null,
"timestamp": 1234567890
}
"move forward" → {"action": "motor", "linear": 0.5, "angular": 0.0}"turn left" → {"action": "motor", "linear": 0.0, "angular": 0.5}"stop" → {"action": "motor", "linear": 0.0, "angular": 0.0}"go to x:5 y:3" → {"action": "navigate", "goal": {"x": 5.0, "y": 3.0, "theta": 0.0}}"move to the door" → Extracts coordinates and navigates"follow that person" → {"action": "behavior", "name": "follow_person"}"patrol the area" → {"action": "behavior", "name": "patrol"}The node subscribes to /vision/detections from the object-detector node and uses this data to answer vision questions:
"what do you see?" → "I see a person (95% confidence) and a car (87% confidence)""is there a person in front of me?" → "Yes, I detect 1 person with 95% confidence""how many cars?" → "I see 2 cars: car (87% confidence) and car (82% confidence)""describe what's visible" → Natural language description based on detectionsHow it works:
/vision/detectionsBenefits over vision APIs:
The LLM command node intelligently manages the interaction between user commands and autonomous behaviors:
Disabled (mode = "disabled")
Interrupt Only (mode = "interrupt_only")
Interrupt with Auto-Resume (mode = "interrupt_with_auto_resume")
timeout_secs (default: 30s)1. Robot is running "patrol" behavior (autonomous)
2. User says: "stop" via LLM command
→ Behavior tree is interrupted
→ Motor command published: {linear: 0.0, angular: 0.0}
3. Robot stops and remains idle
4. After 30 seconds (timeout):
→ Behavior tree automatically resumes
→ Robot continues patrolling
The system uses enhanced BehaviorControl messages:
{
"action": "interrupt",
"source": "llm-command",
"duration_secs": 30,
"timestamp": 1234567890
}
Actions:
interrupt: Pause behavior tree (from LLM command)resume: Resume behavior tree (manual or auto)enable: Enable behavior tree (from dashboard)disable: Disable behavior tree (from dashboard)The default system prompt guides the LLM to parse commands into structured JSON actions:
You are a helpful robot assistant. Parse user commands and respond with structured actions.
For navigation commands (e.g., "go to the door", "move to coordinates"), extract the goal and respond with JSON:
{"action": "navigate", "goal": {"x": 5.0, "y": 3.0, "theta": 0.0}}
For motor commands (e.g., "move forward", "turn left", "stop"), respond with JSON:
{"action": "motor", "linear": 0.5, "angular": 0.0}
For behavior commands (e.g., "follow that person", "patrol the area"), respond with JSON:
{"action": "behavior", "name": "follow_person"}
For vision queries (e.g., "what do you see?"), describe what's visible in the camera feed.
For general questions, respond conversationally.
You can customize this prompt in the configuration.
The dashboard provides a user-friendly interface for:
Access the dashboard at http://localhost:3000/dashboard/robot-control
┌─────────────────┐
│ Dashboard UI │
│ (Command Input) │
└────────┬────────┘
│ publishes
▼
/ai/command
│
▼
┌──────────────────┐
│ OpenAI Reasoning │
│ Node │
│ │
│ ┌────────────┐ │
│ │ LlmNode │ │
│ │ (mecha10- │ │
│ │ ai-llm) │ │
│ └────────────┘ │
│ │ │
│ Parse JSON │
│ │ │
└─────────┼────────┘
│
┌─────┴─────┬──────────────┬───────────────┐
▼ ▼ ▼ ▼
/motor/cmd_vel /nav/goal /behavior/execute /ai/response
│ │ │ │
▼ ▼ ▼ ▼
┌────────┐ ┌──────────┐ ┌─────────────┐ ┌─────────┐
│ Motor │ │Navigation│ │ Behavior │ │Dashboard│
│ Driver │ │ Stack │ │ Executor │ │ UI │
└────────┘ └──────────┘ └─────────────┘ └─────────┘
The node is launched automatically by mecha10 dev when included in mecha10.json.
To run manually:
cargo run -p mecha10-nodes-llm-command
Test the node with simulation:
Start control plane and simulation:
docker compose up -d
mecha10 dev
Send a test command via dashboard or Redis CLI:
redis-cli PUBLISH "/ai/command" '{"text":"move forward","timestamp":1234567890}'
Subscribe to response topic:
redis-cli SUBSCRIBE "/ai/response"
redis-cli SUBSCRIBE "/motor/cmd_vel"
MIT