File tree 2 files changed +12
-2
lines changed
include/nav2_mppi_controller/critics
2 files changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -46,6 +46,7 @@ class GoalCritic : public CriticFunction
46
46
unsigned int power_{0 };
47
47
float weight_{0 };
48
48
float threshold_to_consider_{0 };
49
+ bool enforce_path_inversion_{false };
49
50
};
50
51
51
52
} // namespace mppi::critics
Original file line number Diff line number Diff line change @@ -21,6 +21,9 @@ namespace mppi::critics
21
21
22
22
void GoalCritic::initialize ()
23
23
{
24
+ auto getParentParam = parameters_handler_->getParamGetter (parent_name_);
25
+ getParentParam (enforce_path_inversion_, " enforce_path_inversion" , false );
26
+
24
27
auto getParam = parameters_handler_->getParamGetter (name_);
25
28
26
29
getParam (power_, " cost_power" , 1 );
@@ -40,8 +43,14 @@ void GoalCritic::score(CriticData & data)
40
43
return ;
41
44
}
42
45
43
- const auto & goal_x = data.goal .position .x ;
44
- const auto & goal_y = data.goal .position .y ;
46
+ auto goal_x = data.goal .position .x ;
47
+ auto goal_y = data.goal .position .y ;
48
+
49
+ if (enforce_path_inversion_) {
50
+ const unsigned int cusp_idx = data.path .x .size () - 1 ;
51
+ goal_x = data.path .x [cusp_idx];
52
+ goal_y = data.path .y [cusp_idx];
53
+ }
45
54
46
55
const auto delta_x = data.trajectories .x - goal_x;
47
56
const auto delta_y = data.trajectories .y - goal_y;
You can’t perform that action at this time.
0 commit comments