Skip to content

Commit

Permalink
Fix param parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
jlblancoc committed Aug 26, 2023
1 parent 9babc66 commit 6fbcd85
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
class PFLocalizationCore : public mrpt::system::COutputLogger
{
public:
PFLocalizationCore() = default;
PFLocalizationCore();
virtual ~PFLocalizationCore() = default;

/** Parameters the filter will use to initialize or to run.
Expand Down
2 changes: 2 additions & 0 deletions mrpt_pf_localization/include/mrpt_pf_localization_node.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ class PFLocalizationNode : public rclcpp::Node
private:
PFLocalizationCore core_;

rclcpp::TimerBase::SharedPtr timer_;

///
void reload_params_from_ros();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,11 @@ void PFLocalizationCore::Parameters::load_from(
// class.
}

PFLocalizationCore::PFLocalizationCore()
: mrpt::system::COutputLogger("mrpt_pf_localization")
{
}

void PFLocalizationCore::on_observation(const mrpt::obs::CObservation::Ptr& obs)
{
auto tle = mrpt::system::CTimeLoggerEntry(profiler_, "on_observation");
Expand Down
16 changes: 12 additions & 4 deletions mrpt_pf_localization/src/mrpt_pf_localization_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ PFLocalizationNode::PFLocalizationNode(const rclcpp::NodeOptions& options)

// Create timer:
// ------------------------------------------
this->create_wall_timer(
timer_ = this->create_wall_timer(
std::chrono::microseconds(mrpt::round(1.0e6 / nodeParams_.rate_hz)),
[this]() { this->loop(); });
}
Expand Down Expand Up @@ -140,9 +140,17 @@ void PFLocalizationNode::reload_params_from_ros()
const std::string childKey = name.substr(pos + 1);
name = childKey;

// Create YAML node:
(*targetYamlNode)[parentKey] = mrpt::containers::yaml::Map();
targetYamlNode = &(*targetYamlNode)[parentKey].asMap();
// Use subnode:
if (auto it = targetYamlNode->find(parentKey);
it == targetYamlNode->end())
{ // create new:
(*targetYamlNode)[parentKey] = mrpt::containers::yaml::Map();
targetYamlNode = &(*targetYamlNode)[parentKey].asMap();
}
else
{ // reuse
targetYamlNode = &it->second.asMap();
}
}

// Get param value:
Expand Down

0 comments on commit 6fbcd85

Please sign in to comment.