MATLAB-based 7-DOF robot arm visualization with natural language control via file-system queue.
User (Kimi CLI) --Natural Language--> AI generates .m script --File Queue--> MATLAB --Animation--> Figure
- robotagent.m: One-click launcher (file watch + animation engine)
- Arm7R.m: 7-DOF forward/inverse kinematics
- quinticTrajectory.m: Quintic polynomial joint-space trajectory planner
- processIncomingCommands.m: File-queue executor (
timercallback) - Pure MATLAB, no Robotics Toolbox required, no Python bridge, no TCP server
v0.0.5 update: The old intermediate layers
generate_robot_cmd.mandparseNaturalLanguage.mhave been removed. Kimi now generates executable.mscripts directly and drops them intoincoming/.
In MATLAB, navigate to the robot-agent folder and run robotagent.m (double-click or press ▶):
========================================
RobotAgent started.
Figure: RobotAgent - 7R Arm
Watching: D:\...\robot-agent\incoming
========================================
A Figure window pops up showing the 7R arm at zero pose. The MATLAB command line remains free.
Type natural language commands in Kimi CLI, e.g.:
Move end-effector to (500, 0, 800) in 3 seconds
Kimi CLI internally:
- Reads the project skill
skills/robotagent-ops/SKILL.md - Generates a complete
.mscript (trajectory + animation + log output) - Writes it to
robot-agent/incoming/cmd_xxx.m - MATLAB
timerdetects and executes automatically - Kimi reads
logs/log_xxx.txtand reports[Done]/[ERR]/[PAUSE]
| Natural Language | Generated Action |
|---|---|
home / 回到原位 |
Return to zero pose (default 5s) |
move to (500, 0, 800) |
Cartesian PTP move (default 5s) |
joint 1 90 deg / 關節1轉90度 |
Single-joint move (default 5s) |
circle radius 200 / 畫圓 半徑200 |
Circular trajectory around end-effector Z axis |
status / 現在姿態 |
Print current joint angles & EE pose |
| Composite command | Split into multiple cmd_*.m scripts executed in creation order |
Append in X seconds / 用 X 秒 to override the default 5-second duration.
Run all phases at once:
cd('D:\Document\code\Matlab\robot-agent\tests\phases');
addpath('../../src');
run_all_tests;Or run individual phases:
cd('D:\Document\code\Matlab\robot-agent');
addpath('src');
addpath('tests/phases');
test_phase1_figure;
test_phase2_filewatch;
test_phase3_generator;
test_phase4_cleanup;
test_phase5_e2e;
test_phase6_complex;Or run obstacle tests:
addpath('src');
addpath('tests/obstacle');
test_build_robot_tree;
test_obstacle_visualization;
test_obstacle_collision;
test_obstacle_avoidance_move;
test_obstacle_disabled;Or run from PowerShell/CMD:
matlab -batch "cd('D:\Document\code\Matlab\robot-agent\tests\phases'); addpath('../../src'); run_all_tests;"robot-agent/
├── robotagent.m # One-click launcher
├── src/
│ ├── Arm7R.m # 7-DOF kinematics
│ ├── initRobotFigure.m # Figure initialization (with obstacle sphere)
│ ├── updateRobotFigure.m # Figure efficient update
│ ├── animateRobot.m # Animation playback
│ ├── quinticTrajectory.m # Quintic polynomial planner
│ ├── processIncomingCommands.m # File-queue executor
│ ├── buildRobotTree.m # Convert Arm7R DH to rigidBodyTree
│ ├── checkRobotObstacleCollision.m # Robot-to-sphere collision check
│ ├── planTrajectoryWithObstacle.m # RRT-based obstacle avoidance
│ └── computeTrajectory.m # Legacy trajectory helper
├── tests/
│ ├── phases/
│ │ ├── run_all_tests.m # Unified test entry
│ │ ├── test_phase1_figure.m
│ │ ├── test_phase2_filewatch.m
│ │ ├── test_phase3_generator.m
│ │ ├── test_phase4_cleanup.m
│ │ ├── test_phase5_e2e.m
│ │ ├── test_phase6_complex.m
│ │ └── output/ # Test screenshots
│ └── obstacle/
│ ├── test_build_robot_tree.m
│ ├── test_obstacle_visualization.m
│ ├── test_obstacle_collision.m
│ ├── test_obstacle_avoidance_move.m
│ └── test_obstacle_disabled.m
├── skills/
│ └── robotagent-ops/ # Project skill for Kimi CLI
│ ├── SKILL.md
│ └── references/
├── docs/
│ ├── README_Arm7R.md
│ ├── plan_refactor_filewatch.md
│ └── robot_agent_cmds.json
└── README.md # This file
- Added obstacle avoidance module (requires Robotics System Toolbox):
- Red sphere obstacle visualization in
initRobotFigure.m buildRobotTree.mconverts Arm7R DH parameters torigidBodyTreecheckRobotObstacleCollision.mdetects robot-to-sphere collisionsplanTrajectoryWithObstacle.musesmanipulatorRRTto plan collision-free paths- Manual obstacle avoidance switch: set
enable_obstacle_avoidance = true;inrobotagent.mbefore running (requires Robotics System Toolbox)
- Red sphere obstacle visualization in
- Switches
fig.UserData.obstacle_enabledandfig.UserData.obstacle_avoidance_enabled - Reorganized
tests/intotests/phases/andtests/obstacle/ - Added obstacle avoidance script template G in skill references
- Refactored to AI-direct-code mode: removed
generate_robot_cmd.mandparseNaturalLanguage.m - Added unified test entry
tests/run_all_tests.m - Reorganized test phases:
test_phase4_cleanup.mtest_phase5_e2e.m(end-to-end integration)test_phase6_complex.m(composite multi-segment commands)
- Added project skill references for pose adjustment, script templates, and troubleshooting
- Added
incoming_history/to preserve every executed script - Improved logging: every execution writes to
logs/log_*.txtwith[RX],[Done],[ERR], or[PAUSE]markers
- Refactored skill into reference files
- Fixed
processIncomingCommands.mvariable scope bug - Added circle trajectory templates
- Unified logging, pose display
- Composite commands, multi-cmd queue
- Added project skill, updated AGENTS.md
- File-watch architecture, natural language control, quintic trajectory
- MATLAB: R2020b or later (
timerrequired). Tested on R2023b. - Toolbox: None required. Pure base MATLAB.
- Quintic trajectory: All joint motions use quintic polynomial interpolation (zero start/end velocity & acceleration).
- Default duration: 5 seconds when not specified by user.