修改滚刷推杆不下沉的bug
This commit is contained in:
parent
0195ddb3f8
commit
cf5a698eb9
@ -293,43 +293,43 @@ struct can_VCU_motor1_cmd
|
|||||||
// 设置Byte1
|
// 设置Byte1
|
||||||
void setByte1(int8_t value)
|
void setByte1(int8_t value)
|
||||||
{
|
{
|
||||||
data[1] = std::clamp(value, static_cast<int8_t>(0), static_cast<int8_t>(100));
|
data[1] = std::clamp(value, static_cast<int8_t>(-100), static_cast<int8_t>(100));
|
||||||
}
|
}
|
||||||
|
|
||||||
// 设置Byte2
|
// 设置Byte2
|
||||||
void setByte2(int8_t value)
|
void setByte2(int8_t value)
|
||||||
{
|
{
|
||||||
data[2] = std::clamp(value, static_cast<int8_t>(0), static_cast<int8_t>(100));
|
data[2] = std::clamp(value, static_cast<int8_t>(-100), static_cast<int8_t>(100));
|
||||||
}
|
}
|
||||||
|
|
||||||
// 设置Byte3
|
// 设置Byte3
|
||||||
void setByte3(int8_t value)
|
void setByte3(int8_t value)
|
||||||
{
|
{
|
||||||
data[3] = std::clamp(value, static_cast<int8_t>(0), static_cast<int8_t>(100));
|
data[3] = std::clamp(value, static_cast<int8_t>(-100), static_cast<int8_t>(100));
|
||||||
}
|
}
|
||||||
|
|
||||||
// 设置Byte4
|
// 设置Byte4
|
||||||
void setByte4(int8_t value)
|
void setByte4(int8_t value)
|
||||||
{
|
{
|
||||||
data[4] = std::clamp(value, static_cast<int8_t>(0), static_cast<int8_t>(100));
|
data[4] = std::clamp(value, static_cast<int8_t>(-100), static_cast<int8_t>(100));
|
||||||
}
|
}
|
||||||
|
|
||||||
// 设置Byte5
|
// 设置Byte5
|
||||||
void setByte5(int8_t value)
|
void setByte5(int8_t value)
|
||||||
{
|
{
|
||||||
data[5] = std::clamp(value, static_cast<int8_t>(0), static_cast<int8_t>(100));
|
data[5] = std::clamp(value, static_cast<int8_t>(-100), static_cast<int8_t>(100));
|
||||||
}
|
}
|
||||||
|
|
||||||
// 设置Byte6
|
// 设置Byte6
|
||||||
void setByte6(int8_t value)
|
void setByte6(int8_t value)
|
||||||
{
|
{
|
||||||
data[6] = std::clamp(value, static_cast<int8_t>(0), static_cast<int8_t>(100));
|
data[6] = std::clamp(value, static_cast<int8_t>(-100), static_cast<int8_t>(100));
|
||||||
}
|
}
|
||||||
|
|
||||||
// 设置Byte7
|
// 设置Byte7
|
||||||
void setByte7(int8_t value)
|
void setByte7(int8_t value)
|
||||||
{
|
{
|
||||||
data[7] = std::clamp(value, static_cast<int8_t>(0), static_cast<int8_t>(100));
|
data[7] = std::clamp(value, static_cast<int8_t>(-100), static_cast<int8_t>(100));
|
||||||
}
|
}
|
||||||
|
|
||||||
CANFrame toFrame() const
|
CANFrame toFrame() const
|
||||||
@ -356,49 +356,49 @@ struct can_VCU_motor2_cmd
|
|||||||
// 设置Byte0
|
// 设置Byte0
|
||||||
void setByte0(int8_t value)
|
void setByte0(int8_t value)
|
||||||
{
|
{
|
||||||
data[0] = std::clamp(value, static_cast<int8_t>(0), static_cast<int8_t>(100));
|
data[0] = std::clamp(value, static_cast<int8_t>(-100), static_cast<int8_t>(100));
|
||||||
}
|
}
|
||||||
|
|
||||||
// 设置Byte1
|
// 设置Byte1
|
||||||
void setByte1(int8_t value)
|
void setByte1(int8_t value)
|
||||||
{
|
{
|
||||||
data[1] = std::clamp(value, static_cast<int8_t>(0), static_cast<int8_t>(100));
|
data[1] = std::clamp(value, static_cast<int8_t>(-100), static_cast<int8_t>(100));
|
||||||
}
|
}
|
||||||
|
|
||||||
// 设置Byte2
|
// 设置Byte2
|
||||||
void setByte2(int8_t value)
|
void setByte2(int8_t value)
|
||||||
{
|
{
|
||||||
data[2] = std::clamp(value, static_cast<int8_t>(0), static_cast<int8_t>(100));
|
data[2] = std::clamp(value, static_cast<int8_t>(-100), static_cast<int8_t>(100));
|
||||||
}
|
}
|
||||||
|
|
||||||
// 设置Byte3
|
// 设置Byte3
|
||||||
void setByte3(int8_t value)
|
void setByte3(int8_t value)
|
||||||
{
|
{
|
||||||
data[3] = std::clamp(value, static_cast<int8_t>(0), static_cast<int8_t>(100));
|
data[3] = std::clamp(value, static_cast<int8_t>(-100), static_cast<int8_t>(100));
|
||||||
}
|
}
|
||||||
|
|
||||||
// 设置Byte4
|
// 设置Byte4
|
||||||
void setByte4(int8_t value)
|
void setByte4(int8_t value)
|
||||||
{
|
{
|
||||||
data[4] = std::clamp(value, static_cast<int8_t>(0), static_cast<int8_t>(100));
|
data[4] = std::clamp(value, static_cast<int8_t>(-100), static_cast<int8_t>(100));
|
||||||
}
|
}
|
||||||
|
|
||||||
// 设置Byte5
|
// 设置Byte5
|
||||||
void setByte5(int8_t value)
|
void setByte5(int8_t value)
|
||||||
{
|
{
|
||||||
data[5] = std::clamp(value, static_cast<int8_t>(0), static_cast<int8_t>(100));
|
data[5] = std::clamp(value, static_cast<int8_t>(-100), static_cast<int8_t>(100));
|
||||||
}
|
}
|
||||||
|
|
||||||
// 设置Byte6
|
// 设置Byte6
|
||||||
void setByte6(int8_t value)
|
void setByte6(int8_t value)
|
||||||
{
|
{
|
||||||
data[6] = std::clamp(value, static_cast<int8_t>(0), static_cast<int8_t>(100));
|
data[6] = std::clamp(value, static_cast<int8_t>(-100), static_cast<int8_t>(100));
|
||||||
}
|
}
|
||||||
|
|
||||||
// 设置Byte7
|
// 设置Byte7
|
||||||
void setByte7(int8_t value)
|
void setByte7(int8_t value)
|
||||||
{
|
{
|
||||||
data[7] = std::clamp(value, static_cast<int8_t>(0), static_cast<int8_t>(100));
|
data[7] = std::clamp(value, static_cast<int8_t>(-100), static_cast<int8_t>(100));
|
||||||
}
|
}
|
||||||
|
|
||||||
CANFrame toFrame() const
|
CANFrame toFrame() const
|
||||||
|
|||||||
@ -55,15 +55,16 @@ void vcuTimerTask(CANDriver &canctl)
|
|||||||
if (sweep_state_changed)
|
if (sweep_state_changed)
|
||||||
{
|
{
|
||||||
// 根据清扫状态设置所有部件
|
// 根据清扫状态设置所有部件
|
||||||
uint8_t target_value = msg.sweep ? 100 : 0; // 100表示启动,0表示停止
|
int8_t target_value = msg.sweep ? 100 : 0; // 100表示启动,0表示停止
|
||||||
|
int8_t target_value2 = msg.sweep ? -100 : 100; // -100表示下沉,100表示抬升
|
||||||
|
|
||||||
// ===== 控制0x211报文 (电机M1-M7) =====
|
// ===== 控制0x211报文 (电机M1-M7) =====
|
||||||
vcu_motor1_cmd.setByte0(msg.sweep ? 1 : 0); // 1表示正向运行,0表示停止
|
vcu_motor1_cmd.setByte0(msg.sweep ? 1 : 0); // 1表示正向运行,0表示停止
|
||||||
vcu_motor1_cmd.setByte1(target_value);
|
vcu_motor1_cmd.setByte1(target_value);
|
||||||
vcu_motor1_cmd.setByte2(target_value);
|
vcu_motor1_cmd.setByte2(target_value);
|
||||||
vcu_motor1_cmd.setByte3(target_value);
|
vcu_motor1_cmd.setByte3(target_value);
|
||||||
vcu_motor1_cmd.setByte4(target_value);
|
vcu_motor1_cmd.setByte4(target_value2);
|
||||||
vcu_motor1_cmd.setByte5(target_value);
|
vcu_motor1_cmd.setByte5(target_value2);
|
||||||
vcu_motor1_cmd.setByte6(target_value);
|
vcu_motor1_cmd.setByte6(target_value);
|
||||||
vcu_motor1_cmd.setByte7(target_value);
|
vcu_motor1_cmd.setByte7(target_value);
|
||||||
canctl.sendFrame(vcu_motor1_cmd.toFrame());
|
canctl.sendFrame(vcu_motor1_cmd.toFrame());
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user