Skip to content

Commit 64a7801

Browse files
committed
renaming
1 parent 3183c9d commit 64a7801

File tree

6 files changed

+91
-78
lines changed

6 files changed

+91
-78
lines changed

behaviortree_ros2/include/behaviortree_ros2/bt_utils.hpp

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -28,55 +28,61 @@
2828
#include "rclcpp/rclcpp.hpp"
2929
#include <ament_index_cpp/get_package_share_directory.hpp>
3030

31-
namespace action_server_bt
31+
namespace BT
3232
{
3333
/**
3434
* @brief Convert BT::NodeStatus into Action Server feedback message NodeStatus
35+
*
3536
* @param status Current status of the executing BehaviorTree
3637
* @return NodeStatus used to publish feedback to the Action Client
3738
*/
38-
btcpp_ros2_interfaces::msg::NodeStatus convert_node_status(BT::NodeStatus& status);
39+
btcpp_ros2_interfaces::msg::NodeStatus ConvertNodeStatus(BT::NodeStatus& status);
3940

4041
/**
4142
* @brief Function the uses ament_index_cpp to get the package path of the parameter specified by the user
43+
*
4244
* @param parameter_value String containing 'package_name/subfolder' for the directory path to look up
4345
* @return Full path to the directory specified by the parameter_value
4446
*/
45-
std::string get_directory_path(const std::string& parameter_value);
47+
std::string GetDirectoryPath(const std::string& parameter_value);
4648

4749
/**
4850
* @brief Function to load BehaviorTree xml files from a specific directory
51+
*
4952
* @param factory BehaviorTreeFactory to register the BehaviorTrees into
5053
* @param directory_path Full path to the directory to search for BehaviorTree definitions
5154
*/
52-
void load_behavior_trees(BT::BehaviorTreeFactory& factory,
53-
const std::string& directory_path);
55+
void LoadBehaviorTrees(BT::BehaviorTreeFactory& factory,
56+
const std::string& directory_path);
5457

5558
/**
5659
* @brief Function to load BehaviorTree plugins from a specific directory
60+
*
5761
* @param factory BehaviorTreeFactory to register the plugins into
5862
* @param directory_path Full path to the directory to search for BehaviorTree plugins
5963
*/
60-
void load_plugins(BT::BehaviorTreeFactory& factory, const std::string& directory_path);
64+
void LoadPlugins(BT::BehaviorTreeFactory& factory, const std::string& directory_path);
6165

6266
/**
6367
* @brief Function to load BehaviorTree ROS plugins from a specific directory
68+
*
6469
* @param factory BehaviorTreeFactory to register the plugins into
6570
* @param directory_path Full path to the directory to search for BehaviorTree plugins
6671
* @param node node pointer that is shared with the ROS based BehaviorTree plugins
6772
*/
68-
void load_ros_plugins(BT::BehaviorTreeFactory& factory, const std::string& directory_path,
69-
rclcpp::Node::SharedPtr node);
73+
void LoadRosPlugins(BT::BehaviorTreeFactory& factory, const std::string& directory_path,
74+
rclcpp::Node::SharedPtr node);
7075

7176
/**
7277
* @brief Function to register all Behaviors and BehaviorTrees from user specified packages
78+
*
7379
* @param params ROS parameters that contain lists of packages to load
7480
* plugins, ros_plugins and BehaviorTrees from
7581
* @param factory BehaviorTreeFactory to register into
7682
* @param node node pointer that is shared with the ROS based Behavior plugins
7783
*/
78-
void register_behavior_trees(action_server_bt::Params& params,
79-
BT::BehaviorTreeFactory& factory,
80-
rclcpp::Node::SharedPtr node);
84+
void RegisterBehaviorTrees(action_server_bt::Params& params,
85+
BT::BehaviorTreeFactory& factory,
86+
rclcpp::Node::SharedPtr node);
8187

82-
} // namespace action_server_bt
88+
} // namespace BT

behaviortree_ros2/include/behaviortree_ros2/tree_execution_server.hpp

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -21,34 +21,34 @@
2121
#include "rclcpp/rclcpp.hpp"
2222
#include "rclcpp_action/rclcpp_action.hpp"
2323

