16 #include "nav2_mppi_controller/critics/goal_critic.hpp"
18 namespace mppi::critics
24 auto getParentParam = parameters_handler_->
getParamGetter(parent_name_);
26 getParam(power_,
"cost_power", 1);
27 getParam(weight_,
"cost_weight", 5.0f);
28 getParam(threshold_to_consider_,
"threshold_to_consider", 1.4f);
31 logger_,
"GoalCritic instantiated with %d power and %f weight.",
37 if (!enabled_ || data.state.local_path_length > threshold_to_consider_) {
41 geometry_msgs::msg::Pose goal = utils::getLastPathPose(data.path);
43 auto goal_x = goal.position.x;
44 auto goal_y = goal.position.y;
46 const auto delta_x = data.trajectories.x - goal_x;
47 const auto delta_y = data.trajectories.y - goal_y;
50 data.costs += (((delta_x.square() + delta_y.square()).sqrt()).rowwise().mean() *
53 data.costs += (((delta_x.square() + delta_y.square()).sqrt()).rowwise().mean() *
60 #include <pluginlib/class_list_macros.hpp>
auto getParamGetter(const std::string &ns)
Get an object to retrieve parameters.
Abstract critic objective function to score trajectories.
void initialize() override
Initialize critic.
void score(CriticData &data) override
Evaluate cost related to goal following.
Data to pass to critics for scoring, including state, trajectories, pruned path, global goal,...