16 #ifndef NAV2_CONSTRAINED_SMOOTHER__OPTIONS_HPP_
17 #define NAV2_CONSTRAINED_SMOOTHER__OPTIONS_HPP_
22 #include "nav2_ros_common/lifecycle_node.hpp"
23 #include "nav2_ros_common/node_utils.hpp"
24 #include "ceres/ceres.h"
26 namespace nav2_constrained_smoother
49 std::string local_name = name + std::string(
".");
53 name +
".minimum_turning_radius", 0.4);
54 max_curvature = 1.0f / minimum_turning_radius;
57 double cost_cusp_multiplier_sqrt = std::sqrt(
59 local_name +
"w_cost_cusp_multiplier", 3.0));
60 cusp_costmap_weight_sqrt = costmap_weight_sqrt * cost_cusp_multiplier_sqrt;
63 smooth_weight_sqrt = std::sqrt(
65 local_name +
"w_smooth",
68 local_name +
"cost_check_points", std::vector<double>());
69 if (cost_check_points.size() % 3 != 0) {
72 "constrained_smoother"),
73 "cost_check_points parameter must contain values as follows: "
74 "[x1, y1, weight1, x2, y2, weight2, ...]");
75 throw std::runtime_error(
"Invalid parameter: cost_check_points");
78 for (
size_t i = 2u; i < cost_check_points.size(); i += 3) {
79 cost_check_points[i] = std::sqrt(cost_check_points[i]);
82 double check_point_weights_sum = 0.0;
83 for (
size_t i = 2u; i < cost_check_points.size(); i += 3) {
84 check_point_weights_sum += cost_check_points[i];
86 for (
size_t i = 2u; i < cost_check_points.size(); i += 3) {
87 cost_check_points[i] /= check_point_weights_sum;
90 local_name +
"path_downsampling_factor", 1);
92 local_name +
"path_upsampling_factor", 1);
95 local_name +
"keep_goal_orientation",
true);
97 local_name +
"keep_start_orientation",
true);
100 double smooth_weight_sqrt{0.0};
101 double costmap_weight_sqrt{0.0};
102 double cusp_costmap_weight_sqrt{0.0};
103 double cusp_zone_length{0.0};
104 double distance_weight_sqrt{0.0};
105 double curvature_weight_sqrt{0.0};
106 double max_curvature{0.0};
107 double max_time{10.0};
108 int path_downsampling_factor{1};
109 int path_upsampling_factor{1};
110 bool reversing_enabled{
true};
111 bool keep_goal_orientation{
true};
112 bool keep_start_orientation{
true};
113 std::vector<double> cost_check_points{};
138 std::string local_name = name + std::string(
".optimizer.");
142 local_name +
"linear_solver_type", std::string(
"SPARSE_NORMAL_CHOLESKY"));
143 if (solver_types.find(linear_solver_type) == solver_types.end()) {
144 std::stringstream valid_types_str;
145 for (
auto type = solver_types.begin(); type != solver_types.end(); type++) {
146 if (type != solver_types.begin()) {
147 valid_types_str <<
", ";
149 valid_types_str << type->first;
152 rclcpp::get_logger(
"constrained_smoother"),
153 "Invalid linear_solver_type. Valid values are %s", valid_types_str.str().c_str());
154 throw std::runtime_error(
"Invalid parameter: linear_solver_type");
163 const std::map<std::string, ceres::LinearSolverType> solver_types = {
164 {
"DENSE_QR", ceres::DENSE_QR},
165 {
"SPARSE_NORMAL_CHOLESKY", ceres::SPARSE_NORMAL_CHOLESKY}};
168 std::string linear_solver_type;
A lifecycle node wrapper to enable common Nav2 needs such as manipulating parameters.
ParameterT declare_or_get_parameter(const std::string ¶meter_name, const ParameterDescriptor ¶meter_descriptor=ParameterDescriptor())
Declares or gets a parameter with specified type (not value). If the parameter is already declared,...
void get(nav2::LifecycleNode *node, const std::string &name)
Get params from ROS parameter.
void get(nav2::LifecycleNode *node, const std::string &name)
Get params from ROS parameter.
SmootherParams()
A constructor for nav2_smac_planner::SmootherParams.