hiep update

This commit is contained in:
2026-11-23 16:07:27 +07:00
parent d10bfd0ee3
commit cdcdb4f31c
6 changed files with 35 additions and 9 deletions

View File

@@ -53,9 +53,7 @@ void pnkx_local_planner::PNKXDockingLocalPlanner::initialize(robot::NodeHandle &
info_.origin_x = costmap_->getOriginX();
info_.origin_y = costmap_->getOriginY();
if (!costmap_robot_->isCurrent())
throw robot_nav_core2::CostmapDataLagException("Costmap2DROBOT is out of date somehow.");
// Costmap freshness is enforced per cycle in prepare(); layers may still be pending at load time.
parent_ = parent;
planner_nh_ = robot::NodeHandle(parent_, name);
robot::log_info_at(__FILE__, __LINE__, "Planner namespace: %s, parent namespace: %s", planner_nh_.getNamespace().c_str(), parent_.getNamespace().c_str());

View File

@@ -57,9 +57,7 @@ void pnkx_local_planner::PNKXGoStraightLocalPlanner::initialize(robot::NodeHandl
info_.origin_x = costmap_->getOriginX();
info_.origin_y = costmap_->getOriginY();
if (!costmap_robot_->isCurrent())
throw robot_nav_core2::CostmapDataLagException("Costmap2DROBOT is out of date somehow.");
// Costmap freshness is enforced per cycle in prepare(); layers may still be pending at load time.
parent_ = parent;
planner_nh_ = robot::NodeHandle(parent_, name);
robot::log_info_at(__FILE__, __LINE__, "Planner namespace: %s, parent namespace: %s", planner_nh_.getNamespace().c_str(), parent_.getNamespace().c_str());

View File

@@ -67,9 +67,7 @@ void pnkx_local_planner::PNKXLocalPlanner::initialize(robot::NodeHandle &parent,
info_.origin_x = costmap_->getOriginX();
info_.origin_y = costmap_->getOriginY();
if (!costmap_robot_->isCurrent())
throw robot_nav_core2::CostmapDataLagException("Costmap2DROBOT is out of date somehow.");
// Costmap freshness is enforced per cycle in prepare(); layers may still be pending at load time.
parent_ = parent;
planner_nh_ = robot::NodeHandle(parent_, name);
robot::log_info_at(__FILE__, __LINE__, "Planner namespace: %s, parent namespace: %s", planner_nh_.getNamespace().c_str(), parent_.getNamespace().c_str());

View File

@@ -539,6 +539,18 @@ namespace robot
*/
int loadYamlFilesFromDirectory(const std::string &directory_path);
/**
* @brief Replace the shared parameter tree with the YAML files of a directory.
*
* Sets the static config directory, clears the shared root tree and reloads it.
* Existing NodeHandle instances keep their previous scope; create new handles
* after reloading. Not thread-safe: callers must serialize with tree readers.
*
* @param config_dir Directory containing .yaml/.yml files.
* @return true if config_dir is a directory and was loaded.
*/
static bool reload(const std::string &config_dir);
/**
* @brief Get the namespace of this NodeHandle.
*

View File

@@ -880,6 +880,17 @@ namespace robot
return loaded_count;
}
bool NodeHandle::reload(const std::string &config_dir)
{
std::error_code ec;
if (!std::filesystem::is_directory(config_dir, ec))
return false;
config_directory_ = config_dir;
root_ = YAML::Node(YAML::NodeType::Map);
NodeHandle loader("~"); // empty root_ -> constructor auto-loads config_directory_
return true;
}
std::string NodeHandle::findConfigDirectory()
{
// If config directory is already set, use it