35 #include "dwb_critics/prefer_forward.hpp"
37 #include "pluginlib/class_list_macros.hpp"
44 void PreferForwardCritic::onInit()
46 auto node = node_.lock();
48 throw std::runtime_error{
"Failed to lock node"};
51 penalty_ = node->declare_or_get_parameter(
52 dwb_plugin_name_ +
"." + name_ +
".penalty", 1.0);
53 strafe_x_ = node->declare_or_get_parameter(
54 dwb_plugin_name_ +
"." + name_ +
".strafe_x", 0.1);
55 strafe_theta_ = node->declare_or_get_parameter(
56 dwb_plugin_name_ +
"." + name_ +
".strafe_theta", 0.2);
57 theta_scale_ = node->declare_or_get_parameter(
58 dwb_plugin_name_ +
"." + name_ +
".theta_scale", 10.0);
64 if (traj.velocity.x < 0.0) {
68 if (traj.velocity.x < strafe_x_ && fabs(traj.velocity.theta) < strafe_theta_) {
73 return fabs(traj.velocity.theta) * theta_scale_;
Evaluates a Trajectory2D to produce a score.
Penalize trajectories with move backwards and/or turn too much.
double scoreTrajectory(const dwb_msgs::msg::Trajectory2D &traj) override
Return a raw score for the given trajectory.