15 #include "nav2_mppi_controller/critics/goal_angle_critic.hpp"
16 #include "angles/angles.h"
17 namespace mppi::critics
22 auto getParentParam = parameters_handler_->
getParamGetter(parent_name_);
24 getParam(power_,
"cost_power", 1);
25 getParam(weight_,
"cost_weight", 3.0f);
26 getParam(threshold_to_consider_,
"threshold_to_consider", 0.5f);
27 getParam(symmetric_yaw_tolerance_,
"symmetric_yaw_tolerance",
false);
31 "GoalAngleCritic instantiated with %d power, %f weight, %f "
32 "angular threshold and symmetric_yaw_tolerance %s",
33 power_, weight_, threshold_to_consider_, symmetric_yaw_tolerance_ ?
"enabled" :
"disabled");
38 if (!enabled_ || data.state.local_path_length > threshold_to_consider_) {
42 const geometry_msgs::msg::Pose goal = utils::getLastPathPose(data.path);
43 const float goal_yaw =
static_cast<float>(tf2::getYaw(goal.orientation));
44 auto angular_distances = utils::shortest_angular_distance(data.trajectories.yaws, goal_yaw).abs();
46 if (symmetric_yaw_tolerance_) {
47 const float symmetric_goal_yaw = angles::normalize_angle(goal_yaw + M_PI);
48 auto symmetric_distances = utils::shortest_angular_distance(data.trajectories.yaws,
49 symmetric_goal_yaw).abs().eval();
51 data.costs += (angular_distances.min(symmetric_distances).rowwise().mean() *
54 data.costs += angular_distances.min(symmetric_distances).rowwise().mean() * weight_;
60 data.costs += (angular_distances.rowwise().mean() * weight_).pow(power_);
62 data.costs += angular_distances.rowwise().mean() * weight_;
68 #include <pluginlib/class_list_macros.hpp>
70 PLUGINLIB_EXPORT_CLASS(
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 robot orientation at goal pose (considered only if robot near last goal in c...
Data to pass to critics for scoring, including state, trajectories, pruned path, global goal,...