Skip to content

Commit ce629ea

Browse files
authored
WMO-56730 Adjust pallet goal action and bt node (#19)
* create action and node * add behavior tree
1 parent 542c725 commit ce629ea

File tree

10 files changed

+145
-2
lines changed

10 files changed

+145
-2
lines changed

doc/parameters/param_list.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
| Parameter | Default | Description |
66
| ----------| --------| ------------|
77
| default_bt_xml_filename | N/A | path to the default behavior tree XML description |
8-
| plugin_lib_names | ["nav2_compute_path_to_pose_action_bt_node", "nav2_compute_waypoints_to_pose_action_bt_node", "nav2_compute_path_along_waypoints_action_bt_node", "nav2_find_free_goal_on_path_action_bt_node", "nav2_follow_path_action_bt_node", "nav2_back_up_action_bt_node", "nav2_spin_action_bt_node", "nav2_wait_action_bt_node", "nav2_clear_costmap_service_bt_node", "nav2_path_empty_condition_bt_node", "nav2_is_stuck_condition_bt_node", "nav2_goal_reached_condition_bt_node", "nav2_initial_pose_received_condition_bt_node", "nav2_goal_updated_condition_bt_node", "nav2_reinitialize_global_localization_service_bt_node", "nav2_rate_controller_bt_node", "nav2_distance_controller_bt_node", "nav2_recovery_node_bt_node", "nav2_pipeline_sequence_bt_node", "nav2_round_robin_node_bt_node", "nav2_transform_available_condition_bt_node"] | list of behavior tree node shared libraries |
8+
| plugin_lib_names | ["nav2_adjust_pallet_goal_action_bt_node", "nav2_compute_path_to_pose_action_bt_node", "nav2_compute_waypoints_to_pose_action_bt_node", "nav2_compute_path_along_waypoints_action_bt_node", "nav2_find_free_goal_on_path_action_bt_node", "nav2_follow_path_action_bt_node", "nav2_back_up_action_bt_node", "nav2_spin_action_bt_node", "nav2_wait_action_bt_node", "nav2_clear_costmap_service_bt_node", "nav2_path_empty_condition_bt_node", "nav2_is_stuck_condition_bt_node", "nav2_goal_reached_condition_bt_node", "nav2_initial_pose_received_condition_bt_node", "nav2_goal_updated_condition_bt_node", "nav2_reinitialize_global_localization_service_bt_node", "nav2_rate_controller_bt_node", "nav2_distance_controller_bt_node", "nav2_recovery_node_bt_node", "nav2_pipeline_sequence_bt_node", "nav2_round_robin_node_bt_node", "nav2_transform_available_condition_bt_node"] | list of behavior tree node shared libraries |
99
| transform_tolerance | 0.1 | TF transform tolerance |
1010
| global_frame | "map" | Reference frame |
1111
| robot_base_frame | "base_link" | Robot base frame |

nav2_behavior_tree/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ ament_target_dependencies(${library_name}
5555
add_library(nav2_compute_path_to_pose_action_bt_node SHARED plugins/action/compute_path_to_pose_action.cpp)
5656
list(APPEND plugin_libs nav2_compute_path_to_pose_action_bt_node)
5757

58+
add_library(nav2_adjust_pallet_goal_action_bt_node SHARED plugins/action/adjust_pallet_goal_action.cpp)
59+
list(APPEND plugin_libs nav2_adjust_pallet_goal_action_bt_node)
60+
5861
add_library(nav2_compute_path_to_pose_python_action_bt_node SHARED plugins/action/compute_path_to_pose_python_action.cpp)
5962
list(APPEND plugin_libs nav2_compute_path_to_pose_python_action_bt_node)
6063

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
// Copyright (c) 2018 Intel Corporation
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
#ifndef NAV2_BEHAVIOR_TREE__PLUGINS__ACTION__ADJUST_PALLET_GOAL_ACTION_HPP_
16+
#define NAV2_BEHAVIOR_TREE__PLUGINS__ACTION__ADJUST_PALLET_GOAL_ACTION_HPP_
17+
18+
#include <string>
19+
20+
#include "nav2_msgs/action/adjust_pallet_goal.hpp"
21+
#include "nav_msgs/msg/path.h"
22+
#include "nav2_behavior_tree/bt_action_node.hpp"
23+
24+
namespace nav2_behavior_tree
25+
{
26+
27+
class AdjustPalletGoalAction : public BtActionNode<nav2_msgs::action::AdjustPalletGoal>
28+
{
29+
public:
30+
AdjustPalletGoalAction(
31+
const std::string & xml_tag_name,
32+
const std::string & action_name,
33+
const BT::NodeConfiguration & conf);
34+
35+
void on_tick() override;
36+
37+
BT::NodeStatus on_success() override;
38+
39+
static BT::PortsList providedPorts()
40+
{
41+
return providedBasicPorts(
42+
{
43+
BT::OutputPort<geometry_msgs::msg::PoseStamped>("goal", "Adjusted goal"),
44+
BT::InputPort<geometry_msgs::msg::PoseStamped>("input_goal", "Input goal that should be adjusted"),
45+
});
46+
}
47+
48+
private:
49+
bool first_time_{true};
50+
};
51+
52+
} // namespace nav2_behavior_tree
53+
54+
#endif // NAV2_BEHAVIOR_TREE__PLUGINS__ACTION__ADJUST_PALLET_GOAL_ACTION_HPP_

nav2_behavior_tree/nav2_tree_nodes.xml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,10 @@
2828
<input_port name="planner_id"/>
2929
</Action>
3030

31-
31+
<Action ID="AdjustPalletGoal">
32+
<input_port name="input_goal">Input goal that should be adjusted</input_port>
33+
<output_port name="goal">Adjusted goal</output_port>
34+
</Action>
3235

3336
<Action ID="ComputeWaypointsToPose">
3437
<input_port name="goal">Destination to plan to</input_port>
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
// Copyright (c) 2018 Intel Corporation
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
#include <memory>
16+
#include <string>
17+
18+
#include "nav2_behavior_tree/plugins/action/adjust_pallet_goal_action.hpp"
19+
20+
namespace nav2_behavior_tree
21+
{
22+
23+
AdjustPalletGoalAction::AdjustPalletGoalAction(
24+
const std::string & xml_tag_name,
25+
const std::string & action_name,
26+
const BT::NodeConfiguration & conf)
27+
: BtActionNode<nav2_msgs::action::AdjustPalletGoal>(xml_tag_name, action_name, conf)
28+
{
29+
}
30+
31+
void AdjustPalletGoalAction::on_tick()
32+
{
33+
getInput("input_goal", goal_.input_goal);
34+
}
35+
36+
BT::NodeStatus AdjustPalletGoalAction::on_success()
37+
{
38+
setOutput("goal", result_.result->pose);
39+
return BT::NodeStatus::SUCCESS;
40+
}
41+
42+
} // namespace nav2_behavior_tree
43+
44+
#include "behaviortree_cpp_v3/bt_factory.h"
45+
BT_REGISTER_NODES(factory)
46+
{
47+
BT::NodeBuilder builder =
48+
[](const std::string & name, const BT::NodeConfiguration & config)
49+
{
50+
return std::make_unique<nav2_behavior_tree::AdjustPalletGoalAction>(
51+
name, "adjust_pallet_goal", config);
52+
};
53+
54+
factory.registerBuilder<nav2_behavior_tree::AdjustPalletGoalAction>(
55+
"AdjustPalletGoal", builder);
56+
}

nav2_bringup/bringup/params/forklift_params.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ bt_navigator:
127127
odom_topic: /odom
128128
default_bt_xml_filename: "/code/ros2_ws/src/navigation2/nav2_bt_navigator/behavior_trees/navigate_w_replanning_v1.xml"
129129
plugin_lib_names:
130+
- nav2_adjust_pallet_goal_action_bt_node
130131
- nav2_compute_path_to_pose_action_bt_node
131132
- nav2_compute_path_to_pose_python_action_bt_node
132133
- nav2_compute_waypoints_to_pose_action_bt_node
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<!--
2+
This Behavior Tree drives between pallets, and continously searches for the final destination
3+
-->
4+
5+
<root main_tree_to_execute="MainTree">
6+
<BehaviorTree ID="MainTree">
7+
<PipelineSequence name="DriveBetweenPallets">
8+
<RateController hz="1.0">
9+
<Sequence name="AdjustAndReplan">
10+
<AdjustPalletGoal input_goal="{goal}" goal="{adjusted_goal}"/>
11+
<ComputePathToPosePython goal="{adjusted_goal}" path="{path}" planner_id="GridBased"/>
12+
</Sequence>
13+
</RateController>
14+
<FollowPath path="{path}" controller_id="DynamicFollowPath"/>
15+
</PipelineSequence>
16+
</BehaviorTree>
17+
</root>

nav2_bt_navigator/src/bt_navigator.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ BtNavigator::BtNavigator()
3737
RCLCPP_INFO(get_logger(), "Creating");
3838

3939
const std::vector<std::string> plugin_libs = {
40+
"nav2_adjust_pallet_goal_action_bt_node",
4041
"nav2_compute_path_to_pose_action_bt_node",
4142
"nav2_compute_path_to_pose_python_action_bt_node",
4243
"nav2_compute_waypoints_to_pose_action_bt_node",

nav2_msgs/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ rosidl_generate_interfaces(${PROJECT_NAME}
2929
"srv/SaveMap.srv"
3030
"action/BackUp.action"
3131
"action/ComputePathToPose.action"
32+
"action/AdjustPalletGoal.action"
3233
"action/ComputeWaypointsToPose.action"
3334
"action/ComputePathAlongWaypoints.action"
3435
"action/FindFreeGoalOnPath.action"
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#goal definition
2+
geometry_msgs/PoseStamped input_goal
3+
---
4+
#result definition
5+
geometry_msgs/PoseStamped pose
6+
---
7+
#feedback

0 commit comments

Comments
 (0)