更新readme

This commit is contained in:
cyy_mac
2026-06-14 23:32:21 +08:00
parent 70ff8986d9
commit d408e08f17

View File

@@ -2,10 +2,30 @@
基于 MotrixSim 的阿克曼小车仿真,支持键盘控制和 HTTP API 局域网共享。 基于 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 ```bash
# macOS
uv run mxpython main.py uv run mxpython main.py
# Linux / Windows
uv run python main.py
``` ```
## HTTP API端口 8765 ## HTTP API端口 8765
@@ -21,11 +41,11 @@ uv run mxpython main.py
http://<仿真机IP>:8765/image http://<仿真机IP>:8765/image
# curl # curl
curl http://192.168.1.100:8765/image -o frame.jpg curl http://1{IP}:8765/image -o frame.jpg
# Python # Python
import requests 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: with open("frame.jpg", "wb") as f:
f.write(r.content) f.write(r.content)
``` ```
@@ -35,7 +55,7 @@ with open("frame.jpg", "wb") as f:
获取小车当前状态JSON 获取小车当前状态JSON
```bash ```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。 获取 IMU 数据(含 MPU6050 噪声JSON。
```bash ```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 发送控制指令JSON
```bash ```bash
curl -X POST http://192.168.1.100:8765/cmd \ curl -X POST http://{IP}:8765/cmd \
-H "Content-Type: application/json" \ -H "Content-Type: application/json" \
-d '{"speed": 1.0, "steer": 0.3}' -d '{"speed": 1.0, "steer": 0.3}'
``` ```