-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Added goal updated condition node #1712
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
Changes from all commits
20363e1
e815166
67fcea6
755e759
1ce446e
7651dc2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,71 @@ | ||
| // Copyright (c) 2020 Aitor Miguel Blanco | ||
| // | ||
| // 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__GOAL_UPDATED_CONDITION_HPP_ | ||
| #define NAV2_BEHAVIOR_TREE__GOAL_UPDATED_CONDITION_HPP_ | ||
|
|
||
| #include <string> | ||
|
|
||
| #include "behaviortree_cpp_v3/condition_node.h" | ||
| #include "geometry_msgs/msg/pose_stamped.hpp" | ||
|
|
||
| namespace nav2_behavior_tree | ||
| { | ||
|
|
||
| class GoalUpdatedCondition : public BT::ConditionNode | ||
| { | ||
| public: | ||
| GoalUpdatedCondition( | ||
| const std::string & condition_name, | ||
| const BT::NodeConfiguration & conf) | ||
| : BT::ConditionNode(condition_name, conf) | ||
| { | ||
| } | ||
|
|
||
| GoalUpdatedCondition() = delete; | ||
|
|
||
| BT::NodeStatus tick() override | ||
| { | ||
| if (status() == BT::NodeStatus::IDLE) { | ||
SteveMacenski marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| goal_ = config().blackboard->get<geometry_msgs::msg::PoseStamped>("goal"); | ||
| return BT::NodeStatus::FAILURE; | ||
| } | ||
|
|
||
| auto current_goal = config().blackboard->get<geometry_msgs::msg::PoseStamped>("goal"); | ||
| if (goal_ != current_goal) { | ||
| goal_ = current_goal; | ||
| return BT::NodeStatus::SUCCESS; | ||
| } | ||
|
|
||
| return BT::NodeStatus::FAILURE; | ||
| } | ||
|
|
||
| static BT::PortsList providedPorts() | ||
| { | ||
| return {}; | ||
| } | ||
|
|
||
| private: | ||
| geometry_msgs::msg::PoseStamped goal_; | ||
| }; | ||
|
|
||
| } // namespace nav2_behavior_tree | ||
|
|
||
| #include "behaviortree_cpp_v3/bt_factory.h" | ||
| BT_REGISTER_NODES(factory) | ||
| { | ||
| factory.registerNodeType<nav2_behavior_tree::GoalUpdatedCondition>("GoalUpdated"); | ||
| } | ||
|
|
||
| #endif // NAV2_BEHAVIOR_TREE__GOAL_UPDATED_CONDITION_HPP_ | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,12 +18,15 @@ | |
| <ClearEntireCostmap name="ClearLocalCostmap-Context" service_name="local_costmap/clear_entirely_local_costmap"/> | ||
| </RecoveryNode> | ||
| </PipelineSequence> | ||
| <SequenceStar name="RecoveryActions"> | ||
| <ClearEntireCostmap name="ClearLocalCostmap-Subtree" service_name="local_costmap/clear_entirely_local_costmap"/> | ||
| <ClearEntireCostmap name="ClearGlobalCostmap-Subtree" service_name="global_costmap/clear_entirely_global_costmap"/> | ||
| <Spin spin_dist="1.57"/> | ||
| <Wait wait_duration="5"/> | ||
| </SequenceStar> | ||
| <ReactiveFallback name="RecoveryFallback"> | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you generate images of these for the PR?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I added them in the PR description, should I include them somewhere else? I'm thinking on spending some time going through our documentation for the bt, maybe I could also include them somewhere in the docs?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, that could be good. Anywhere that you see a BT diagram that you have now changed in this PR you should update. But it looks like you did that already?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think that's done, yes. |
||
| <GoalUpdated/> | ||
| <SequenceStar name="RecoveryActions"> | ||
| <ClearEntireCostmap name="ClearLocalCostmap-Subtree" service_name="local_costmap/clear_entirely_local_costmap"/> | ||
| <ClearEntireCostmap name="ClearGlobalCostmap-Subtree" service_name="global_costmap/clear_entirely_global_costmap"/> | ||
| <Spin spin_dist="1.57"/> | ||
| <Wait wait_duration="5"/> | ||
| </SequenceStar> | ||
| </ReactiveFallback> | ||
| </RecoveryNode> | ||
| </BehaviorTree> | ||
| </root> | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -57,6 +57,7 @@ | |
| "IsStuck", | ||
| "GoalReached", | ||
| "initialPoseReceived", | ||
| "GoalUpdated", | ||
| ] | ||
|
|
||
| def main(): | ||
|
|
||
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.
Can you add to the readme for BT navigator about how to implement preemption using this workflow? And then show examples of a tree using this to do a preemption, I think its important to make it explicitly clear to BT designers their needs for getting this behavior. The planning and recovery cases make good case studies.
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.
Yes! I knew I was forgetting something.