|
@@ -63,8 +63,10 @@ void LidarScanController::initialize()
|
|
|
|
|
|
|
|
// 创建基站检测状态发布者(使用 transient_local 确保新订阅者能收到最后一条消息)
|
|
// 创建基站检测状态发布者(使用 transient_local 确保新订阅者能收到最后一条消息)
|
|
|
pub_station_detected_ = node_->create_publisher<std_msgs::msg::Bool>(
|
|
pub_station_detected_ = node_->create_publisher<std_msgs::msg::Bool>(
|
|
|
- "station/detected",
|
|
|
|
|
|
|
+ "/station/detected",
|
|
|
rclcpp::QoS(10).transient_local()); // 修改为 transient_local
|
|
rclcpp::QoS(10).transient_local()); // 修改为 transient_local
|
|
|
|
|
+ pub_charging_voltage_ = node_->create_publisher<std_msgs::msg::String>(
|
|
|
|
|
+ "/charging/voltage_detected", 10);
|
|
|
|
|
|
|
|
// 初始化控制消息
|
|
// 初始化控制消息
|
|
|
ctrl_twist_.linear.x = 0.0;
|
|
ctrl_twist_.linear.x = 0.0;
|
|
@@ -466,7 +468,7 @@ void LidarScanController::controlRechargeMotion(const RechargeResult &result)
|
|
|
std::string adjust_type;
|
|
std::string adjust_type;
|
|
|
|
|
|
|
|
const double ANGLE_8DEG = 5.0 * M_PI / 180.0; // 5度阈值
|
|
const double ANGLE_8DEG = 5.0 * M_PI / 180.0; // 5度阈值
|
|
|
- // const double DY_THRESHOLD = 0.05; // 5cm阈值
|
|
|
|
|
|
|
+ // const double DY_THRESHOLD = 0.05; // 5cm阈值
|
|
|
|
|
|
|
|
// 优先调整角度
|
|
// 优先调整角度
|
|
|
if (fabs(yaw_diff) > ANGLE_8DEG)
|
|
if (fabs(yaw_diff) > ANGLE_8DEG)
|
|
@@ -1281,15 +1283,24 @@ void LidarScanController::setChargingVoltage(bool value)
|
|
|
{
|
|
{
|
|
|
detect_charging_voltage_ = value;
|
|
detect_charging_voltage_ = value;
|
|
|
detect_charging_voltage_time_ = node_->now();
|
|
detect_charging_voltage_time_ = node_->now();
|
|
|
|
|
+ auto msg = std_msgs::msg::String();
|
|
|
|
|
+ std::stringstream ss;
|
|
|
|
|
+ ss << (value ? "CHARGING_VOLTAGE_DETECTED" : "CHARGING_VOLTAGE_LOST")
|
|
|
|
|
+ << ":timestamp=" << node_->now().seconds()
|
|
|
|
|
+ << ",voltage_status=" << (value ? "true" : "false");
|
|
|
|
|
|
|
|
if (value)
|
|
if (value)
|
|
|
{
|
|
{
|
|
|
|
|
+ ss << ",message=充电电压已检测到,开始充电流程";
|
|
|
RCLCPP_INFO(node_->get_logger(), "检测到充电电压");
|
|
RCLCPP_INFO(node_->get_logger(), "检测到充电电压");
|
|
|
}
|
|
}
|
|
|
else
|
|
else
|
|
|
{
|
|
{
|
|
|
|
|
+ ss << ",message=充电电压已断开";
|
|
|
RCLCPP_INFO(node_->get_logger(), "充电电压已断开");
|
|
RCLCPP_INFO(node_->get_logger(), "充电电压已断开");
|
|
|
}
|
|
}
|
|
|
|
|
+ msg.data = ss.str();
|
|
|
|
|
+ pub_charging_voltage_->publish(msg);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
bool LidarScanController::getChargingVoltage() const
|
|
bool LidarScanController::getChargingVoltage() const
|