docs: update gimbal protocol and frontend integration specs
This commit is contained in:
+9
-11
@@ -4,7 +4,7 @@
|
||||
|
||||
| 参数 | 值 |
|
||||
|---|---|
|
||||
| 波特率 | 115200 |
|
||||
| 波特率 | 921600 |
|
||||
| 数据位 | 8 |
|
||||
| 停止位 | 1 |
|
||||
| 校验位 | None |
|
||||
@@ -53,30 +53,28 @@ def send_auto_tracking(ser, error_x: float, error_y: float):
|
||||
|
||||
---
|
||||
|
||||
## 2. 手动控制数据帧 0xA6 (11 字节)
|
||||
## 2. 手动控制数据帧 0xA6 (10 字节)
|
||||
|
||||
**用途**: 手动模式下发送角度目标值。
|
||||
**用途**: 手动模式下发送角速度目标值。
|
||||
|
||||
```
|
||||
[SOF:0xA6][zero_force:1][yaw_ref:4][pitch_ref:4][checksum:1]
|
||||
[SOF:0xA6][yaw_velocity:4][pitch_velocity:4][checksum:1]
|
||||
```
|
||||
|
||||
| 偏移 | 长度 | 类型 | 含义 |
|
||||
|---|---|---|---|
|
||||
| 0 | 1 | uint8 | 帧头 0xA6 |
|
||||
| 1 | 1 | uint8 | 零力标志 (0=正常, 1=零力) |
|
||||
| 2 | 4 | float | Yaw 角度参考 (degrees) |
|
||||
| 6 | 4 | float | Pitch 角度参考 (degrees) |
|
||||
| 10 | 1 | uint8 | checksum |
|
||||
| 1 | 4 | float | Yaw 角速度 (degrees/s) |
|
||||
| 5 | 4 | float | Pitch 角速度 (degrees/s) |
|
||||
| 9 | 1 | uint8 | checksum |
|
||||
|
||||
**Python 写入示例**:
|
||||
|
||||
```python
|
||||
def send_manual_control(ser, yaw_deg: float, pitch_deg: float, zero_force: int = 0):
|
||||
def send_manual_control(ser, yaw_deg_per_s: float, pitch_deg_per_s: float):
|
||||
data = bytearray()
|
||||
data.append(0xA6)
|
||||
data.append(0 if zero_force else 0)
|
||||
data.extend(struct.pack('<ff', yaw_deg, pitch_deg))
|
||||
data.extend(struct.pack('<ff', yaw_deg_per_s, pitch_deg_per_s))
|
||||
checksum = sum(data) & 0xFF
|
||||
data.append(checksum)
|
||||
ser.write(data)
|
||||
|
||||
Reference in New Issue
Block a user