|
|
@@ -69,7 +69,6 @@ void LidarScanController::initialize()
|
|
|
"/charging/voltage_detected", 10);
|
|
|
pub1_=node_->create_publisher<std_msgs::msg::Int32>("/vlago/recharge/status1",10);
|
|
|
pub2_=node_->create_publisher<std_msgs::msg::Int32>("/vlago/recharge/feedback",10);
|
|
|
-
|
|
|
// 初始化控制消息
|
|
|
ctrl_twist_.linear.x = 0.0;
|
|
|
ctrl_twist_.angular.z = 0.0;
|
|
|
@@ -407,6 +406,7 @@ void LidarScanController::procData(RechargeResult &result)
|
|
|
|
|
|
void LidarScanController::controlRechargeMotion(const RechargeResult &result)
|
|
|
{
|
|
|
+ if (!active_) return;
|
|
|
publishStationDetected(true);
|
|
|
bool in_rotation_delay = node_->get_parameter("in_rotation_delay").as_bool();
|
|
|
if (in_rotation_delay)
|
|
|
@@ -432,6 +432,7 @@ void LidarScanController::controlRechargeMotion(const RechargeResult &result)
|
|
|
ctrl_twist_.linear.x = 0.0;
|
|
|
ctrl_twist_.angular.z = 0.0;
|
|
|
ctrl_twist_time_ = node_->now();
|
|
|
+ stopNavigation();
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
@@ -506,7 +507,7 @@ void LidarScanController::controlRechargeMotion(const RechargeResult &result)
|
|
|
rclcpp::Time adjust_start = node_->now();
|
|
|
int publish_count = 0;
|
|
|
|
|
|
- while ((node_->now() - adjust_start).seconds() < adjust_duration)
|
|
|
+ while (rclcpp::ok() && active_ &&(node_->now() - adjust_start).seconds() < adjust_duration)
|
|
|
{
|
|
|
pub_ctrl_->publish(adjust_cmd);
|
|
|
publish_count++;
|
|
|
@@ -540,7 +541,7 @@ void LidarScanController::controlRechargeMotion(const RechargeResult &result)
|
|
|
rclcpp::Time forward_start = node_->now();
|
|
|
int forward_count = 0;
|
|
|
|
|
|
- while ((node_->now() - forward_start).seconds() < forward_duration)
|
|
|
+ while (rclcpp::ok() && active_ &&(node_->now() - forward_start).seconds() < forward_duration)
|
|
|
{
|
|
|
pub_ctrl_->publish(forward_cmd);
|
|
|
forward_count++;
|
|
|
@@ -648,6 +649,7 @@ void LidarScanController::controlRechargeMotion(const RechargeResult &result)
|
|
|
auto msg =std_msgs::msg::Int32();
|
|
|
msg.data=RECHARGE_FEEDBACK_SUCCESS_DOCKED;
|
|
|
pub2_->publish(msg);
|
|
|
+ stopNavigation();
|
|
|
|
|
|
// 模拟检测到充电电压
|
|
|
setChargingVoltage(true);
|
|
|
@@ -1317,9 +1319,10 @@ bool LidarScanController::getChargingVoltage() const
|
|
|
auto diff = now - detect_charging_voltage_time_;
|
|
|
|
|
|
// 如果检测到充电电压且在0.1秒内,认为有效
|
|
|
- if (detect_charging_voltage_ && diff.seconds() < 0.1)
|
|
|
- {
|
|
|
- return true;
|
|
|
- }
|
|
|
- return false;
|
|
|
+ // if (detect_charging_voltage_ && diff.seconds() < 0.1)
|
|
|
+ // {
|
|
|
+ // return true;
|
|
|
+ // }
|
|
|
+ // return false;
|
|
|
+ return detect_charging_voltage_;
|
|
|
}
|