Compare commits

...

2 Commits

Author SHA1 Message Date
lyq
b00863bc68 优化清扫控制pre 2026-04-03 08:53:02 +08:00
lyq
f19fed282a 远控bug 2026-04-03 08:52:40 +08:00
2 changed files with 24 additions and 27 deletions

View File

@ -45,38 +45,35 @@ void vcuTimerTask(CANDriver& canctl)
canctl.sendFrame(vcu_enable_cmd.toFrame());
// mode: 0=标准模式(刷子), 1=混合模式(刷子+洒水)
bool enable_brush = msg.sweep; // 两种模式都启用刷子
bool enable_water = msg.sweep && (msg.sweep_mode == 1); // 仅混合模式启用洒水
bool enable_brush = true; // 两种模式都启用刷子
// bool enable_water = msg.sweep && (msg.sweep_mode == 1); // 仅混合模式启用洒水
bool enable_water = true;
// ===== 控制0x211报文 (电机M1-M7) =====
vcu_motor1_cmd.setByte0(msg.sweep ? 1 : 0); // 1表示正向运行0表示停止
// 标准模式和混合模式都启用的部件(刷子等)
vcu_motor1_cmd.setByte1(enable_brush ? target_value : 0);
vcu_motor1_cmd.setByte2(enable_brush ? target_value : 0);
vcu_motor1_cmd.setByte3(enable_brush ? target_value : 0);
vcu_motor1_cmd.setByte4(enable_brush ? target_value2 : 100);
vcu_motor1_cmd.setByte5(enable_brush ? target_value2 : 100);
vcu_motor1_cmd.setByte6(enable_brush ? target_value : 0);
vcu_motor1_cmd.setByte7(enable_brush ? target_value : 0);
vcu_motor1_cmd.setByte0(msg.sweep ? 1 : 0); // 电机M1方向 1表示正向运行0表示停止
vcu_motor1_cmd.setByte1(enable_brush ? target_value : 0); //电机M1油门
vcu_motor1_cmd.setByte2(enable_brush ? target_value : 0);//吸尘电机
vcu_motor1_cmd.setByte3(0);//振尘电机
vcu_motor1_cmd.setByte4(enable_brush ? target_value2 : 0);//主刷推杆-100 100
vcu_motor1_cmd.setByte5(enable_brush ? target_value2 : 0);//前挡皮推杆电机-100 100
vcu_motor1_cmd.setByte6(enable_brush ? target_value : 0);//边刷电机
vcu_motor1_cmd.setByte7(enable_brush ? target_value : 0);//边刷电机
canctl.sendFrame(vcu_motor1_cmd.toFrame());
// ===== 控制0x212报文 (电机M8和LED输出) =====
// 注意:这里假设某个字节控制洒水,需要根据实际硬件确认
// 模式1混合模式时启用洒水相关部件
vcu_motor2_cmd.setByte0(enable_brush ? target_value : 0);
vcu_motor2_cmd.setByte1(enable_brush ? target_value : 0);
vcu_motor2_cmd.setByte2(enable_brush ? target_value : 0);
vcu_motor2_cmd.setByte3(enable_brush ? target_value : 0);
vcu_motor2_cmd.setByte4(enable_water ? target_value : 0); // 假设Byte4控制洒水
vcu_motor2_cmd.setByte5(enable_water ? target_value : 0); // 假设Byte5控制洒水
vcu_motor2_cmd.setByte6(enable_brush ? target_value : 0);
vcu_motor2_cmd.setByte7(enable_brush ? target_value : 0);
// ===== 控制0x212报文 (电机M8和预留输出) =====
vcu_motor2_cmd.setByte0(enable_brush ? target_value : 0); //水泵电机 -100 100
vcu_motor2_cmd.setByte1(0);//
vcu_motor2_cmd.setByte2(0);//
vcu_motor2_cmd.setByte3(0);//
vcu_motor2_cmd.setByte4(0); //
vcu_motor2_cmd.setByte5(0); //
vcu_motor2_cmd.setByte6(0);//
vcu_motor2_cmd.setByte7(0);//
canctl.sendFrame(vcu_motor2_cmd.toFrame());
LOG_INFO_THROTTLE(1000, "[VCU] Sweep? %s, Mode: %d (0=标准,1=混合), Water: %s",
LOG_INFO_THROTTLE(1000, "[VCU] Sweep? %s, Mode: %d (0=标准,1=混合), Water: %s | Pump: %d",
msg.sweep ? "Yes" : "No", msg.sweep_mode,
enable_water ? "On" : "Off");
enable_water ? "On" : "Off", enable_water);
}
// 定时器回调BMS 查询任务

View File

@ -214,14 +214,14 @@ class RemoteCtrlNode : public rclcpp::Node
// 未授权时:完全不发
if (!authorized)
{
LOG_WARN_ONCE("[REMOTE] NOT AUTHORIZED - will NOT publish message");
LOG_WARN("[REMOTE] NOT AUTHORIZED - will NOT publish message");
return;
}
// 已授权但超时:完全不发
if (!alive)
{
LOG_WARN_ONCE("[REMOTE] REMOTE ALIVE=FALSE - will NOT publish message");
LOG_WARN("[REMOTE] REMOTE ALIVE=FALSE - will NOT publish message");
return;
}