Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 18 additions & 10 deletions controllers/easynav_mpc_controller/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,26 @@ find_package(sensor_msgs REQUIRED)
find_package(pcl_conversions REQUIRED)
find_package(Eigen3 REQUIRED NO_MODULE)
find_package(PCL REQUIRED COMPONENTS common io)

# Try to find NLopt package from system first, or get it through CMake FetchContent to build it
find_package(NLopt QUIET)
if(NOT NLopt_FOUND)
find_path(NLOPT_INCLUDE_DIR nlopt.hpp)
find_library(NLOPT_LIBRARY nlopt)
if(NLOPT_INCLUDE_DIR AND NLOPT_LIBRARY)
set(NLopt_FOUND TRUE)
set(NLopt_INCLUDE_DIRS ${NLOPT_INCLUDE_DIR})
set(NLopt_LIBRARIES ${NLOPT_LIBRARY})
endif()
endif()
if(NOT NLopt_FOUND)
message(FATAL_ERROR "NLopt not found. Install libnlopt-dev or set NLopt_DIR/CMAKE_PREFIX_PATH.")
include(FetchContent)
# Force FetchContent to download and build in the workspace build dir
set(FETCH_CONTENT_BASE_DIR "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/_deps>")

# Disable unneeded NLopt features
set(NLOPT_PYTHON OFF)
set(NLOPT_OCTAVE OFF)
set(NLOPT_GUILE OFF)
set(NLOPT_JAVA OFF)
fetchcontent_declare(nlopt
GIT_REPOSITORY https://github.com/stevengj/nlopt
GIT_TAG v2.11.0
)
fetchcontent_makeavailable(
nlopt
)
endif()

add_library(${PROJECT_NAME} SHARED
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,10 @@ TEST(DynamicWindowPurePursuit, ComputeDynamicWindowClampsToAccelLimits)
current_speed.angular.z = 0.0;

const auto window = easynav::dynamic_window_pure_pursuit::computeDynamicWindow(
current_speed, /*max_linear_vel=*/1.0, /*min_linear_vel=*/-1.0,
/*max_angular_vel=*/1.0, /*min_angular_vel=*/-1.0,
/*max_linear_accel=*/2.0, /*max_linear_decel=*/2.0,
/*max_angular_accel=*/2.0, /*max_angular_decel=*/2.0, /*dt=*/0.1);
current_speed, /*max_linear_vel=*/ 1.0, /*min_linear_vel=*/ -1.0,
/*max_angular_vel=*/ 1.0, /*min_angular_vel=*/ -1.0,
/*max_linear_accel=*/ 2.0, /*max_linear_decel=*/ 2.0,
/*max_angular_accel=*/ 2.0, /*max_angular_decel=*/ 2.0, /*dt=*/ 0.1);

EXPECT_NEAR(window.max_linear_vel, 0.2, 1e-9);
EXPECT_NEAR(window.min_linear_vel, -0.2, 1e-9);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -634,13 +634,11 @@ SerestController::update_rt(NavState & nav_state)
if (!fetch_required_inputs(nav_state, path, odom)) {return;}

// 1.5) Goal tolerances: prefer shared GoalManager values, fallback to local params
double goal_pos_tol = goal_pos_tol_;
double goal_yaw_tol = goal_yaw_tol_deg_ * (M_PI / 180.0);
if (nav_state.has("goal_tolerance.position")) {
goal_pos_tol = nav_state.get<double>("goal_tolerance.position");
goal_pos_tol_ = nav_state.get<double>("goal_tolerance.position");
}
if (nav_state.has("goal_tolerance.yaw")) {
goal_yaw_tol = nav_state.get<double>("goal_tolerance.yaw");
goal_yaw_tol_deg_ = nav_state.get<double>("goal_tolerance.yaw") * (180.0 / M_PI);
}

// 2) Robot state (position + yaw)
Expand Down Expand Up @@ -718,10 +716,10 @@ SerestController::update_rt(NavState & nav_state)
publish_cmd_and_debug(
nav_state, path, vlin, vrot,
e_y, e_theta, rk.kappa_hat,
d_closest, v_safe, v_curv, /*alpha*/1.0,
d_closest, v_safe, v_curv, /*alpha*/ 1.0,
allow_reverse_, dist_to_end,
dist_xy_goal, gamma_slow,
/*in_final_align*/0, /*arrived*/0);
/*in_final_align*/ 0, /*arrived*/ 0);
return;
}
}
Expand Down Expand Up @@ -830,7 +828,7 @@ SerestController::update_rt(NavState & nav_state)
d_closest, v_safe, v_curv, alpha,
allow_reverse_, dist_to_end,
dist_xy_goal, gamma_slow,
/*in_final_align=*/0, /*arrived=*/0);
/*in_final_align=*/ 0, /*arrived=*/ 0);
}

} // namespace easynav
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,22 +189,28 @@ AMCLLocalizer::on_initialize()
auto node = get_node();
const auto & plugin_name = get_plugin_name();

int num_particles;
double x_init, y_init, yaw_init, std_dev_xy, std_dev_yaw;

