-
Notifications
You must be signed in to change notification settings - Fork 1.8k
standalone assisted teleop #2904
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 44 commits into
ros-navigation:main
from
jwallace42:standalone_assisted_teleop
Aug 25, 2022
Merged
Changes from all commits
Commits
Show all changes
44 commits
Select commit
Hold shift + click to select a range
895490b
standalone assisted teleop
jwallace42 eb84121
added in action message
jwallace42 82926e0
code review
jwallace42 819f6dd
moved to behavior server
jwallace42 4d862d3
added assisted teleop bt node
jwallace42 d94f1a5
revert
jwallace42 041f494
added bt node for assisted teleop
jwallace42 eeaae40
lint fix
jwallace42 ecd4e77
added cancel assisted teleop node
jwallace42 76d3ef9
code review
jwallace42 83ed6c6
Merge branch 'main' into standalone_assisted_teleop
jwallace42 361f945
working
jwallace42 e328e0d
cleanup
jwallace42 d6b3ee3
updated feeback
jwallace42 2d905e3
code review
jwallace42 a33c0ce
update compute velocity
jwallace42 8fe8bc3
cleanup
jwallace42 7af4216
lint fixes
jwallace42 2e9ba8c
cleanup
jwallace42 7a509e7
test fix
jwallace42 e5b123e
starting to add tests for assisted teleop
jwallace42 f3857da
Merge branch 'main' into standalone_assisted_teleop
jwallace42 c291f7f
fixed tests
jwallace42 0f515d9
undo
jwallace42 aca7e6b
Merge branch 'bt_test_fix' into standalone_assisted_teleop
jwallace42 b732b01
fixed test
jwallace42 876f37e
is_recovery
jwallace42 71cf73a
adjust abort result based on recovery or not
jwallace42 7396495
code review
jwallace42 ba31853
added preempt velocity
jwallace42 2a932f8
working preempt assisted teleop test
jwallace42 da8c297
completed assisted teleop tests
jwallace42 d162784
code review
jwallace42 f24098c
undo
jwallace42 0b6e818
code review
jwallace42 fb65669
remove sleep
jwallace42 719114c
topic rename
jwallace42 145017f
Merge branch 'main' into standalone_assisted_teleop
SteveMacenski 9abbbd7
Merge branch 'main' into standalone_assisted_teleop
SteveMacenski de3a6af
Merge branch 'main' into standalone_assisted_teleop
jwallace42 721ef4d
Merge branch 'main' into standalone_assisted_teleop
jwallace42 7d76c11
missing comma
jwallace42 29962fe
added comma :(
jwallace42 8b9e462
added comma
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
70 changes: 70 additions & 0 deletions
70
nav2_behavior_tree/include/nav2_behavior_tree/plugins/action/assisted_teleop_action.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,70 @@ | ||
| // 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__ACTION__ASSISTED_TELEOP_ACTION_HPP_ | ||
| #define NAV2_BEHAVIOR_TREE__PLUGINS__ACTION__ASSISTED_TELEOP_ACTION_HPP_ | ||
|
|
||
| #include <string> | ||
|
|
||
| #include "nav2_behavior_tree/bt_action_node.hpp" | ||
| #include "nav2_msgs/action/assisted_teleop.hpp" | ||
|
|
||
| namespace nav2_behavior_tree | ||
| { | ||
|
|
||
| /** | ||
| * @brief A nav2_behavior_tree::BtActionNode class that wraps nav2_msgs::action::AssistedTeleop | ||
| */ | ||
| class AssistedTeleopAction : public BtActionNode<nav2_msgs::action::AssistedTeleop> | ||
| { | ||
| public: | ||
| /** | ||
| * @brief A constructor for nav2_behavior_tree::nav2_msgs::action::AssistedTeleop | ||
| * @param xml_tag_name Name for the XML tag for this node | ||
| * @param action_name Action name this node creates a client for | ||
| * @param conf BT node configuration | ||
| */ | ||
| AssistedTeleopAction( | ||
| const std::string & xml_tag_name, | ||
| const std::string & action_name, | ||
| const BT::NodeConfiguration & conf); | ||
|
|
||
| /** | ||
| * @brief Function to perform some user-defined operation on tick | ||
| */ | ||
| void on_tick() override; | ||
|
|
||
| BT::NodeStatus on_aborted() override; | ||
|
|
||
| /** | ||
| * @brief Creates list of BT ports | ||
| * @return BT::PortsList Containing basic ports along with node-specific ports | ||
| */ | ||
| static BT::PortsList providedPorts() | ||
| { | ||
| return providedBasicPorts( | ||
| { | ||
| BT::InputPort<double>("time_allowance", 10.0, "Allowed time for running assisted teleop"), | ||
| BT::InputPort<bool>("is_recovery", false, "If true the recovery count will be incremented") | ||
| }); | ||
| } | ||
|
|
||
| private: | ||
| bool is_recovery_; | ||
| }; | ||
|
|
||
| } // namespace nav2_behavior_tree | ||
|
|
||
| #endif // NAV2_BEHAVIOR_TREE__PLUGINS__ACTION__ASSISTED_TELEOP_ACTION_HPP_ |
59 changes: 59 additions & 0 deletions
59
nav2_behavior_tree/include/nav2_behavior_tree/plugins/action/assisted_teleop_cancel_node.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,59 @@ | ||
| // 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__ACTION__ASSISTED_TELEOP_CANCEL_NODE_HPP_ | ||
| #define NAV2_BEHAVIOR_TREE__PLUGINS__ACTION__ASSISTED_TELEOP_CANCEL_NODE_HPP_ | ||
|
|
||
| #include <memory> | ||
| #include <string> | ||
|
|
||
| #include "nav2_msgs/action/assisted_teleop.hpp" | ||
|
|
||
| #include "nav2_behavior_tree/bt_cancel_action_node.hpp" | ||
|
|
||
| namespace nav2_behavior_tree | ||
| { | ||
|
|
||
| /** | ||
| * @brief A nav2_behavior_tree::BtActionNode class that wraps nav2_msgs::action::BackUp | ||
| */ | ||
| class AssistedTeleopCancel : public BtCancelActionNode<nav2_msgs::action::AssistedTeleop> | ||
| { | ||
| public: | ||
| /** | ||
| * @brief A constructor for nav2_behavior_tree::BackUpAction | ||
| * @param xml_tag_name Name for the XML tag for this node | ||
| * @param action_name Action name this node creates a client for | ||
| * @param conf BT node configuration | ||
| */ | ||
| AssistedTeleopCancel( | ||
| const std::string & xml_tag_name, | ||
| const std::string & action_name, | ||
| const BT::NodeConfiguration & conf); | ||
|
|
||
| /** | ||
| * @brief Creates list of BT ports | ||
| * @return BT::PortsList Containing basic ports along with node-specific ports | ||
| */ | ||
| static BT::PortsList providedPorts() | ||
| { | ||
| return providedBasicPorts( | ||
| { | ||
| }); | ||
| } | ||
| }; | ||
|
|
||
| } // namespace nav2_behavior_tree | ||
|
|
||
| #endif // NAV2_BEHAVIOR_TREE__PLUGINS__ACTION__ASSISTED_TELEOP_CANCEL_NODE_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
62 changes: 62 additions & 0 deletions
62
nav2_behavior_tree/plugins/action/assisted_teleop_action.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,62 @@ | ||
| // Copyright (c) 2022 Joshua Wallace | ||
|
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 <string> | ||
| #include <memory> | ||
|
|
||
| #include "nav2_behavior_tree/plugins/action/assisted_teleop_action.hpp" | ||
|
|
||
| namespace nav2_behavior_tree | ||
| { | ||
|
|
||
| AssistedTeleopAction::AssistedTeleopAction( | ||
| const std::string & xml_tag_name, | ||
| const std::string & action_name, | ||
| const BT::NodeConfiguration & conf) | ||
| : BtActionNode<nav2_msgs::action::AssistedTeleop>(xml_tag_name, action_name, conf) | ||
| { | ||
| double time_allowance; | ||
| getInput("time_allowance", time_allowance); | ||
| getInput("is_recovery", is_recovery_); | ||
|
|
||
| // Populate the input message | ||
| goal_.time_allowance = rclcpp::Duration::from_seconds(time_allowance); | ||
| } | ||
|
|
||
| void AssistedTeleopAction::on_tick() | ||
| { | ||
| if (is_recovery_) { | ||
| increment_recovery_count(); | ||
| } | ||
| } | ||
|
|
||
|
SteveMacenski marked this conversation as resolved.
|
||
| BT::NodeStatus AssistedTeleopAction::on_aborted() | ||
| { | ||
| return is_recovery_ ? BT::NodeStatus::FAILURE : BT::NodeStatus::SUCCESS; | ||
| } | ||
|
|
||
| } // namespace nav2_behavior_tree | ||
|
|
||
| #include "behaviortree_cpp_v3/bt_factory.h" | ||
| BT_REGISTER_NODES(factory) | ||
| { | ||
| BT::NodeBuilder builder = | ||
| [](const std::string & name, const BT::NodeConfiguration & config) | ||
| { | ||
| return std::make_unique<nav2_behavior_tree::AssistedTeleopAction>( | ||
| name, "assisted_teleop", config); | ||
| }; | ||
|
|
||
| factory.registerBuilder<nav2_behavior_tree::AssistedTeleopAction>("AssistedTeleop", builder); | ||
| } | ||
47 changes: 47 additions & 0 deletions
47
nav2_behavior_tree/plugins/action/assisted_teleop_cancel_node.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,47 @@ | ||
| // 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 <string> | ||
| #include <memory> | ||
|
|
||
| #include "std_msgs/msg/string.hpp" | ||
|
|
||
| #include "nav2_behavior_tree/plugins/action/assisted_teleop_cancel_node.hpp" | ||
|
|
||
| namespace nav2_behavior_tree | ||
|
SteveMacenski marked this conversation as resolved.
|
||
| { | ||
|
|
||
| AssistedTeleopCancel::AssistedTeleopCancel( | ||
| const std::string & xml_tag_name, | ||
| const std::string & action_name, | ||
| const BT::NodeConfiguration & conf) | ||
| : BtCancelActionNode<nav2_msgs::action::AssistedTeleop>(xml_tag_name, action_name, conf) | ||
| { | ||
| } | ||
|
|
||
| } // namespace nav2_behavior_tree | ||
|
|
||
| #include "behaviortree_cpp_v3/bt_factory.h" | ||
| BT_REGISTER_NODES(factory) | ||
| { | ||
| BT::NodeBuilder builder = | ||
| [](const std::string & name, const BT::NodeConfiguration & config) | ||
| { | ||
| return std::make_unique<nav2_behavior_tree::AssistedTeleopCancel>( | ||
| name, "assisted_teleop", config); | ||
| }; | ||
|
|
||
| factory.registerBuilder<nav2_behavior_tree::AssistedTeleopCancel>( | ||
| "CancelAssistedTeleop", builder); | ||
| } | ||
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.