35 #include "dwb_critics/goal_align.hpp"
38 #include "dwb_critics/alignment_util.hpp"
39 #include "pluginlib/class_list_macros.hpp"
44 void GoalAlignCritic::onInit()
46 GoalDistCritic::onInit();
47 stop_on_failure_ =
false;
49 auto node = node_.lock();
51 throw std::runtime_error{
"Failed to lock node"};
54 forward_point_distance_ = node->declare_or_get_parameter(dwb_plugin_name_ +
"." + name_ +
55 ".forward_point_distance", 0.325);
59 const geometry_msgs::msg::Pose & pose,
const nav_2d_msgs::msg::Twist2D & vel,
60 const geometry_msgs::msg::Pose & goal,
61 const nav_msgs::msg::Path & global_plan)
68 double angle_to_goal = atan2(goal.position.y - pose.position.y,
69 goal.position.x - pose.position.x);
71 nav_msgs::msg::Path target_poses = global_plan;
72 target_poses.poses.back().pose.position.x += forward_point_distance_ * cos(angle_to_goal);
73 target_poses.poses.back().pose.position.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.
bool prepare(const geometry_msgs::msg::Pose &pose, const nav_2d_msgs::msg::Twist2D &vel, const geometry_msgs::msg::Pose &goal, const nav_msgs::msg::Path &global_plan) override
Prior to evaluating any trajectories, look at contextual information constant across all trajectories...
double scorePose(const geometry_msgs::msg::Pose &pose) override
Retrieve the score for a single pose.
bool prepare(const geometry_msgs::msg::Pose &pose, const nav_2d_msgs::msg::Twist2D &vel, const geometry_msgs::msg::Pose &goal, const nav_msgs::msg::Path &global_plan) override
Prior to evaluating any trajectories, look at contextual information constant across all trajectories...
virtual double scorePose(const geometry_msgs::msg::Pose &pose)
Retrieve the score for a single pose.