node->declare_parameter<int>(plugin_name + ".num_particles", 100);
node->declare_parameter<double>(plugin_name + ".initial_pose.x", 0.0);
node->declare_parameter<double>(plugin_name + ".initial_pose.y", 0.0);
node->declare_parameter<double>(plugin_name + ".initial_pose.yaw", 0.0);
node->declare_parameter<double>(plugin_name + ".initial_pose.std_dev_xy", 0.5);
node->declare_parameter<double>(plugin_name + ".initial_pose.std_dev_yaw", 0.5);
node->declare_parameter<double>(plugin_name + ".reseed_freq", 1.0);
node->declare_parameter<double>(plugin_name + ".noise_translation", 0.01);
node->declare_parameter<double>(plugin_name + ".noise_rotation", 0.01);
node->declare_parameter<double>(plugin_name + ".noise_translation_to_rotation", 0.01);
node->declare_parameter<double>(plugin_name + ".min_noise_xy", 0.05);
node->declare_parameter<double>(plugin_name + ".min_noise_yaw", 0.05);
node->declare_parameter<bool>(plugin_name + ".compute_odom_from_tf", false);
int num_particles = 100;
double x_init = 0.0;
double y_init = 0.0;
double yaw_init = 0.0;
double std_dev_xy = 0.5;
double std_dev_yaw = 0.5;
double reseed_freq = 1.0;

node->declare_parameter<int>(plugin_name + ".num_particles", num_particles);
node->declare_parameter<double>(plugin_name + ".initial_pose.x", x_init);
node->declare_parameter<double>(plugin_name + ".initial_pose.y", y_init);
node->declare_parameter<double>(plugin_name + ".initial_pose.yaw", yaw_init);
node->declare_parameter<double>(plugin_name + ".initial_pose.std_dev_xy", std_dev_xy);
node->declare_parameter<double>(plugin_name + ".initial_pose.std_dev_yaw", std_dev_yaw);
node->declare_parameter<double>(plugin_name + ".reseed_freq", reseed_freq);
node->declare_parameter<double>(plugin_name + ".noise_translation", noise_translation_);
node->declare_parameter<double>(plugin_name + ".noise_rotation", noise_rotation_);
node->declare_parameter<double>(plugin_name + ".noise_translation_to_rotation",
noise_translation_to_rotation_);
node->declare_parameter<double>(plugin_name + ".min_noise_xy", min_noise_xy_);
node->declare_parameter<double>(plugin_name + ".min_noise_yaw", min_noise_yaw_);
node->declare_parameter<bool>(plugin_name + ".compute_odom_from_tf", compute_odom_from_tf_);

node->get_parameter<int>(plugin_name + ".num_particles", num_particles);
node->get_parameter<double>(plugin_name + ".initial_pose.x", x_init);
Expand All @@ -220,7 +226,6 @@ AMCLLocalizer::on_initialize()
node->get_parameter<double>(plugin_name + ".min_noise_yaw", min_noise_yaw_);
node->get_parameter<bool>(plugin_name + ".compute_odom_from_tf", compute_odom_from_tf_);

double reseed_freq;
node->get_parameter<double>(plugin_name + ".reseed_freq", reseed_freq);
reseed_time_ = 1.0 / reseed_freq;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,21 +187,27 @@ AMCLLocalizer::on_initialize()
auto node = get_node();
const auto & plugin_name = get_plugin_name();

int num_particles;
double x_init, y_init, yaw_init, std_dev_xy, std_dev_yaw;

node->declare_parameter<int>(plugin_name + ".num_particles", 100);
node->declare_parameter<double>(plugin_name + ".initial_pose.x", 0.0);
node->declare_parameter<double>(plugin_name + ".initial_pose.y", 0.0);
node->declare_parameter<double>(plugin_name + ".initial_pose.yaw", 0.0);
node->declare_parameter<double>(plugin_name + ".initial_pose.std_dev_xy", 0.5);
node->declare_parameter<double>(plugin_name + ".initial_pose.std_dev_yaw", 0.5);
node->declare_parameter<double>(plugin_name + ".reseed_freq", 1.0);
node->declare_parameter<double>(plugin_name + ".noise_translation", 0.01);
node->declare_parameter<double>(plugin_name + ".noise_rotation", 0.01);
node->declare_parameter<double>(plugin_name + ".noise_translation_to_rotation", 0.01);
node->declare_parameter<double>(plugin_name + ".min_noise_xy", 0.05);
node->declare_parameter<double>(plugin_name + ".min_noise_yaw", 0.05);
int num_particles = 100;
double x_init = 0.0;
double y_init = 0.0;
double yaw_init = 0.0;
double std_dev_xy = 0.5;
double std_dev_yaw = 0.5;
double reseed_freq = 1.0;

node->declare_parameter<int>(plugin_name + ".num_particles", num_particles);
node->declare_parameter<double>(plugin_name + ".initial_pose.x", x_init);
node->declare_parameter<double>(plugin_name + ".initial_pose.y", y_init);
node->declare_parameter<double>(plugin_name + ".initial_pose.yaw", yaw_init);
node->declare_parameter<double>(plugin_name + ".initial_pose.std_dev_xy", std_dev_xy);
node->declare_parameter<double>(plugin_name + ".initial_pose.std_dev_yaw", std_dev_yaw);
node->declare_parameter<double>(plugin_name + ".reseed_freq", reseed_freq);
node->declare_parameter<double>(plugin_name + ".noise_translation", noise_translation_);
node->declare_parameter<double>(plugin_name + ".noise_rotation", noise_rotation_);
node->declare_parameter<double>(plugin_name + ".noise_translation_to_rotation",
noise_translation_to_rotation_);
node->declare_parameter<double>(plugin_name + ".min_noise_xy", min_noise_xy_);
node->declare_parameter<double>(plugin_name + ".min_noise_yaw", min_noise_yaw_);

node->get_parameter<int>(plugin_name + ".num_particles", num_particles);
node->get_parameter<double>(plugin_name + ".initial_pose.x", x_init);
Expand Down Expand Up @@ -231,7 +237,6 @@ AMCLLocalizer::on_initialize()
}


double reseed_freq;
node->get_parameter<double>(plugin_name + ".reseed_freq", reseed_freq);
reseed_time_ = 1.0 / reseed_freq;

Expand Down