-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Behavior Tree uses Error Codes #3324
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
SteveMacenski
merged 35 commits into
ros-navigation:main
from
jwallace42:bt_uses_error_codes
Jan 10, 2023
Merged
Changes from all commits
Commits
Show all changes
35 commits
Select commit
Hold shift + click to select a range
073a0f6
rough outline for condition node
34b0742
completed error code condition
9c4430a
behavior tree with error codes
59cdada
created generic code ex
0e09faa
test for error_code_condition
b6edc0f
generic error code bt node
8f9baff
remove error code condition
3da4740
updates
dbec469
updated error code condition
6354a0c
would a controller recovery help
b9f9565
rename
7c4a850
added planner recovery condition
4df6348
initial draft
ec0744a
complete with one error code as input
8d3469c
revert cmake
4351d39
bt conversion test
f0d77fc
code review
f8f9efb
code review
4f08804
code review
a1c47ea
refactor behavior tree tests
478b2ad
cleanup
2d66b29
final cleanup
0cfa26f
uncomment
5bcfcd5
removed logger
d20f8b8
function header update
63be7ef
Merge branch 'main' into bt_uses_error_codes
fc54e30
update bt to include would a planner recovery help
4184d92
copyright cleanup
ed22975
added bt node for smoother recovery
062f3ed
smoother test
761e8d6
costmap filter test fix
c5ffdc1
remove include
8d4a26f
test if commit counted
jwallace42 d71cd5b
update copyright
jwallace42 723d38a
code review
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
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
69 changes: 69 additions & 0 deletions
69
...r_tree/include/nav2_behavior_tree/plugins/condition/are_error_codes_present_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,69 @@ | ||
| // Copyright (c) 2022 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__ARE_ERROR_CODES_PRESENT_CONDITION_HPP_ | ||
| #define NAV2_BEHAVIOR_TREE__PLUGINS__CONDITION__ARE_ERROR_CODES_PRESENT_CONDITION_HPP_ | ||
|
|
||
| #include <string> | ||
| #include <memory> | ||
| #include <vector> | ||
| #include <set> | ||
|
|
||
| #include "rclcpp/rclcpp.hpp" | ||
| #include "behaviortree_cpp_v3/condition_node.h" | ||
|
|
||
| namespace nav2_behavior_tree | ||
| { | ||
|
|
||
| class AreErrorCodesPresent : public BT::ConditionNode | ||
| { | ||
| public: | ||
| AreErrorCodesPresent( | ||
| const std::string & condition_name, | ||
| const BT::NodeConfiguration & conf) | ||
| : BT::ConditionNode(condition_name, conf) | ||
| { | ||
| getInput<std::set<unsigned short>>("error_codes_to_check", error_codes_to_check_); //NOLINT | ||
| } | ||
|
|
||
| AreErrorCodesPresent() = delete; | ||
|
|
||
| BT::NodeStatus tick() | ||
| { | ||
| getInput<unsigned short>("error_code", error_code_); //NOLINT | ||
|
|
||
| if (error_codes_to_check_.find(error_code_) != error_codes_to_check_.end()) { | ||
| return BT::NodeStatus::SUCCESS; | ||
| } | ||
|
|
||
| return BT::NodeStatus::FAILURE; | ||
| } | ||
|
|
||
| static BT::PortsList providedPorts() | ||
| { | ||
| return | ||
| { | ||
| BT::InputPort<unsigned short>("error_code", "The active error codes"), //NOLINT | ||
| BT::InputPort<std::set<unsigned short>>("error_codes_to_check", "Error codes to check")//NOLINT | ||
| }; | ||
| } | ||
|
|
||
| protected: | ||
| unsigned short error_code_; //NOLINT | ||
| std::set<unsigned short> error_codes_to_check_; //NOLINT | ||
| }; | ||
|
|
||
| } // namespace nav2_behavior_tree | ||
|
|
||
| #endif // NAV2_BEHAVIOR_TREE__PLUGINS__CONDITION__ARE_ERROR_CODES_PRESENT_CONDITION_HPP_ |
40 changes: 40 additions & 0 deletions
40
...clude/nav2_behavior_tree/plugins/condition/would_a_controller_recovery_help_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,40 @@ | ||
| // Copyright (c) 2022 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__WOULD_A_CONTROLLER_RECOVERY_HELP_CONDITION_HPP_ | ||
| #define NAV2_BEHAVIOR_TREE__PLUGINS__CONDITION__WOULD_A_CONTROLLER_RECOVERY_HELP_CONDITION_HPP_ | ||
|
|
||
| #include <string> | ||
|
|
||
| #include "nav2_msgs/action/follow_path.hpp" | ||
| #include "nav2_behavior_tree/plugins/condition/are_error_codes_present_condition.hpp" | ||
|
|
||
| namespace nav2_behavior_tree | ||
| { | ||
|
|
||
| class WouldAControllerRecoveryHelp : public AreErrorCodesPresent | ||
| { | ||
| using Action = nav2_msgs::action::FollowPath; | ||
| using ActionGoal = Action::Goal; | ||
|
|
||
| public: | ||
| WouldAControllerRecoveryHelp( | ||
| const std::string & condition_name, | ||
| const BT::NodeConfiguration & conf); | ||
|
|
||
| WouldAControllerRecoveryHelp() = delete; | ||
| }; | ||
|
|
||
| } // namespace nav2_behavior_tree | ||
| #endif // NAV2_BEHAVIOR_TREE__PLUGINS__CONDITION__WOULD_A_CONTROLLER_RECOVERY_HELP_CONDITION_HPP_ | ||
40 changes: 40 additions & 0 deletions
40
.../include/nav2_behavior_tree/plugins/condition/would_a_planner_recovery_help_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,40 @@ | ||
| // Copyright (c) 2022 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__WOULD_A_PLANNER_RECOVERY_HELP_CONDITION_HPP_ | ||
| #define NAV2_BEHAVIOR_TREE__PLUGINS__CONDITION__WOULD_A_PLANNER_RECOVERY_HELP_CONDITION_HPP_ | ||
|
|
||
| #include <string> | ||
|
|
||
| #include "nav2_msgs/action/compute_path_to_pose.hpp" | ||
| #include "nav2_behavior_tree/plugins/condition/are_error_codes_present_condition.hpp" | ||
|
|
||
| namespace nav2_behavior_tree | ||
| { | ||
|
|
||
| class WouldAPlannerRecoveryHelp : public AreErrorCodesPresent | ||
| { | ||
| using Action = nav2_msgs::action::ComputePathToPose; | ||
| using ActionGoal = Action::Goal; | ||
|
|
||
| public: | ||
| WouldAPlannerRecoveryHelp( | ||
| const std::string & condition_name, | ||
| const BT::NodeConfiguration & conf); | ||
|
|
||
| WouldAPlannerRecoveryHelp() = delete; | ||
| }; | ||
|
|
||
| } // namespace nav2_behavior_tree | ||
| #endif // NAV2_BEHAVIOR_TREE__PLUGINS__CONDITION__WOULD_A_PLANNER_RECOVERY_HELP_CONDITION_HPP_ |
42 changes: 42 additions & 0 deletions
42
...include/nav2_behavior_tree/plugins/condition/would_a_smoother_recovery_help_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,42 @@ | ||
| // Copyright (c) 2023 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 | ||
SteveMacenski marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| // 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__WOULD_A_SMOOTHER_RECOVERY_HELP_CONDITION_HPP_ | ||
| #define NAV2_BEHAVIOR_TREE__PLUGINS__CONDITION__WOULD_A_SMOOTHER_RECOVERY_HELP_CONDITION_HPP_ | ||
|
|
||
|
|
||
| #include <string> | ||
|
|
||
| #include "nav2_msgs/action/smooth_path.hpp" | ||
| #include "nav2_behavior_tree/plugins/condition/are_error_codes_present_condition.hpp" | ||
|
|
||
| namespace nav2_behavior_tree | ||
| { | ||
|
|
||
| class WouldASmootherRecoveryHelp : public AreErrorCodesPresent | ||
| { | ||
| using Action = nav2_msgs::action::SmoothPath; | ||
| using ActionGoal = Action::Goal; | ||
|
|
||
| public: | ||
| WouldASmootherRecoveryHelp( | ||
| const std::string & condition_name, | ||
| const BT::NodeConfiguration & conf); | ||
|
|
||
| WouldASmootherRecoveryHelp() = delete; | ||
| }; | ||
|
|
||
| } // namespace nav2_behavior_tree | ||
|
|
||
| #endif // NAV2_BEHAVIOR_TREE__PLUGINS__CONDITION__WOULD_A_SMOOTHER_RECOVERY_HELP_CONDITION_HPP_ | ||
22 changes: 22 additions & 0 deletions
22
nav2_behavior_tree/plugins/condition/are_error_codes_present_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,22 @@ | ||
| // Copyright (c) 2023 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/are_error_codes_present_condition.hpp" | ||
|
|
||
| #include "behaviortree_cpp_v3/bt_factory.h" | ||
| BT_REGISTER_NODES(factory) | ||
| { | ||
| factory.registerNodeType<nav2_behavior_tree::AreErrorCodesPresent>( | ||
| "AreErrorCodesPresent"); | ||
| } |
41 changes: 41 additions & 0 deletions
41
nav2_behavior_tree/plugins/condition/would_a_controller_recovery_help_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,41 @@ | ||
| // Copyright (c) 2022 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/would_a_controller_recovery_help_condition.hpp" | ||
| #include <memory> | ||
|
|
||
| namespace nav2_behavior_tree | ||
| { | ||
|
|
||
| WouldAControllerRecoveryHelp::WouldAControllerRecoveryHelp( | ||
SteveMacenski marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| const std::string & condition_name, | ||
| const BT::NodeConfiguration & conf) | ||
| : AreErrorCodesPresent(condition_name, conf) | ||
| { | ||
| error_codes_to_check_ = { | ||
| ActionGoal::UNKNOWN, | ||
| ActionGoal::PATIENCE_EXCEEDED, | ||
| ActionGoal::FAILED_TO_MAKE_PROGRESS, | ||
| ActionGoal::NO_VALID_CONTROL | ||
| }; | ||
| } | ||
|
|
||
| } // namespace nav2_behavior_tree | ||
|
|
||
| #include "behaviortree_cpp_v3/bt_factory.h" | ||
| BT_REGISTER_NODES(factory) | ||
| { | ||
| factory.registerNodeType<nav2_behavior_tree::WouldAControllerRecoveryHelp>( | ||
| "WouldAControllerRecoveryHelp"); | ||
| } | ||
40 changes: 40 additions & 0 deletions
40
nav2_behavior_tree/plugins/condition/would_a_planner_recovery_help_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,40 @@ | ||
| // Copyright (c) 2022 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/would_a_planner_recovery_help_condition.hpp" | ||
| #include <memory> | ||
|
|
||
| namespace nav2_behavior_tree | ||
| { | ||
|
|
||
| WouldAPlannerRecoveryHelp::WouldAPlannerRecoveryHelp( | ||
| const std::string & condition_name, | ||
| const BT::NodeConfiguration & conf) | ||
| : AreErrorCodesPresent(condition_name, conf) | ||
| { | ||
| error_codes_to_check_ = { | ||
| ActionGoal::UNKNOWN, | ||
| ActionGoal::NO_VALID_PATH, | ||
| ActionGoal::TIMEOUT | ||
| }; | ||
| } | ||
|
|
||
| } // namespace nav2_behavior_tree | ||
|
|
||
| #include "behaviortree_cpp_v3/bt_factory.h" | ||
| BT_REGISTER_NODES(factory) | ||
| { | ||
| factory.registerNodeType<nav2_behavior_tree::WouldAPlannerRecoveryHelp>( | ||
| "WouldAPlannerRecoveryHelp"); | ||
| } |
41 changes: 41 additions & 0 deletions
41
nav2_behavior_tree/plugins/condition/would_a_smoother_recovery_help_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,41 @@ | ||
| // Copyright (c) 2023 Joshua Wallace | ||
SteveMacenski marked this conversation as resolved.
Show resolved
Hide 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 "nav2_behavior_tree/plugins/condition/would_a_smoother_recovery_help_condition.hpp" | ||
| #include <memory> | ||
|
|
||
| namespace nav2_behavior_tree | ||
| { | ||
|
|
||
| WouldASmootherRecoveryHelp::WouldASmootherRecoveryHelp( | ||
| const std::string & condition_name, | ||
| const BT::NodeConfiguration & conf) | ||
| : AreErrorCodesPresent(condition_name, conf) | ||
| { | ||
| error_codes_to_check_ = { | ||
| ActionGoal::UNKNOWN, | ||
| ActionGoal::TIMEOUT, | ||
| ActionGoal::FAILED_TO_SMOOTH_PATH, | ||
| ActionGoal::SMOOTHED_PATH_IN_COLLISION | ||
| }; | ||
| } | ||
|
|
||
| } // namespace nav2_behavior_tree | ||
|
|
||
| #include "behaviortree_cpp_v3/bt_factory.h" | ||
| BT_REGISTER_NODES(factory) | ||
| { | ||
| factory.registerNodeType<nav2_behavior_tree::WouldASmootherRecoveryHelp>( | ||
| "WouldASmootherRecoveryHelp"); | ||
| } | ||
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.