检查栅格数据过期

This commit is contained in:
lyq 2026-03-09 13:06:23 +08:00
parent 96dde92d9e
commit 1960fc8805

View File

@ -927,10 +927,16 @@ class fu_node : public rclcpp::Node
{ {
if (!enable_obstacle_stop_) return false; if (!enable_obstacle_stop_) return false;
// 检查栅格数据新鲜度(超过500ms认为数据过期) // 检查栅格数据新鲜度(超过3秒认为数据过期)
auto now = node_clock_->now(); auto now = node_clock_->now();
auto grid_age = (now - last_grid_time_).seconds(); auto grid_age = (now - last_grid_time_).seconds();
if (grid_age > 0.5)
// 如果有有效栅格数据,即使稍微过期也继续使用(只要数据不是太旧)
if (grid_data_valid_ && grid_age <= 3.0)
{
// 数据在3秒内继续使用现有数据进行障碍物检测
}
else if (grid_age > 3.0)
{ {
LOG_WARN("[紧急停车] 栅格数据过期(%.3fs),执行安全停车!", grid_age); LOG_WARN("[紧急停车] 栅格数据过期(%.3fs),执行安全停车!", grid_age);
state_machine_->publish_speed = 0; state_machine_->publish_speed = 0;