15 #include "nav2_mppi_controller/critics/prefer_forward_critic.hpp"
17 #include <Eigen/Dense>
19 namespace mppi::critics
24 auto getParentParam = parameters_handler_->
getParamGetter(parent_name_);
25 getParentParam(enforce_path_inversion_,
"enforce_path_inversion",
false);
28 getParam(power_,
"cost_power", 1);
29 getParam(weight_,
"cost_weight", 5.0f);
31 threshold_to_consider_,
32 "threshold_to_consider", 0.5f);
35 logger_,
"PreferForwardCritic instantiated with %d power and %f weight.", power_, weight_);
44 geometry_msgs::msg::Pose goal = utils::getCriticGoal(data, enforce_path_inversion_);
46 if (utils::withinPositionGoalTolerance(
47 threshold_to_consider_, data.state.pose.pose, goal))
54 (data.state.vx.unaryExpr([&](
const float & x){
return std::max(-x, 0.0f);}) *
55 data.model_dt).rowwise().sum() * weight_).pow(power_);
57 data.costs += (data.state.vx.unaryExpr([&](
const float & x){
return std::max(-x, 0.0f);}) *
58 data.model_dt).rowwise().sum() * weight_;
64 #include <pluginlib/class_list_macros.hpp>
66 PLUGINLIB_EXPORT_CLASS(
auto getParamGetter(const std::string &ns)
Get an object to retrieve parameters.
Abstract critic objective function to score trajectories.
void score(CriticData &data) override
Evaluate cost related to robot orientation at goal pose (considered only if robot near last goal in c...
void initialize() override
Initialize critic.
Data to pass to critics for scoring, including state, trajectories, pruned path, global goal,...