refactor: manual mode from absolute setpoint to velocity control, remove auto-enable at motor init

Manual mode now receives angular velocity (degrees/s) via 0xA6 frame instead of
absolute angle reference. The firmware integrates velocity * dt into gimbal angle ref.
Motors are no longer auto-enabled at DMMotorInit — they stay disabled until a mode
switch out of DEBUG. Extract ROBOT_CMD_DELAY macro to replace magic number.
Fix "volity" typo → "velocity" and update docs/protocol comments accordingly.
This commit is contained in:
2026-06-02 16:27:07 +08:00
parent 88702e2832
commit da6acdcc89
8 changed files with 30 additions and 30 deletions
+6 -6
View File
@@ -55,28 +55,28 @@ def send_auto_tracking(ser, error_x: float, error_y: float):
## 2. 手动控制数据帧 0xA6 (11 字节)
**用途**: 手动模式下发送角度目标值。
**用途**: 手动模式下发送角速度目标值。
```
[SOF:0xA6][zero_force:1][yaw_ref:4][pitch_ref:4][checksum:1]
[SOF:0xA6][zero_force:1][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) |
| 2 | 4 | float | Yaw 角速度 (degrees/s) |
| 6 | 4 | float | Pitch 角速度 (degrees/s) |
| 10 | 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, zero_force: int = 0):
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)