24-
namespace action_server_bt
24+
namespace BT
2525
{
2626

2727
/**
28-
* @brief ActionServerBT class hosts a ROS Action Server that is able
28+
* @brief TreeExecutionServer class hosts a ROS Action Server that is able
2929
* to load Behavior plugins, BehaviorTree.xml files and execute them.
3030
*/
31-
class ActionServerBT
31+
class TreeExecutionServer
3232
{
3333
public:
3434
using ExecuteTree = btcpp_ros2_interfaces::action::ExecuteTree;
3535
using GoalHandleExecuteTree = rclcpp_action::ServerGoalHandle<ExecuteTree>;
3636

3737
/**
38-
* @brief Constructor for ActionServerBT.
38+
* @brief Constructor for TreeExecutionServer.
3939
* @details This initializes a ParameterListener to read configurable options from the user and
4040
* starts an Action Server that takes requests to execute BehaviorTrees.
4141
*
4242
* @param options rclcpp::NodeOptions to pass to node_ when initializing it.
4343
* after the tree is created, while its running and after it finishes.
4444
*/
45-
explicit ActionServerBT(const rclcpp::NodeOptions& options);
45+
explicit TreeExecutionServer(const rclcpp::NodeOptions& options);
4646

47-
virtual ~ActionServerBT();
47+
virtual ~TreeExecutionServer();
4848

4949
/**
5050
* @brief Gets the NodeBaseInterface of node_.
51-
* @details This function exists to allow running ActionServerBT as a component in a composable node container.
51+
* @details This function exists to allow running TreeExecutionServer as a component in a composable node container.
5252
*
5353
* @return A shared_ptr to the NodeBaseInterface of node_.
5454
*/
@@ -64,22 +64,28 @@ class ActionServerBT
6464
BT::Blackboard::Ptr globalBlackboard();
6565

6666
protected:
67-
// To be overridden by the user.
68-
// Callback invoked when the tree is created and before it is executed,
69-
// Can be used to update the blackboard or to attach loggers.
67+
/**
68+
* @brief Callback invoked after the tree is created.
69+
* It can be used, for instance, to initialize a logger or the global blackboard.
70+
*
71+
* @param tree The tree that was created
72+
*/
7073
virtual void onTreeCreated(BT::Tree& tree)
7174
{}
7275

73-
// To be overridden by the user.
74-
// In addition to the built in mechanism to register nodes from plugins,
75-
// you can use this method to register custom nodes into the factory.
76+
/**
77+
* @brief registerNodesIntoFactory is a callback invoked after the
78+
* plugins were registered into the BT::BehaviorTreeFactory.
79+
* It can be used to register additional custom nodes manually.
80+
*
81+
* @param factory The factory to use to register nodes
82+
*/
7683
virtual void registerNodesIntoFactory(BT::BehaviorTreeFactory& factory)
7784
{}
7885

79-
// To be overridden by the user.
80-
// Callback invoked after the tickOnce.
81-
// If it returns something different than std::nullopt, the tree execution will
82-
// be halted and the returned value will be the optional NodeStatus.
86+
/**
87+
* @brief onLoopAfterTick invoked after the tree is created and before the tree is executed.
88+
*/
8389
virtual std::optional<BT::NodeStatus> onLoopAfterTick(BT::NodeStatus status)
8490
{
8591
return std::nullopt;
@@ -129,4 +135,4 @@ class ActionServerBT
129135
void execute(const std::shared_ptr<GoalHandleExecuteTree> goal_handle);
130136
};
131137

132-
} // namespace action_server_bt
138+
} // namespace BT

behaviortree_ros2/src/bt_executor_parameters.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
action_server_bt:
22
action_name: {
33
type: string,
4-
default_value: "action_server_bt",
4+
default_value: "bt_action_server",
55
read_only: true,
66
description: "The name the Action Server takes requests from",
77
}

behaviortree_ros2/src/bt_utils.cpp

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@
1515

1616
namespace
1717
{
18-
static const auto kLogger = rclcpp::get_logger("action_server_bt");
18+
static const auto kLogger = rclcpp::get_logger("bt_action_server");
1919
}
2020

