Skip to content

Use of get_safe - #77

Open
fmrico wants to merge 1 commit into
rollingfrom
add_get_safe
Open

Use of get_safe#77
fmrico wants to merge 1 commit into
rollingfrom
add_get_safe

Conversation

@fmrico

@fmrico fmrico commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Hi,

Use of the new NavState::get_safe<T>(key) method (EasyNavigation/EasyNavigation#109)

Best

Signed-off-by: Francisco Martín Rico <fmrico@gmail.com>
Copilot AI lite review requested due to automatic review settings August 10, 2026 09:22

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates easynav_plugins to use the new NavState::get_safe<T>(key) accessor (from EasyNavigation/EasyNavigation#109), which returns values by copy while holding the internal mutex to avoid data races caused by get() returning an unsynchronized reference.

Changes:

  • Replace nav_state.get<T>(...) with nav_state.get_safe<T>(...) for robot pose, path, goals, tolerances, and navigation state reads across planners/controllers.
  • Exclude vendored include/bonxai/* headers from ament_cmake_uncrustify to avoid reformatting upstream code.
  • Minor whitespace-only formatting adjustments in a unit test and a controller call site.

Reviewed changes

Copilot reviewed 10 out of 11 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
planners/easynav_simple_planner/src/easynav_simple_planner/SimplePlanner.cpp Switch robot pose read to get_safe() to avoid unsynchronized reference usage.
planners/easynav_navmap_planner/src/easynav_navmap_planner/AStarPlanner.cpp Switch robot pose read to get_safe() in the A* planner update loop.
planners/easynav_costmap_planner/src/easynav_costmap_planner/CostmapPlanner.cpp Switch robot pose read to get_safe() in costmap planner update loop.
maps_managers/easynav_bonxai_maps_manager/CMakeLists.txt Exclude vendored bonxai headers from uncrustify during lint runs.
controllers/easynav_vff_controller/src/easynav_vff_controller/VffController.cpp Use get_safe() for goals and robot pose to avoid concurrent-write races.
controllers/easynav_simple_controller/src/easynav_simple_controller/SimpleController.cpp Use get_safe() for path/robot pose (note: currently does redundant get_safe() reads).
controllers/easynav_serest_controller/src/easynav_serest_controller/SerestController.cpp Use get_safe() for required inputs and tolerances; minor formatting change.
controllers/easynav_regulated_pp_controller/tests/regulated_pp_controller_tests.cpp Whitespace-only formatting changes in a test call.
controllers/easynav_regulated_pp_controller/src/easynav_regulated_pp_controller/RegulatedPurePursuitController.cpp Use get_safe() for navigation state, path, pose, and tolerances.
controllers/easynav_mppi_controller/src/easynav_mppi_controller/MPPIController.cpp Use get_safe() for navigation state, path, and robot pose.
controllers/easynav_mpc_controller/src/easynav_mpc_controller/MPCController.cpp Use get_safe() for navigation state/path/pose (note: currently does redundant get_safe() reads).

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

detection_pub_->publish(cloud_out);

const auto pose = nav_state.get<nav_msgs::msg::Odometry>("robot_pose").pose.pose;
const auto pose = nav_state.get_safe<nav_msgs::msg::Odometry>("robot_pose").pose.pose;
Comment on lines +111 to 115
const auto & pose = nav_state.get_safe<nav_msgs::msg::Odometry>("robot_pose").pose.pose;
const auto & goal_pose = path.poses.back().pose;

const auto clock_type = get_node()->get_clock()->get_clock_type();
rclcpp::Time latest_stamp(
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants