-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Tracking error layer #5605
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
silanus23
wants to merge
5
commits into
ros-navigation:main
Choose a base branch
from
silanus23:tracking_error_layer
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+912
−0
Draft
Tracking error layer #5605
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
91 changes: 91 additions & 0 deletions
91
nav2_costmap_2d/include/nav2_costmap_2d/tracking_error_layer.hpp
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,91 @@ | ||
| // Copyright (c) 2025 Berkan Tali | ||
| // | ||
| // Licensed under the Apache License, Version 2.0 (the "License"); | ||
| // you may not use this file except in compliance with the License. | ||
| // You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, software | ||
| // distributed under the License is distributed on an "AS IS" BASIS, | ||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| // See the License for the specific language governing permissions and | ||
| // limitations under the License. | ||
|
|
||
| #ifndef NAV2_COSTMAP_2D__TRACKING_ERROR_LAYER_HPP_ | ||
| #define NAV2_COSTMAP_2D__TRACKING_ERROR_LAYER_HPP_ | ||
|
|
||
| #include <vector> | ||
| #include <memory> | ||
| #include <mutex> | ||
|
|
||
| #include "nav2_costmap_2d/layered_costmap.hpp" | ||
| #include "rclcpp/rclcpp.hpp" | ||
| #include "nav2_costmap_2d/layer.hpp" | ||
| #include "nav_msgs/msg/path.hpp" | ||
| #include "nav2_msgs/msg/tracking_feedback.hpp" | ||
| #include "nav2_costmap_2d/costmap_layer.hpp" | ||
| #include "nav2_util/path_utils.hpp" | ||
| #include "nav2_util/geometry_utils.hpp" | ||
| #include "nav2_util/robot_utils.hpp" | ||
| #include <tf2_geometry_msgs/tf2_geometry_msgs.hpp> | ||
| #include "tf2_ros/buffer.hpp" | ||
| #include "tf2_ros/transform_listener.hpp" | ||
| #include "geometry_msgs/msg/pose_stamped.hpp" | ||
|
|
||
|
|
||
| namespace nav2_costmap_2d | ||
| { | ||
|
|
||
| class TrackingErrorLayer : public nav2_costmap_2d::CostmapLayer | ||
| { | ||
| public: | ||
| TrackingErrorLayer(); | ||
|
|
||
| ~TrackingErrorLayer(); | ||
| virtual void onInitialize(); | ||
| virtual void updateBounds( | ||
| double robot_x, double robot_y, double robot_yaw, double * min_x, | ||
| double * min_y, double * max_x, double * max_y); | ||
| virtual void updateCosts( | ||
| nav2_costmap_2d::Costmap2D & master_grid, | ||
| int min_i, int min_j, int max_i, int max_j); | ||
| virtual void reset(); | ||
| virtual void onFootprintChanged(); | ||
| virtual bool isClearable() {return false;} | ||
|
|
||
| // Lifecycle methods | ||
| virtual void activate(); | ||
| virtual void deactivate(); | ||
| virtual void cleanup(); | ||
| std::vector<std::vector<double>> getWallPoints(const nav_msgs::msg::Path & segment); | ||
| nav_msgs::msg::Path getPathSegment(); | ||
|
|
||
| protected: | ||
| void pathCallback(const nav_msgs::msg::Path::SharedPtr msg); | ||
| void trackingCallback(const nav2_msgs::msg::TrackingFeedback::SharedPtr msg); | ||
| nav2_msgs::msg::TrackingFeedback last_tracking_feedback_; | ||
| rcl_interfaces::msg::SetParametersResult | ||
| dynamicParametersCallback(std::vector<rclcpp::Parameter> parameters); | ||
|
|
||
| private: | ||
| nav2::Subscription<nav_msgs::msg::Path>::SharedPtr path_sub_; | ||
| nav2::Subscription<nav2_msgs::msg::TrackingFeedback>::SharedPtr tracking_feedback_sub_; | ||
| std::mutex path_mutex_; | ||
| std::mutex tracking_error_mutex_; | ||
| nav_msgs::msg::Path last_path_; | ||
| rclcpp::node_interfaces::OnSetParametersCallbackHandle::SharedPtr dyn_params_handler_; | ||
|
|
||
| std::shared_ptr<tf2_ros::Buffer> tf_buffer_; | ||
| std::shared_ptr<tf2_ros::TransformListener> tf_listener_; | ||
|
|
||
| size_t temp_step_; | ||
| int step_; | ||
| double width_; | ||
| double look_ahead_; | ||
| bool enabled_; | ||
| }; | ||
|
|
||
| } // namespace nav2_costmap_2d | ||
|
|
||
| #endif // NAV2_COSTMAP_2D__TRACKING_ERROR_LAYER_HPP_ | ||
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you can get away with a single data mutex