Skip to content

Commit 88d8667

Browse files
pepisgSteveMacenski
authored andcommitted
Scale cost critic's weight when dynamically updated (#4246)
* 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]>
1 parent 4e16d3c commit 88d8667

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

nav2_mppi_controller/src/critics/cost_critic.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,12 @@ void CostCritic::initialize()
3333
// Normalized by cost value to put in same regime as other weights
3434
weight_ /= 254.0f;
3535

36+
// Normalize weight when parameter is changed dynamically as well
37+
auto weightDynamicCb = [&](const rclcpp::Parameter & weight) {
38+
weight_ = weight.as_double() / 254.0f;
39+
};
40+
parameters_handler_->addDynamicParamCallback(name_ + ".cost_weight", weightDynamicCb);
41+
3642
collision_checker_.setCostmap(costmap_);
3743
possibly_inscribed_cost_ = findCircumscribedCost(costmap_ros_);
3844

0 commit comments

Comments
 (0)