USB 摄像头+远程遥控+中英的适配+topic的集成和状态的使用到相应页面

This commit is contained in:
2026-10-20 17:03:37 +08:00
parent 178cd2533c
commit 582242e9aa
144 changed files with 15759 additions and 406 deletions

View File

@@ -2,22 +2,27 @@ import 'dart:typed_data';
/// 极简化的 Codec:只负责中间那段变化的“负载数据”
class MachineProtocolCodec {
/// 仅封装 0x00 指令的数据部分 (Byte 3 到 Byte 10,共 8 字节)
/// 仅封装 0x00 指令的数据部分(共 20 字节)
///
/// 协议变更(2026-10):左右轮速 short(int16) 改为线速度/角速度 double:
/// - [0..7] linear float64 小端(线速度 m/s)
/// - [8..15] angular float64 小端(角速度 rad/s)
/// - [16] lift / [17] mower / [18] ignition / [19] emergency(不变)
static Uint8List encodeRemoteControlPayload({
required int left,
required int right,
required double linear,
required double angular,
int lift = 0,
int mower = 0,
int ignition = 0,
int emergency = 0,
}) {
final bd = ByteData(8); // 只分配 8 字节
final bd = ByteData(20); // 8 + 8 + 4 字节
int pos = 0;
bd.setInt16(pos, left, Endian.little);
pos += 2;
bd.setInt16(pos, right, Endian.little);
pos += 2;
bd.setFloat64(pos, linear, Endian.little);
pos += 8;
bd.setFloat64(pos, angular, Endian.little);
pos += 8;
bd.setUint8(pos++, lift);
bd.setUint8(pos++, mower);
bd.setUint8(pos++, ignition);