optimal & fix file cmake

This commit is contained in:
2026-08-03 22:41:32 +07:00
parent d8babff20b
commit 701d25f952
70 changed files with 5572 additions and 1146 deletions

View File

@@ -66,12 +66,12 @@ bool SensorGatewayConfig::validate(std::string& error) const
if (laser_sor_mean_k < 2)
{
error = "laser_sor_mean_k phải >= 2 [điểm] khi laser_sor_enabled = true";
error = "laser_sor_mean_k must be >= 2 [points] when laser_sor_enabled = true";
return false;
}
if (!(laser_sor_stddev_mul > 0.0))
{
error = "laser_sor_stddev_mul phải > 0 khi laser_sor_enabled = true";
error = "laser_sor_stddev_mul must be > 0 when laser_sor_enabled = true";
return false;
}
return true;
@@ -84,7 +84,7 @@ std::string SensorGatewayConfig::describe() const
out << " laser_sor_enabled : " << (laser_sor_enabled ? "true" : "false") << '\n';
if (laser_sor_enabled)
{
out << " laser_sor_mean_k : " << laser_sor_mean_k << " điểm\n";
out << " laser_sor_mean_k : " << laser_sor_mean_k << " points\n";
out << " laser_sor_stddev_mul : " << laser_sor_stddev_mul << '\n';
}
return out.str();
@@ -125,6 +125,19 @@ bool SensorGateway::configure(const SensorGatewayConfig& config, std::string& er
return true;
}
void SensorGateway::attachTelemetry(RuntimeStats* telemetry)
{
telemetry_ = telemetry;
if (telemetry_ == nullptr)
{
return;
}
section_static_map_ = telemetry_->section("sensors.staticMap");
section_laser_ = telemetry_->section("sensors.laserScan");
section_cloud_ = telemetry_->section("sensors.pointCloud");
section_depth_ = telemetry_->section("sensors.depthCamera");
}
void SensorGateway::attach(robot_costmap_2d::LayeredCostmap* global,
robot_costmap_2d::LayeredCostmap* local)
{
@@ -167,9 +180,9 @@ void SensorGateway::warnAboutUnreachableLayers(robot_costmap_2d::LayeredCostmap*
if (layer->getType() == robot_costmap_2d::LayerType::OBSTACLE_LAYER)
{
robot::log_warning(
"[SensorGateway] costmap %s: layer '%s' kiểu ObstacleLayer sẽ KHÔNG nhận dữ liệu cảm "
"biến — cổng này đẩy vật cản theo LayerType::VOXEL_LAYER. Đổi sang 'type: VoxelLayer' "
"trong danh sách plugins nếu layer đó cần dữ liệu.\n",
"[SensorGateway] costmap %s: layer '%s' of type ObstacleLayer will NOT receive sensor "
"data — this gateway pushes obstacles as LayerType::VOXEL_LAYER. Switch it to 'type: "
"VoxelLayer' in the plugins list if that layer needs data.\n",
which, layer->getName().c_str());
}
}
@@ -241,7 +254,7 @@ void dispatchTo(robot_costmap_2d::LayeredCostmap* costmap, const T& value,
++stats.layer_exceptions;
robot::log_error_throttle(
kHotPathLogThrottle,
"[SensorGateway] layer '%s' (%s) ném exception khi nhận '%s': %s\n",
"[SensorGateway] layer '%s' (%s) threw an exception while taking '%s': %s\n",
layer->getName().c_str(), toString(type), name.c_str(), ex.what());
}
}
@@ -255,11 +268,12 @@ void SensorGateway::pushStaticMap(const std::string& name, const robot_nav_msgs:
{
++stats_.dropped_no_costmap;
robot::log_warning_throttle(kHotPathLogThrottle,
"[SensorGateway] bỏ static map '%s': chưa gắn costmap nào\n",
"[SensorGateway] dropping static map '%s': no costmap attached\n",
name.c_str());
return;
}
ScopedSection timer(telemetry_, section_static_map_);
dispatchTo(global_costmap_, map, robot_costmap_2d::LayerType::STATIC_LAYER, name, stats_);
dispatchTo(local_costmap_, map, robot_costmap_2d::LayerType::STATIC_LAYER, name, stats_);
}
@@ -270,11 +284,12 @@ void SensorGateway::pushLaserScan(const std::string& name, const robot_sensor_ms
{
++stats_.dropped_no_costmap;
robot::log_warning_throttle(kHotPathLogThrottle,
"[SensorGateway] bỏ laser scan '%s': chưa gắn costmap nào\n",
"[SensorGateway] dropping laser scan '%s': no costmap attached\n",
name.c_str());
return;
}
ScopedSection timer(telemetry_, section_laser_);
dispatchTo(local_costmap_, scan, robot_costmap_2d::LayerType::VOXEL_LAYER, name, stats_);
dispatchTo(global_costmap_, scan, robot_costmap_2d::LayerType::VOXEL_LAYER, name, stats_);
}
@@ -286,11 +301,12 @@ void SensorGateway::pushPointCloud(const std::string& name,
{
++stats_.dropped_no_costmap;
robot::log_warning_throttle(kHotPathLogThrottle,
"[SensorGateway] bỏ point cloud '%s': chưa gắn costmap nào\n",
"[SensorGateway] dropping point cloud '%s': no costmap attached\n",
name.c_str());
return;
}
ScopedSection timer(telemetry_, section_cloud_);
dispatchTo(local_costmap_, cloud, robot_costmap_2d::LayerType::VOXEL_LAYER, name, stats_);
dispatchTo(global_costmap_, cloud, robot_costmap_2d::LayerType::VOXEL_LAYER, name, stats_);
}
@@ -302,11 +318,12 @@ void SensorGateway::pushPointCloud2(const std::string& name,
{
++stats_.dropped_no_costmap;
robot::log_warning_throttle(kHotPathLogThrottle,
"[SensorGateway] bỏ point cloud2 '%s': chưa gắn costmap nào\n",
"[SensorGateway] dropping point cloud2 '%s': no costmap attached\n",
name.c_str());
return;
}
ScopedSection timer(telemetry_, section_cloud_);
dispatchTo(local_costmap_, cloud, robot_costmap_2d::LayerType::VOXEL_LAYER, name, stats_);
dispatchTo(global_costmap_, cloud, robot_costmap_2d::LayerType::VOXEL_LAYER, name, stats_);
}
@@ -323,11 +340,13 @@ void SensorGateway::pushDepthCameraData(const std::string& topic,
{
++stats_.dropped_no_costmap;
robot::log_warning_throttle(kHotPathLogThrottle,
"[SensorGateway] bỏ depth camera '%s': chưa gắn costmap nào\n",
"[SensorGateway] dropping depth camera '%s': no costmap attached\n",
topic.c_str());
return;
}
ScopedSection timer(telemetry_, section_depth_);
// Phải giữ nguyên dạng ConstPtr: layer so `typeid(DepthCameraData::ConstPtr)`. Truyền giá trị sẽ
// rơi im lặng qua mọi nhánh của handleImpl.
dispatchTo(local_costmap_, data, robot_costmap_2d::LayerType::VOXEL_LAYER, topic, stats_);