21-
namespace action_server_bt
21+
namespace BT
2222
{
2323

24-
btcpp_ros2_interfaces::msg::NodeStatus convert_node_status(BT::NodeStatus& status)
24+
btcpp_ros2_interfaces::msg::NodeStatus ConvertNodeStatus(BT::NodeStatus& status)
2525
{
2626
btcpp_ros2_interfaces::msg::NodeStatus action_status;
2727
switch(status)
@@ -41,7 +41,7 @@ btcpp_ros2_interfaces::msg::NodeStatus convert_node_status(BT::NodeStatus& statu
4141
return action_status;
4242
}
4343

44-
std::string get_directory_path(const std::string& parameter_value)
44+
std::string GetDirectoryPath(const std::string& parameter_value)
4545
{
4646
std::string package_name, subfolder;
4747
auto pos = parameter_value.find_first_of("/");
@@ -70,8 +70,8 @@ std::string get_directory_path(const std::string& parameter_value)
7070
return "";
7171
}
7272

73-
void load_behavior_trees(BT::BehaviorTreeFactory& factory,
74-
const std::string& directory_path)
73+
void LoadBehaviorTrees(BT::BehaviorTreeFactory& factory,
74+
const std::string& directory_path)
7575
{
7676
using std::filesystem::directory_iterator;
7777
for(const auto& entry : directory_iterator(directory_path))
@@ -92,7 +92,7 @@ void load_behavior_trees(BT::BehaviorTreeFactory& factory,
9292
}
9393
}
9494

95-
void load_plugins(BT::BehaviorTreeFactory& factory, const std::string& directory_path)
95+
void LoadPlugins(BT::BehaviorTreeFactory& factory, const std::string& directory_path)
9696
{
9797
using std::filesystem::directory_iterator;
9898
for(const auto& entry : directory_iterator(directory_path))
@@ -113,8 +113,8 @@ void load_plugins(BT::BehaviorTreeFactory& factory, const std::string& directory
113113
}
114114
}
115115

116-
void load_ros_plugins(BT::BehaviorTreeFactory& factory, const std::string& directory_path,
117-
rclcpp::Node::SharedPtr node)
116+
void LoadRosPlugins(BT::BehaviorTreeFactory& factory, const std::string& directory_path,
117+
rclcpp::Node::SharedPtr node)
118118
{
119119
using std::filesystem::directory_iterator;
120120
BT::RosNodeParams params;
@@ -137,37 +137,36 @@ void load_ros_plugins(BT::BehaviorTreeFactory& factory, const std::string& direc
137137
}
138138
}
139139

140-
void register_behavior_trees(action_server_bt::Params& params,
141-
BT::BehaviorTreeFactory& factory,
142-
rclcpp::Node::SharedPtr node)
140+
void RegisterBehaviorTrees(action_server_bt::Params& params,
141+
BT::BehaviorTreeFactory& factory, rclcpp::Node::SharedPtr node)
143142
{
144143
// clear the factory and load/reload it with the Behaviors and Trees specified by the user in their action_server_bt config yaml
145144
factory.clearRegisteredBehaviorTrees();
146145

147146
for(const auto& plugin : params.plugins)
148147
{
149-
const auto plugin_directory = get_directory_path(plugin);
148+
const auto plugin_directory = GetDirectoryPath(plugin);
150149
// skip invalid plugins directories
151150
if(plugin_directory.empty())
152151
continue;
153-
load_plugins(factory, plugin_directory);
152+
LoadPlugins(factory, plugin_directory);
154153
}
155154
for(const auto& plugin : params.ros_plugins)
156155
{
157-
const auto plugin_directory = get_directory_path(plugin);
156+
const auto plugin_directory = GetDirectoryPath(plugin);
158157
// skip invalid plugins directories
159158
if(plugin_directory.empty())
160159
continue;
161-
load_ros_plugins(factory, plugin_directory, node);
160+
LoadRosPlugins(factory, plugin_directory, node);
162161
}
163162
for(const auto& tree_dir : params.behavior_trees)
164163
{
165-
const auto tree_directory = get_directory_path(tree_dir);
164+
const auto tree_directory = GetDirectoryPath(tree_dir);
166165
// skip invalid subtree directories
167166
if(tree_directory.empty())
168167
continue;
169-
load_behavior_trees(factory, tree_directory);
168+
LoadBehaviorTrees(factory, tree_directory);
170169
}
171170
}
172171

173-
} // namespace action_server_bt
172+
} // namespace BT

0 commit comments

Comments
 (0)