-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Goalchecker path argument and plugin #4789
Open
josephduchesne
wants to merge
13
commits into
ros-navigation:main
Choose a base branch
from
josephduchesne:goalchecker_path_argument_and_plugin
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.
+523
−62
Open
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
d0e22c2
add path argument to goal checker interface
ottojo 55a9e68
New PathCompleteGoalChecker controller plugin
josephduchesne 524ab92
- Split goal checker plugin tests into per-goal-checker tests, since …
josephduchesne d90135e
Fixed a silly spelling error
josephduchesne 63aecac
Adding missing install target for new plugin
josephduchesne 5d86e1c
Fixed typo and lint error
josephduchesne 488376c
Added is_path_longer_than_length() utility method and unit tests.
josephduchesne 5988e0d
Changed PathCompleteGoalChecker to measure remaining path length as a…
josephduchesne 01c1b2b
Updated default GoalChecker to be PathCompleteGoalChecker
josephduchesne 8c1b560
Added missing link library for path_complete_goal_checker
josephduchesne 7ba08df
Removed extra empty comment lines, and fixed redundant/misunderstood …
josephduchesne 678697b
Merge branch 'ros-navigation:main' into goalchecker_path_argument_and…
josephduchesne 8626e9b
Fixed missing return value
josephduchesne 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 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 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
82 changes: 82 additions & 0 deletions
82
nav2_controller/include/nav2_controller/plugins/path_complete_goal_checker.hpp
This file contains 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,82 @@ | ||
/* | ||
* Software License Agreement (BSD License) | ||
* | ||
* Copyright (c) 2024, Joseph Duchesne | ||
* All rights reserved. | ||
* | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted provided that the following conditions | ||
* are met: | ||
* | ||
* * Redistributions of source code must retain the above copyright | ||
* notice, this list of conditions and the following disclaimer. | ||
* * Redistributions in binary form must reproduce the above | ||
* copyright notice, this list of conditions and the following | ||
* disclaimer in the documentation and/or other materials provided | ||
* with the distribution. | ||
* * Neither the name of the copyright holder nor the names of its | ||
* contributors may be used to endorse or promote products derived | ||
* from this software without specific prior written permission. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS | ||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE | ||
* COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, | ||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, | ||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | ||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN | ||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
* POSSIBILITY OF SUCH DAMAGE. | ||
*/ | ||
|
||
#ifndef NAV2_CONTROLLER__PLUGINS__PATH_COMPLETE_GOAL_CHECKER_HPP_ | ||
#define NAV2_CONTROLLER__PLUGINS__PATH_COMPLETE_GOAL_CHECKER_HPP_ | ||
|
||
#include <string> | ||
#include <memory> | ||
#include <vector> | ||
|
||
#include "nav2_controller/plugins/simple_goal_checker.hpp" | ||
|
||
namespace nav2_controller | ||
{ | ||
|
||
/** | ||
* @class PathCompleteGoalChecker | ||
* @brief Goal Checker plugin that checks position delta, once path is shorter than a threshold. | ||
*/ | ||
class PathCompleteGoalChecker : public SimpleGoalChecker | ||
{ | ||
public: | ||
PathCompleteGoalChecker(); | ||
|
||
// Standard GoalChecker Interface | ||
void initialize( | ||
const rclcpp_lifecycle::LifecycleNode::WeakPtr & parent, | ||
const std::string & plugin_name, | ||
const std::shared_ptr<nav2_costmap_2d::Costmap2DROS> costmap_ros) override; | ||
|
||
void reset() override; | ||
|
||
bool isGoalReached( | ||
const geometry_msgs::msg::Pose & query_pose, const geometry_msgs::msg::Pose & goal_pose, | ||
const geometry_msgs::msg::Twist & velocity, const nav_msgs::msg::Path & current_path) override; | ||
|
||
protected: | ||
// minimum remaining path length before checking position goals | ||
double path_length_tolerance_; | ||
|
||
/** | ||
* @brief Callback executed when a paramter change is detected | ||
* @param parameters list of changed parameters | ||
*/ | ||
rcl_interfaces::msg::SetParametersResult | ||
dynamicParametersCallback(std::vector<rclcpp::Parameter> parameters); | ||
}; | ||
|
||
} // namespace nav2_controller | ||
|
||
#endif // NAV2_CONTROLLER__PLUGINS__PATH_COMPLETE_GOAL_CHECKER_HPP_ |
This file contains 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 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 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 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,111 @@ | ||
/* | ||
* Software License Agreement (BSD License) | ||
* | ||
* Copyright (c) 2024, Joseph Duchesne | ||
* All rights reserved. | ||
* | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted provided that the following conditions | ||
* are met: | ||
* | ||
* * Redistributions of source code must retain the above copyright | ||
* notice, this list of conditions and the following disclaimer. | ||
* * Redistributions in binary form must reproduce the above | ||
* copyright notice, this list of conditions and the following | ||
* disclaimer in the documentation and/or other materials provided | ||
* with the distribution. | ||
* * Neither the name of the copyright holder nor the names of its | ||
* contributors may be used to endorse or promote products derived | ||
* from this software without specific prior written permission. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS | ||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE | ||
* COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, | ||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, | ||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | ||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN | ||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
* POSSIBILITY OF SUCH DAMAGE. | ||
*/ | ||
|
||
#include "nav2_controller/plugins/path_complete_goal_checker.hpp" | ||
#include "pluginlib/class_list_macros.hpp" | ||
#include "nav2_util/node_utils.hpp" | ||
#include "nav2_util/geometry_utils.hpp" | ||
|
||
using rcl_interfaces::msg::ParameterType; | ||
using std::placeholders::_1; | ||
|
||
namespace nav2_controller | ||
{ | ||
|
||
PathCompleteGoalChecker::PathCompleteGoalChecker() | ||
: SimpleGoalChecker(), path_length_tolerance_(1.0) | ||
{ | ||
} | ||
|
||
void PathCompleteGoalChecker::initialize( | ||
const rclcpp_lifecycle::LifecycleNode::WeakPtr & parent, | ||
const std::string & plugin_name, | ||
const std::shared_ptr<nav2_costmap_2d::Costmap2DROS> costmap_ros) | ||
{ | ||
SimpleGoalChecker::initialize(parent, plugin_name, costmap_ros); | ||
|
||
auto node = parent.lock(); | ||
|
||
nav2_util::declare_parameter_if_not_declared( | ||
node, | ||
plugin_name + ".path_length_tolerance", | ||
rclcpp::ParameterValue(path_length_tolerance_)); | ||
|
||
node->get_parameter(plugin_name + ".path_length_tolerance", path_length_tolerance_); | ||
|
||
// Replace SimpleGoalChecker's callback for dynamic parameters | ||
dyn_params_handler_ = node->add_on_set_parameters_callback( | ||
std::bind(&PathCompleteGoalChecker::dynamicParametersCallback, this, _1)); | ||
} | ||
|
||
void PathCompleteGoalChecker::reset() | ||
{ | ||
SimpleGoalChecker::reset(); | ||
} | ||
|
||
bool PathCompleteGoalChecker::isGoalReached( | ||
const geometry_msgs::msg::Pose & query_pose, const geometry_msgs::msg::Pose & goal_pose, | ||
const geometry_msgs::msg::Twist & twist, const nav_msgs::msg::Path & path) | ||
{ | ||
using nav2_util::geometry_utils::is_path_longer_than_length; | ||
|
||
if (is_path_longer_than_length(path, path_length_tolerance_)) { | ||
return false; | ||
} | ||
// otherwise defer to SimpleGoalChecker's isGoalReached | ||
return SimpleGoalChecker::isGoalReached(query_pose, goal_pose, twist, path); | ||
} | ||
|
||
rcl_interfaces::msg::SetParametersResult | ||
PathCompleteGoalChecker::dynamicParametersCallback(std::vector<rclcpp::Parameter> parameters) | ||
{ | ||
auto result = rcl_interfaces::msg::SetParametersResult(); | ||
|
||
for (auto & parameter : parameters) { | ||
const auto & type = parameter.get_type(); | ||
const auto & name = parameter.get_name(); | ||
|
||
if (type == ParameterType::PARAMETER_DOUBLE) { | ||
if (name == plugin_name_ + ".path_length_tolerance") { | ||
path_length_tolerance_ = parameter.as_double(); | ||
} | ||
} | ||
} | ||
result.successful = true; | ||
return result; | ||
} | ||
|
||
} // namespace nav2_controller | ||
|
||
PLUGINLIB_EXPORT_CLASS(nav2_controller::PathCompleteGoalChecker, nav2_core::GoalChecker) |
This file contains 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 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 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
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 the problem here is that if the path is not updated regularly (i.e. we plan once on start and only replan if there's a problem rather than at a fixed frequency), this would not work. We actually have logic in the Controller's path handlers to account for this by finding the robot's closest point on a path within a local window size of the path and storing that as our robot's "new starting point" to prune all points prior to. Then as we iterate, that is dynamically updated. As long as the search window is larger than the greatest distance a robot can move within the control frequency plus some margin, then it works on an iterative basis.
I agree this would work fine enough though for the case that we update the path on a regular frequency as long as the tolerance is sufficiently generous.
I think it would make sense to implement the same kind of logic here, no? If so, I think we should create a
nav2_util
function that does this path handling that we use here. Then, we can replace the copy-pasted version of that in all the controllers with a common util so they all behave the same! That would be a great architectural contributionThere 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'll see what I can do :)