-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #60 from BehaviorTree/bt_server
Action Server to execute trees
- Loading branch information
Showing
26 changed files
with
1,197 additions
and
19 deletions.
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
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,74 @@ | ||
# Bt Server Parameters | ||
|
||
Default Config | ||
```yaml | ||
bt_server: | ||
ros__parameters: | ||
action_name: bt_execution | ||
behavior_trees: '{}' | ||
groot2_port: 1667.0 | ||
plugins: '{}' | ||
ros_plugins_timeout: 1000.0 | ||
tick_frequency: 100.0 | ||
|
||
``` | ||
|
||
## action_name | ||
|
||
The name the Action Server takes requests from | ||
|
||
* Type: `string` | ||
* Default Value: "bt_execution" | ||
* Read only: True | ||
|
||
## tick_frequency | ||
|
||
Frequency in Hz to tick() the Behavior tree at | ||
|
||
* Type: `int` | ||
* Default Value: 100 | ||
* Read only: True | ||
|
||
*Constraints:* | ||
- parameter must be within bounds 1 | ||
|
||
## groot2_port | ||
|
||
Server port value to publish Groot2 messages on | ||
|
||
* Type: `int` | ||
* Default Value: 1667 | ||
* Read only: True | ||
|
||
*Constraints:* | ||
- parameter must be within bounds 1 | ||
|
||
## plugins | ||
|
||
List of 'package_name/subfolder' containing BehaviorTree plugins to load into the factory | ||
|
||
* Type: `string_array` | ||
* Default Value: {} | ||
|
||
*Constraints:* | ||
- contains no duplicates | ||
|
||
## ros_plugins_timeout | ||
|
||
Timeout (ms) used in BT::RosNodeParams | ||
|
||
* Type: `int` | ||
* Default Value: 1000 | ||
|
||
*Constraints:* | ||
- parameter must be within bounds 1 | ||
|
||
## behavior_trees | ||
|
||
List of 'package_name/subfolder' containing SubTrees to load into the BehaviorTree factory | ||
|
||
* Type: `string_array` | ||
* Default Value: {} | ||
|
||
*Constraints:* | ||
- contains no duplicates |
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,79 @@ | ||
// Copyright 2024 Marq Rasmussen | ||
// | ||
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated | ||
// documentation files (the "Software"), to deal in the Software without restriction, including without limitation the | ||
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to | ||
// permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright | ||
// notice and this permission notice shall be included in all copies or substantial portions of the Software. | ||
// | ||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE | ||
// WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR | ||
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR | ||
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
|
||
#include <functional> | ||
#include <memory> | ||
#include <thread> | ||
|
||
// auto-generated header, created by generate_parameter_library | ||
#include "bt_executor_parameters.hpp" | ||
|
||
#include "btcpp_ros2_interfaces/msg/node_status.hpp" | ||
|
||
#include "behaviortree_cpp/bt_factory.h" | ||
|
||
#include "behaviortree_ros2/plugins.hpp" | ||
#include "behaviortree_ros2/ros_node_params.hpp" | ||
|
||
#include "rclcpp/rclcpp.hpp" | ||
#include <ament_index_cpp/get_package_share_directory.hpp> | ||
|
||
namespace BT | ||
{ | ||
/** | ||
* @brief Convert BT::NodeStatus into Action Server feedback message NodeStatus | ||
* | ||
* @param status Current status of the executing BehaviorTree | ||
* @return NodeStatus used to publish feedback to the Action Client | ||
*/ | ||
btcpp_ros2_interfaces::msg::NodeStatus ConvertNodeStatus(BT::NodeStatus& status); | ||
|
||
/** | ||
* @brief Function the uses ament_index_cpp to get the package path of the parameter specified by the user | ||
* | ||
* @param parameter_value String containing 'package_name/subfolder' for the directory path to look up | ||
* @return Full path to the directory specified by the parameter_value | ||
*/ | ||
std::string GetDirectoryPath(const std::string& parameter_value); | ||
|
||
/** | ||
* @brief Function to load BehaviorTree xml files from a specific directory | ||
* | ||
* @param factory BehaviorTreeFactory to register the BehaviorTrees into | ||
* @param directory_path Full path to the directory to search for BehaviorTree definitions | ||
*/ | ||
void LoadBehaviorTrees(BT::BehaviorTreeFactory& factory, | ||
const std::string& directory_path); | ||
|
||
/** | ||
* @brief Function to load BehaviorTree ROS plugins (or standard BT.CPP plugins) from a specific directory | ||
* | ||
* @param factory BehaviorTreeFactory to register the plugins into | ||
* @param directory_path Full path to the directory to search for BehaviorTree plugins | ||
* @param params parameters passed to the ROS plugins | ||
*/ | ||
void LoadRosPlugins(BT::BehaviorTreeFactory& factory, const std::string& directory_path, | ||
BT::RosNodeParams params); | ||
|
||
/** | ||
* @brief Function to register all Behaviors and BehaviorTrees from user specified packages | ||
* | ||
* @param params ROS parameters that contain lists of packages to load | ||
* plugins, ros_plugins and BehaviorTrees from | ||
* @param factory BehaviorTreeFactory to register into | ||
* @param node node pointer that is shared with the ROS based Behavior plugins | ||
*/ | ||
void RegisterBehaviorTrees(bt_server::Params& params, BT::BehaviorTreeFactory& factory, | ||
rclcpp::Node::SharedPtr node); | ||
|
||
} // namespace BT |
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.