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 geometry_msgs::msg::Pose goal = utils::getLastPathPose(data.path);
44 double goal_yaw = tf2::getYaw(goal.orientation);
46 auto angular_distances = utils::shortest_angular_distance(data.trajectories.yaws,
47 goal_yaw).abs().eval();
49 if (symmetric_yaw_tolerance_) {
50 double symmetric_goal_yaw = angles::normalize_angle(goal_yaw + M_PI);
51 auto symmetric_distances = utils::shortest_angular_distance(data.trajectories.yaws,
52 symmetric_goal_yaw).abs().eval();
53 angular_distances = angular_distances.min(symmetric_distances);
57 data.costs += ((angular_distances.rowwise().mean()) * weight_).pow(power_).eval();
59 data.costs += ((angular_distances.rowwise().mean()) * weight_).eval();
65 #include <pluginlib/class_list_macros.hpp>
67 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,...