16 #include "nav2_mppi_controller/critics/goal_critic.hpp"
18 namespace mppi::critics
24 auto getParentParam = parameters_handler_->
getParamGetter(parent_name_);
25 getParentParam(enforce_path_inversion_,
"enforce_path_inversion",
false);
29 getParam(power_,
"cost_power", 1);
30 getParam(weight_,
"cost_weight", 5.0f);
31 getParam(threshold_to_consider_,
"threshold_to_consider", 1.4f);
34 logger_,
"GoalCritic instantiated with %d power and %f weight.",
44 geometry_msgs::msg::Pose goal = utils::getCriticGoal(data, enforce_path_inversion_);
46 if (!utils::withinPositionGoalTolerance(
47 threshold_to_consider_, data.state.pose.pose, goal))
52 auto goal_x = goal.position.x;
53 auto goal_y = goal.position.y;
55 const auto delta_x = data.trajectories.x - goal_x;
56 const auto delta_y = data.trajectories.y - goal_y;
59 data.costs += (((delta_x.square() + delta_y.square()).sqrt()).rowwise().mean() *
62 data.costs += (((delta_x.square() + delta_y.square()).sqrt()).rowwise().mean() *
69 #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,...