35 #include "dwb_critics/goal_align.hpp"
38 #include "dwb_critics/alignment_util.hpp"
39 #include "pluginlib/class_list_macros.hpp"
40 #include "nav_2d_utils/parameters.hpp"
45 void GoalAlignCritic::onInit()
47 GoalDistCritic::onInit();
48 stop_on_failure_ =
false;
50 auto node = node_.lock();
52 throw std::runtime_error{
"Failed to lock node"};
55 forward_point_distance_ = nav_2d_utils::searchAndGetParam(
57 dwb_plugin_name_ +
"." + name_ +
".forward_point_distance", 0.325);
61 const geometry_msgs::msg::Pose2D & pose,
const nav_2d_msgs::msg::Twist2D & vel,
62 const geometry_msgs::msg::Pose2D & goal,
63 const nav_2d_msgs::msg::Path2D & global_plan)
70 double angle_to_goal = atan2(goal.y - pose.y, goal.x - pose.x);
72 nav_2d_msgs::msg::Path2D target_poses = global_plan;
73 target_poses.poses.back().x += forward_point_distance_ * cos(angle_to_goal);
74 target_poses.poses.back().y += forward_point_distance_ * sin(angle_to_goal);
Evaluates a Trajectory2D to produce a score.
Scores trajectories based on whether the robot ends up pointing toward the eventual goal.
double scorePose(const geometry_msgs::msg::Pose2D &pose) override
Retrieve the score for a single pose.
bool prepare(const geometry_msgs::msg::Pose2D &pose, const nav_2d_msgs::msg::Twist2D &vel, const geometry_msgs::msg::Pose2D &goal, const nav_2d_msgs::msg::Path2D &global_plan) override
Prior to evaluating any trajectories, look at contextual information constant across all trajectories...
bool prepare(const geometry_msgs::msg::Pose2D &pose, const nav_2d_msgs::msg::Twist2D &vel, const geometry_msgs::msg::Pose2D &goal, const nav_2d_msgs::msg::Path2D &global_plan) override
Prior to evaluating any trajectories, look at contextual information constant across all trajectories...
virtual double scorePose(const geometry_msgs::msg::Pose2D &pose)
Retrieve the score for a single pose.