Skip to content

Commit

Permalink
Scale cost critic's weight when dynamically updated (#4246)
Browse files Browse the repository at this point in the history
* Scale cost critic's weight when dynamically updated

Signed-off-by: pepisg <[email protected]>

* sign off

Signed-off-by: pepisg <[email protected]>

---------

Signed-off-by: pepisg <[email protected]>
  • Loading branch information
pepisg authored Apr 8, 2024
1 parent 0be2f25 commit f815e8b
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions nav2_mppi_controller/src/critics/cost_critic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ void CostCritic::initialize()
// Normalized by cost value to put in same regime as other weights
weight_ /= 254.0f;

// Normalize weight when parameter is changed dynamically as well
auto weightDynamicCb = [&](const rclcpp::Parameter & weight) {
weight_ = weight.as_double() / 254.0f;
};
parameters_handler_->addDynamicParamCallback(name_ + ".cost_weight", weightDynamicCb);

collision_checker_.setCostmap(costmap_);
possible_collision_cost_ = findCircumscribedCost(costmap_ros_);

Expand Down

0 comments on commit f815e8b

Please sign in to comment.