From 7924773826f38422860feb1de44040ce467778fe Mon Sep 17 00:00:00 2001 From: root Date: Sat, 17 May 2025 15:39:50 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E9=81=A5=E6=8E=A7=E4=B8=80?= =?UTF-8?q?=E9=94=AE=E6=B8=85=E6=89=AB=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/mqtt_report/src/mqtt_report.cpp | 5 +++-- src/radio_ctrl/src/radio_ctrl.cpp | 34 +++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 2 deletions(-) diff --git a/src/mqtt_report/src/mqtt_report.cpp b/src/mqtt_report/src/mqtt_report.cpp index 5e5d8eb..9e9783a 100644 --- a/src/mqtt_report/src/mqtt_report.cpp +++ b/src/mqtt_report/src/mqtt_report.cpp @@ -4,6 +4,7 @@ #include "mqtt_report/get_config.h" #include "mqtt_report/report_struct.h" #include "mqtt_report/fault_codes.h" +#include Config config; // 清扫车配置文件 @@ -37,7 +38,6 @@ void Msg_Handler(const mc::msg::CanFrame::SharedPtr msg) float gear_ratio = 32.0; float wheel_radius = 0.15; // 轮胎半径,单位米 float vehicle_speed_kmh = (2 * 3.1416 * wheel_radius * (motorspeed / gear_ratio) * 60.0) / 1000.0; - info_report.speed = vehicle_speed_kmh; break; } @@ -48,6 +48,7 @@ void Msg_Handler(const mc::msg::CanFrame::SharedPtr msg) uint8_t WaterValue_l = (msg->data[1]); uint16_t WaterValue = (WaterValue_h & 0x3f) * 16 + (WaterValue_l & 0x0f); float WaterLevel = WaterValue * (-0.235) + 199.75; + WaterLevel = std::clamp(WaterLevel, 0.0f, 180.0f); info_report.waterLevel = static_cast(std::round(WaterLevel / 1.8f)); // 液位百分比 break; } @@ -221,7 +222,7 @@ public: private: 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); } diff --git a/src/radio_ctrl/src/radio_ctrl.cpp b/src/radio_ctrl/src/radio_ctrl.cpp index 46b0caf..d64148f 100644 --- a/src/radio_ctrl/src/radio_ctrl.cpp +++ b/src/radio_ctrl/src/radio_ctrl.cpp @@ -107,6 +107,32 @@ private: msg.rpm = static_cast(MCU_RPM_MAX * (1016 - ch_data[1]) / (1016 - 216)); } + // 一键清扫 + if (ch_data[6] == 1792) + { + msg.main_brush_lift = false; + msg.edge_brush_lift = false; + msg.vacuum = false; + msg.spray = false; + msg.mud_flap = false; + msg.dust_shake = false; + msg.main_brush_spin = false; + msg.edge_brush_spin = false; + } + else if (ch_data[6] == 192) + { + msg.main_brush_lift = true; + msg.edge_brush_lift = true; + msg.vacuum = true; + msg.spray = true; + msg.mud_flap = true; + msg.dust_shake = true; + msg.main_brush_spin = true; + msg.edge_brush_spin = true; + msg.main_brush_pwm = 100; + msg.edge_brush_pwm = 100; + } + // 转向逻辑 float target_angle = (static_cast(ch_data[3]) - 800) / 800 * EPS_ANGLE_MAX; @@ -135,6 +161,14 @@ private: msg.brake_time_ms = 500; msg.angle = 0; msg.angle_speed = 120; + msg.main_brush_lift = false; + msg.edge_brush_lift = false; + msg.vacuum = false; + msg.spray = false; + msg.mud_flap = false; + msg.dust_shake = false; + msg.main_brush_spin = false; + msg.edge_brush_spin = false; } if (data_safe)