| | |
| | | nextForward = clampSpeed(nextForward); |
| | | byte[] payload = buildSteeringCommandBytes((byte) nextSteering, (byte) nextForward); |
| | | |
| | | // 调试:打印发送的数据 |
| | | System.out.println("发送转向指令: " + bytesToHex(payload)); |
| | | |
| | | boolean success = sendmessage.sendViaActive(payload); |
| | | if (success) { |
| | | currentSteeringSpeed = nextSteering; |
| | |
| | | * 测试函数:验证转向指令构建 |
| | | */ |
| | | public static void testBuildSteeringCommand() { |
| | | System.out.println("=== 测试修正后的转向指令构建 ==="); |
| | | |
| | | // 测试1:直行前进 |
| | | byte[] cmd1 = buildSteeringCommandBytes((byte)0, (byte)50); |
| | | System.out.println("直行前进50: " + bytesToHex(cmd1)); |
| | | |
| | | // 测试2:左转前进 |
| | | byte[] cmd2 = buildSteeringCommandBytes((byte)-30, (byte)40); |
| | | System.out.println("左转前进: " + bytesToHex(cmd2)); |
| | | |
| | | // 测试3:右转后退 |
| | | byte[] cmd3 = buildSteeringCommandBytes((byte)20, (byte)-60); |
| | | System.out.println("右转后退: " + bytesToHex(cmd3)); |
| | | |
| | | // 测试4:停止 |
| | | byte[] cmd4 = buildSteeringCommandBytes((byte)0, (byte)0); |
| | | System.out.println("停止: " + bytesToHex(cmd4)); |
| | | } |
| | | |
| | | } |