Use of get_safe - #77
Open
fmrico wants to merge 1 commit into
Open
Conversation
Signed-off-by: Francisco Martín Rico <fmrico@gmail.com>
Contributor
There was a problem hiding this comment.
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>(...)withnav_state.get_safe<T>(...)for robot pose, path, goals, tolerances, and navigation state reads across planners/controllers. - Exclude vendored
include/bonxai/*headers fromament_cmake_uncrustifyto 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( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hi,
Use of the new
NavState::get_safe<T>(key)method (EasyNavigation/EasyNavigation#109)Best