import 'dart:typed_data'; /// 极简化的 Codec:只负责中间那段变化的“负载数据” class MachineProtocolCodec { /// 仅封装 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 double linear, required double angular, int lift = 0, int mower = 0, int ignition = 0, int emergency = 0, }) { final bd = ByteData(20); // 8 + 8 + 4 字节 int pos = 0; 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); bd.setUint8(pos++, emergency); return bd.buffer.asUint8List(); } }