16 #include "nav2_mppi_controller/critics/goal_critic.hpp"
18 namespace mppi::critics
21 using xt::evaluation_strategy::immediate;
27 getParam(power_,
"cost_power", 1);
28 getParam(weight_,
"cost_weight", 5.0f);
29 getParam(threshold_to_consider_,
"threshold_to_consider", 1.4f);
32 logger_,
"GoalCritic instantiated with %d power and %f weight.",
38 if (!enabled_ || !utils::withinPositionGoalTolerance(
39 threshold_to_consider_, data.state.pose.pose, data.goal))
44 const auto & goal_x = data.goal.position.x;
45 const auto & goal_y = data.goal.position.y;
47 const auto traj_x = xt::view(data.trajectories.x, xt::all(), xt::all());
48 const auto traj_y = xt::view(data.trajectories.y, xt::all(), xt::all());
51 data.costs += xt::pow(
53 xt::hypot(traj_x - goal_x, traj_y - goal_y),
54 {1}, immediate) * weight_, power_);
56 data.costs += xt::mean(
57 xt::hypot(traj_x - goal_x, traj_y - goal_y),
58 {1}, immediate) * weight_;
64 #include <pluginlib/class_list_macros.hpp>
auto getParamGetter(const std::string &ns)
Get an object to retreive 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,...