电机控制服务器

一个基于FastMCP框架的ODrive电机控制器控制服务器,提供电机控制、反馈、配置、校准和监控功能。

  • by hkbu-kennycheng
  • Python
  • 本地部署
  • 更新于
在 GitHub 查看 hkbu-kennycheng/odrvie-mcp

使用说明

ODrive MCP 服务器

一个使用FastMCP框架控制ODrive电机控制器的模型上下文协议(MCP)服务器。

特点/功能

  • 电机控制启动/停止电机,设置速度、位置和扭矩设定值
  • 反馈读取电机的位置、速度、电流和温度
  • 配置配置电机参数、增益和安全限制
  • 校准校准电机和编码器
  • 监测实时监测电机状态及错误

安装

pip install -e .

开发环境设置

pip install -e ".[dev]"

项目结构

odrive-mcp/
├── src/
│   ├── __init__.py
│   ├── server.py              # Main MCP server
│   ├── models/
│   │   ├── __init__.py
│   │   └── odrive_models.py   # Data models
│   ├── tools/
│   │   ├── __init__.py
│   │   ├── motor_control.py   # Motor control tools
│   │   ├── calibration.py     # Calibration tools
│   │   └── monitoring.py      # Monitoring tools
│   └── utils/
│       ├── __init__.py
│       └── helpers.py         # Helper utilities
├── tests/
│   ├── __init__.py
│   ├── conftest.py            # Test fixtures
│   ├── test_motor_control.py  # Motor control tests
│   ├── test_calibration.py    # Calibration tests
│   └── test_monitoring.py     # Monitoring tests
├── docs/
│   └── development.md         # Development guide
├── pyproject.toml
├── requirements.txt
└── README.md

测试驱动开发

这个项目遵循TDD(测试驱动开发)原则:

  1. 先写测试在实现之前编写测试
  2. 运行测试验证测试按预期失败
  3. 实现功能编写代码以通过测试
  4. 重构在保持测试通过的同时改进代码

使用以下方式运行测试:

pytest -v --cov=src tests/

使用方法

启动MCP服务器

python -m src.server

连接ODrive

服务器将自动发现并连接到ODrive设备。

文档

许可证

麻省理工学院(MIT)