diff --git a/README.md b/README.md index 4289a71..fbe206b 100644 --- a/README.md +++ b/README.md @@ -2,10 +2,30 @@ 基于 MotrixSim 的阿克曼小车仿真,支持键盘控制和 HTTP API 局域网共享。 +## 依赖 + +| 依赖 | 说明 | 安装 | +|------|------|------| +| Python ≥3.13 | 运行环境 | `brew install python` 或 [python.org](https://python.org) | +| [uv](https://docs.astral.sh/uv/) | 包管理器 | `curl -LsSf https://astral.sh/uv/install.sh \| sh` | +| `motrixsim-core` | 物理仿真引擎 | `uv sync` 自动安装 | +| `pillow` | 摄像头图像转 JPEG | `uv sync` 自动安装 | + +```bash +# 克隆后一键安装 +uv sync +``` + +> `mxpython` 是 motrixsim-core 自带的启动器,**macOS 上必须使用**(主线程需保留给渲染),Linux / Windows 可直接用 `python`。 + ## 启动 ```bash +# macOS uv run mxpython main.py + +# Linux / Windows +uv run python main.py ``` ## HTTP API(端口 8765) @@ -21,11 +41,11 @@ uv run mxpython main.py http://<仿真机IP>:8765/image # curl -curl http://192.168.1.100:8765/image -o frame.jpg +curl http://1{IP}:8765/image -o frame.jpg # Python import requests -r = requests.get("http://192.168.1.100:8765/image") +r = requests.get("http://{IP}:8765/image") with open("frame.jpg", "wb") as f: f.write(r.content) ``` @@ -35,7 +55,7 @@ with open("frame.jpg", "wb") as f: 获取小车当前状态(JSON)。 ```bash -curl http://192.168.1.100:8765/state +curl http://{IP}:8765/state ``` 返回示例: @@ -59,7 +79,7 @@ curl http://192.168.1.100:8765/state 获取 IMU 数据(含 MPU6050 噪声),JSON。 ```bash -curl http://192.168.1.100:8765/imu +curl http://{IP}:8765/imu ``` 返回示例: @@ -81,7 +101,7 @@ curl http://192.168.1.100:8765/imu 发送控制指令(JSON)。 ```bash -curl -X POST http://192.168.1.100:8765/cmd \ +curl -X POST http://{IP}:8765/cmd \ -H "Content-Type: application/json" \ -d '{"speed": 1.0, "steer": 0.3}' ```