-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Cleaned up version of is path valid #2591
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
Merged
Merged
Changes from all commits
Commits
Show all changes
36 commits
Select commit
Hold shift + click to select a range
d68327c
Working replanning if path is vaild, however there is a bug with new …
jwallace42 9c1b724
Completed tested of path replanning
jwallace42 ab0bd04
Delete uncrustify.cfg
jwallace42 82ba36e
Clean up for code review
jwallace42 c6cf5e7
Merge branch 'replanning' of https://github.com/jwallace42/navigation…
jwallace42 1db1637
steady
jwallace42 a45acd4
Merge branch 'main' into replanning
jwallace42 d9e7e3e
small code review changes
jwallace42 0246e99
listen to server_timeout in input port
jwallace42 b295ba4
Lint issues
jwallace42 b6fb154
reverted file for navigate to pose
jwallace42 e105ed7
lint fixes
jwallace42 9a3515c
added global update condition
jwallace42 9eb57d2
headless
jwallace42 e9f6242
revert default bt
jwallace42 4093b9e
Merge branch 'main' of https://github.com/ros-planning/navigation2 in…
jwallace42 dc90458
Add image of new bt tree
jwallace42 617f42d
circle ci and comments
jwallace42 2dcbf3e
add test for globally updated goal condition
jwallace42 eacd1f9
added plath replanning only if path is invalid to navigate to pose
jwallace42 779e3b6
Added nodes to nav2_tree_nodes
jwallace42 6893e29
Merge branch 'main' of github.com:ros-planning/navigation2 into repla…
jwallace42 18fbb98
cleanup BT tree for invalid path
jwallace42 3f389ae
code fixeds
jwallace42 2638090
lint fixes
jwallace42 dce9cd2
added default timeout
jwallace42 e0c18ff
lint fix
jwallace42 f1e6a71
server timeout fix
jwallace42 bc01fa6
removed images of new BTs
jwallace42 6aa2e9f
added rate controller
jwallace42 f3caddc
lint fix
jwallace42 24b748b
Moved server timeout to constructor
jwallace42 405178b
fixed xml lint error
jwallace42 e85a582
fixed test for is path valid
jwallace42 b774eb1
new bt image for reference
jwallace42 1945361
remove reference
jwallace42 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
73 changes: 73 additions & 0 deletions
73
...ior_tree/include/nav2_behavior_tree/plugins/condition/globally_updated_goal_condition.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,73 @@ | ||
| // Copyright (c) 2021 Joshua Wallace | ||
| // | ||
| // 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_BEHAVIOR_TREE__PLUGINS__CONDITION__GLOBALLY_UPDATED_GOAL_CONDITION_HPP_ | ||
| #define NAV2_BEHAVIOR_TREE__PLUGINS__CONDITION__GLOBALLY_UPDATED_GOAL_CONDITION_HPP_ | ||
|
|
||
| #include <string> | ||
| #include <vector> | ||
|
|
||
| #include "rclcpp/rclcpp.hpp" | ||
|
|
||
| #include "behaviortree_cpp_v3/condition_node.h" | ||
| #include "geometry_msgs/msg/pose_stamped.hpp" | ||
|
|
||
|
|
||
| namespace nav2_behavior_tree | ||
| { | ||
| /** | ||
| * @brief A BT::ConditionNode that returns SUCCESS when goal is | ||
| * updated on the blackboard and FAILURE otherwise | ||
| */ | ||
| class GloballyUpdatedGoalCondition : public BT::ConditionNode | ||
| { | ||
| public: | ||
| /** | ||
| * @brief A constructor for nav2_behavior_tree::GloballyUpdatedGoalCondition | ||
| * @param condition_name Name for the XML tag for this node | ||
| * @param conf BT node configuration | ||
| */ | ||
| GloballyUpdatedGoalCondition( | ||
| const std::string & condition_name, | ||
| const BT::NodeConfiguration & conf); | ||
|
|
||
| GloballyUpdatedGoalCondition() = delete; | ||
|
|
||
| /** | ||
| * @brief The main override required by a BT action | ||
| * @return BT::NodeStatus Status of tick execution | ||
| */ | ||
| BT::NodeStatus tick() override; | ||
|
|
||
|
|
||
| /** | ||
| * @brief Creates list of BT ports | ||
| * @return BT::PortsList Containing node-specific ports | ||
| */ | ||
| static BT::PortsList providedPorts() | ||
| { | ||
| return {}; | ||
| } | ||
|
|
||
| private: | ||
| bool first_time; | ||
| rclcpp::Node::SharedPtr node_; | ||
| geometry_msgs::msg::PoseStamped goal_; | ||
| std::vector<geometry_msgs::msg::PoseStamped> goals_; | ||
| }; | ||
|
|
||
| } // namespace nav2_behavior_tree | ||
|
|
||
|
|
||
| #endif // NAV2_BEHAVIOR_TREE__PLUGINS__CONDITION__GLOBALLY_UPDATED_GOAL_CONDITION_HPP_ |
75 changes: 75 additions & 0 deletions
75
nav2_behavior_tree/include/nav2_behavior_tree/plugins/condition/is_path_valid_condition.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,75 @@ | ||
| // Copyright (c) 2021 Joshua Wallace | ||
| // | ||
| // 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_BEHAVIOR_TREE__PLUGINS__CONDITION__IS_PATH_VALID_CONDITION_HPP_ | ||
| #define NAV2_BEHAVIOR_TREE__PLUGINS__CONDITION__IS_PATH_VALID_CONDITION_HPP_ | ||
|
|
||
| #include <string> | ||
| #include <memory> | ||
|
|
||
| #include "rclcpp/rclcpp.hpp" | ||
| #include "behaviortree_cpp_v3/condition_node.h" | ||
| #include "geometry_msgs/msg/pose_stamped.hpp" | ||
| #include "nav2_msgs/srv/is_path_valid.hpp" | ||
|
|
||
| namespace nav2_behavior_tree | ||
| { | ||
|
|
||
| /** | ||
| * @brief A BT::ConditionNode that returns SUCCESS when the IsPathValid | ||
| * service returns true and FAILURE otherwise | ||
| */ | ||
| class IsPathValidCondition : public BT::ConditionNode | ||
| { | ||
| public: | ||
| /** | ||
| * @brief A constructor for nav2_behavior_tree::IsPathValidCondition | ||
| * @param condition_name Name for the XML tag for this node | ||
| * @param conf BT node configuration | ||
| */ | ||
| IsPathValidCondition( | ||
| const std::string & condition_name, | ||
| const BT::NodeConfiguration & conf); | ||
|
|
||
| IsPathValidCondition() = delete; | ||
|
|
||
| /** | ||
| * @brief The main override required by a BT action | ||
| * @return BT::NodeStatus Status of tick execution | ||
| */ | ||
| BT::NodeStatus tick() override; | ||
|
|
||
| /** | ||
| * @brief Creates list of BT ports | ||
| * @return BT::PortsList Containing node-specific ports | ||
| */ | ||
| static BT::PortsList providedPorts() | ||
| { | ||
| return { | ||
| BT::InputPort<nav_msgs::msg::Path>("path", "Path to Check"), | ||
| BT::InputPort<std::chrono::milliseconds>("server_timeout") | ||
| }; | ||
| } | ||
|
|
||
| private: | ||
| rclcpp::Node::SharedPtr node_; | ||
| rclcpp::Client<nav2_msgs::srv::IsPathValid>::SharedPtr client_; | ||
| // The timeout value while waiting for a responce from the | ||
| // is path valid service | ||
| std::chrono::milliseconds server_timeout_; | ||
| }; | ||
|
|
||
| } // namespace nav2_behavior_tree | ||
|
|
||
| #endif // NAV2_BEHAVIOR_TREE__PLUGINS__CONDITION__IS_PATH_VALID_CONDITION_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
61 changes: 61 additions & 0 deletions
61
nav2_behavior_tree/plugins/condition/globally_updated_goal_condition.cpp
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,61 @@ | ||
| // Copyright (c) 2021 Joshua Wallace | ||
|
SteveMacenski marked this conversation as resolved.
SteveMacenski marked this conversation as resolved.
|
||
| // | ||
|
SteveMacenski marked this conversation as resolved.
|
||
| // 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. | ||
|
|
||
| #include <vector> | ||
| #include <string> | ||
|
|
||
| #include "nav2_behavior_tree/plugins/condition/globally_updated_goal_condition.hpp" | ||
|
|
||
| namespace nav2_behavior_tree | ||
| { | ||
|
|
||
| GloballyUpdatedGoalCondition::GloballyUpdatedGoalCondition( | ||
| const std::string & condition_name, | ||
| const BT::NodeConfiguration & conf) | ||
| : BT::ConditionNode(condition_name, conf), | ||
| first_time(true) | ||
| { | ||
| node_ = config().blackboard->get<rclcpp::Node::SharedPtr>("node"); | ||
| } | ||
|
|
||
| BT::NodeStatus GloballyUpdatedGoalCondition::tick() | ||
| { | ||
| if (first_time) { | ||
| first_time = false; | ||
| config().blackboard->get<std::vector<geometry_msgs::msg::PoseStamped>>("goals", goals_); | ||
| config().blackboard->get<geometry_msgs::msg::PoseStamped>("goal", goal_); | ||
| return BT::NodeStatus::FAILURE; | ||
| } | ||
|
|
||
| std::vector<geometry_msgs::msg::PoseStamped> current_goals; | ||
| config().blackboard->get<std::vector<geometry_msgs::msg::PoseStamped>>("goals", current_goals); | ||
| geometry_msgs::msg::PoseStamped current_goal; | ||
| config().blackboard->get<geometry_msgs::msg::PoseStamped>("goal", current_goal); | ||
|
|
||
| if (goal_ != current_goal || goals_ != current_goals) { | ||
| goal_ = current_goal; | ||
| goals_ = current_goals; | ||
| return BT::NodeStatus::SUCCESS; | ||
| } | ||
|
|
||
| return BT::NodeStatus::FAILURE; | ||
| } | ||
|
|
||
| } // namespace nav2_behavior_tree | ||
|
|
||
| #include "behaviortree_cpp_v3/bt_factory.h" | ||
| BT_REGISTER_NODES(factory) | ||
| { | ||
| factory.registerNodeType<nav2_behavior_tree::GloballyUpdatedGoalCondition>("GlobalUpdatedGoal"); | ||
| } | ||
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
61 changes: 61 additions & 0 deletions
61
nav2_behavior_tree/plugins/condition/is_path_valid_condition.cpp
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,61 @@ | ||
| // Copyright (c) 2021 Joshua Wallace | ||
| // | ||
| // 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. | ||
|
|
||
| #include "nav2_behavior_tree/plugins/condition/is_path_valid_condition.hpp" | ||
| #include <chrono> | ||
| #include <memory> | ||
| #include <string> | ||
|
|
||
| namespace nav2_behavior_tree | ||
| { | ||
|
|
||
| IsPathValidCondition::IsPathValidCondition( | ||
| const std::string & condition_name, | ||
| const BT::NodeConfiguration & conf) | ||
| : BT::ConditionNode(condition_name, conf) | ||
| { | ||
| node_ = config().blackboard->get<rclcpp::Node::SharedPtr>("node"); | ||
| client_ = node_->create_client<nav2_msgs::srv::IsPathValid>("is_path_valid"); | ||
|
|
||
| server_timeout_ = config().blackboard->template get<std::chrono::milliseconds>("server_timeout"); | ||
| getInput<std::chrono::milliseconds>("server_timeout", server_timeout_); | ||
| } | ||
|
|
||
| BT::NodeStatus IsPathValidCondition::tick() | ||
| { | ||
| nav_msgs::msg::Path path; | ||
| getInput("path", path); | ||
|
|
||
| auto request = std::make_shared<nav2_msgs::srv::IsPathValid::Request>(); | ||
|
|
||
| request->path = path; | ||
| auto result = client_->async_send_request(request); | ||
|
|
||
| if (rclcpp::spin_until_future_complete(node_, result, server_timeout_) == | ||
| rclcpp::FutureReturnCode::SUCCESS) | ||
| { | ||
| if (result.get()->is_valid) { | ||
| return BT::NodeStatus::SUCCESS; | ||
| } | ||
| } | ||
| return BT::NodeStatus::FAILURE; | ||
| } | ||
|
|
||
| } // namespace nav2_behavior_tree | ||
|
|
||
| #include "behaviortree_cpp_v3/bt_factory.h" | ||
| BT_REGISTER_NODES(factory) | ||
| { | ||
| factory.registerNodeType<nav2_behavior_tree::IsPathValidCondition>("IsPathValid"); | ||
| } |
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
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.
Uh oh!
There was an error while loading. Please reload this page.