修改液位的计算逻辑
This commit is contained in:
parent
352e6eef45
commit
8dd991b677
@ -44,7 +44,9 @@ void Msg_Handler(const mc::msg::CanFrame::SharedPtr msg)
|
|||||||
|
|
||||||
case 0x18FF0121:
|
case 0x18FF0121:
|
||||||
{
|
{
|
||||||
const uint16_t WaterValue = (uint16_t)(((msg->data[3] & 0x3F) << 4) | ((msg->data[2] & 0xF0) >> 4));
|
uint8_t WaterValue_h = (msg->data[2]);
|
||||||
|
uint8_t WaterValue_l = (msg->data[1]);
|
||||||
|
uint16_t WaterValue = (WaterValue_h & 0x3f) * 16 + (WaterValue_l & 0x0f);
|
||||||
float WaterLevel = WaterValue * (-0.235) + 199.75;
|
float WaterLevel = WaterValue * (-0.235) + 199.75;
|
||||||
info_report.waterLevel = static_cast<int>(std::round(WaterLevel / 1.8f)); // 液位百分比
|
info_report.waterLevel = static_cast<int>(std::round(WaterLevel / 1.8f)); // 液位百分比
|
||||||
break;
|
break;
|
||||||
@ -219,7 +221,7 @@ public:
|
|||||||
private:
|
private:
|
||||||
void topic_callback(const mc::msg::CanFrame::SharedPtr msg)
|
void topic_callback(const mc::msg::CanFrame::SharedPtr msg)
|
||||||
{
|
{
|
||||||
RCLCPP_INFO(this->get_logger(), "Received CAN frame ID: %u, DLC: %u", msg->id, msg->dlc);
|
// RCLCPP_INFO(this->get_logger(), "Received CAN frame ID: %u, DLC: %u", msg->id, msg->dlc);
|
||||||
Msg_Handler(msg);
|
Msg_Handler(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user