Skip to content

Commit 7e28106

Browse files
authored
AMRFM-1350: Decide whether pickup location is wrapping machine or standard pickup (ros-navigation#237)
* CheckBinType condition node * For Brummer, only check whether bin_id = 2518_1 for roller_belt
1 parent e5cb22c commit 7e28106

File tree

7 files changed

+119
-2
lines changed

7 files changed

+119
-2
lines changed

doc/parameters/param_list.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
| enable_groot_monitoring | True | enable Groot live monitoring of the behavior tree |
99
| groot_zmq_publisher_port | 1666 | change port of the zmq publisher needed for groot |
1010
| groot_zmq_server_port | 1667 | change port of the zmq server needed for groot |
11-
| plugin_lib_names | ["nav2_compute_pre_charging_goals_action_bt_node", "nav2_get_charging_goal_from_marker_action_bt_node", "nav2_get_pallet_position_from_depth_cameras_action_bt_node", "nav2_get_goal_from_pallet_position_action_bt_node", "nav2_set_lift_level_action_bt_node", "nav2_adjust_pallet_goal_action_bt_node","nav2_narrow_pre_approach_action_bt_node", "nav2_get_putdown_goal_action_bt_node", "nav2_check_zone_from_big_loaders_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_lidar_triggered_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_is_forklift_load_detected_condition_bt_node", "nav2_is_charging_action_condition_bt_node", "nav2_reinitialize_global_localization_service_bt_node", "nav2_call_service_bt_node", "nav2_set_node_parameters_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", "nav2_mean_between_goals_condition_bt_node, nav2_move_goal_towards_other_goal_condition_bt_node"] | list of behavior tree node shared libraries |
11+
| plugin_lib_names | ["nav2_compute_pre_charging_goals_action_bt_node", "nav2_get_charging_goal_from_marker_action_bt_node", "nav2_get_pallet_position_from_depth_cameras_action_bt_node", "nav2_get_goal_from_pallet_position_action_bt_node", "nav2_set_lift_level_action_bt_node", "nav2_adjust_pallet_goal_action_bt_node","nav2_narrow_pre_approach_action_bt_node", "nav2_get_putdown_goal_action_bt_node", "nav2_check_zone_from_big_loaders_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_lidar_triggered_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_is_forklift_load_detected_condition_bt_node", "check_bin_type_condition_bt_node", "nav2_is_charging_action_condition_bt_node", "nav2_reinitialize_global_localization_service_bt_node", "nav2_call_service_bt_node", "nav2_set_node_parameters_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", "nav2_mean_between_goals_condition_bt_node, nav2_move_goal_towards_other_goal_condition_bt_node"] | list of behavior tree node shared libraries |
1212
| transform_tolerance | 0.1 | TF transform tolerance |
1313
| global_frame | "map" | Reference frame |
1414
| 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
@@ -186,6 +186,9 @@ list(APPEND plugin_libs nav2_initial_pose_received_condition_bt_node)
186186
add_library(nav2_is_forklift_load_detected_condition_bt_node SHARED plugins/condition/is_forklift_load_detected.cpp)
187187
list(APPEND plugin_libs nav2_is_forklift_load_detected_condition_bt_node)
188188

189+
add_library(nav2_check_bin_type_condition_bt_node SHARED plugins/condition/check_bin_type_condition.cpp)
190+
list(APPEND plugin_libs nav2_check_bin_type_condition_bt_node)
191+
189192
add_library(nav2_is_charging_action_condition_bt_node SHARED plugins/condition/is_charging_action.cpp)
190193
list(APPEND plugin_libs nav2_is_charging_action_condition_bt_node)
191194

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#ifndef NAV2_BEHAVIOR_TREE__PLUGINS__CONDITION_CHECK_BIN_TYPE_CONDITION_HPP_
2+
#define NAV2_BEHAVIOR_TREE__PLUGINS__CONDITION_CHECK_BIN_TYPE_CONDITION_HPP_
3+
4+
#include <memory>
5+
#include <mutex>
6+
#include <string>
7+
8+
#include "behaviortree_cpp_v3/condition_node.h"
9+
#include "rclcpp/rclcpp.hpp"
10+
11+
namespace nav2_behavior_tree {
12+
13+
class CheckBinTypeCondition : public BT::ConditionNode {
14+
public:
15+
CheckBinTypeCondition(
16+
const std::string &condition_name,
17+
const BT::NodeConfiguration &conf);
18+
19+
CheckBinTypeCondition() = delete;
20+
21+
~CheckBinTypeCondition();
22+
23+
BT::NodeStatus tick() override;
24+
25+
bool TargetBinTypeValid(std::string target_bin_type);
26+
bool TargetBinTypeMatched(std::string target_bin_type, std::string bin_id);
27+
28+
static BT::PortsList providedPorts()
29+
{
30+
return {
31+
BT::InputPort<std::string>("target_bin_type", "AMR target bin type"),
32+
BT::InputPort<std::string>("bin_id", "Bin ID to operate")
33+
};
34+
}
35+
36+
private:
37+
rclcpp::Node::SharedPtr node_;
38+
std::string target_bin_type;
39+
};
40+
41+
} // namespace nav2_behavior_tree
42+
43+
#endif // NAV2_BEHAVIOR_TREE__PLUGINS__CONDITION_CHECK_BIN_TYPE_CONDITION_HPP_

nav2_behavior_tree/nav2_tree_nodes.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,11 @@
263263
<input_port name="target_charging_action">target charging action</input_port>
264264
</Condition>
265265

266+
<Condition ID="CheckBinType">
267+
<input_port name="target_bin_type">AMR target bin type</input_port>
268+
<input_port name="bin_id">Bin ID to operate</input_port>
269+
</Condition>
270+
266271
<!-- ############################### CONTROL NODES ################################ -->
267272
<Control ID="PipelineSequence"/>
268273

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
#include <string>
2+
3+
#include "nav2_behavior_tree/plugins/condition/check_bin_type_condition.hpp"
4+
5+
namespace nav2_behavior_tree {
6+
7+
CheckBinTypeCondition::CheckBinTypeCondition(
8+
const std::string &condition_name,
9+
const BT::NodeConfiguration &conf)
10+
: BT::ConditionNode(condition_name, conf)
11+
{
12+
node_ = config().blackboard->get<rclcpp::Node::SharedPtr>("node");
13+
RCLCPP_DEBUG(node_->get_logger(), "Initialized a CheckBinTypeCondition BT node");
14+
}
15+
16+
CheckBinTypeCondition::~CheckBinTypeCondition()
17+
{
18+
RCLCPP_DEBUG(node_->get_logger(), "Shutting down CheckBinTypeCondition BT node");
19+
}
20+
21+
BT::NodeStatus CheckBinTypeCondition::tick() {
22+
getInput("target_bin_type", target_bin_type);
23+
std::string bin_id;
24+
getInput<std::string>("bin_id", bin_id);
25+
26+
if (!TargetBinTypeValid(target_bin_type)){
27+
RCLCPP_INFO(node_->get_logger(),
28+
"target_bin_type:%s is not valid,"
29+
"available target_bin_type should be either 'floor' or 'roller_belt'\n",target_bin_type);
30+
return BT::NodeStatus::FAILURE;
31+
}
32+
33+
if (TargetBinTypeMatched(target_bin_type, bin_id)){
34+
RCLCPP_INFO(node_->get_logger(), "target_bin_type:%s matches input bin_id:%s\n", target_bin_type, bin_id);
35+
return BT::NodeStatus::SUCCESS;
36+
}
37+
RCLCPP_INFO(node_->get_logger(), "target_bin_type:%s doesn't match input bin_id:%s\n", target_bin_type, bin_id);
38+
return BT::NodeStatus::FAILURE;
39+
}
40+
41+
bool CheckBinTypeCondition::TargetBinTypeValid(std::string target_bin_type)
42+
{
43+
return target_bin_type == "floor" || target_bin_type == "roller_belt";
44+
}
45+
46+
bool CheckBinTypeCondition::TargetBinTypeMatched(std::string target_bin_type, std::string bin_id)
47+
{
48+
// check whether bin_id = "2518_1" (Currently 2518_1 is the only roller_belt bin_id using in Brummer)
49+
bool isRollerBelt = bin_id == "2518_1";
50+
if (target_bin_type == "roller_belt"){
51+
return isRollerBelt;
52+
}
53+
else {
54+
return !isRollerBelt;
55+
}
56+
}
57+
58+
} // namespace nav2_behavior_tree
59+
60+
#include "behaviortree_cpp_v3/bt_factory.h"
61+
BT_REGISTER_NODES(factory) {
62+
factory.registerNodeType<nav2_behavior_tree::CheckBinTypeCondition>(
63+
"CheckBinType");
64+
}

nav2_bringup/bringup/params/forklift_params.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -495,6 +495,7 @@ bt_navigator:
495495
- nav2_is_charging_action_condition_bt_node
496496
- nav2_verify_bin_state_action_bt_node
497497
- nav2_barcode_scanning_success_condition_bt_node
498+
- nav2_check_bin_type_condition_bt_node
498499

499500
execute_goal:
500501
ros__parameters:

nav2_bt_navigator/src/bt_navigator.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,8 @@ BtNavigator::BtNavigator()
101101
"nav2_is_charging_action_condition_bt_node",
102102
"nav2_mean_between_goals_condition_bt_node",
103103
"nav2_verify_bin_state_action_bt_node",
104-
"nav2_barcode_scanning_success_condition_bt_node"
104+
"nav2_barcode_scanning_success_condition_bt_node",
105+
"nav2_check_bin_type_condition_bt_node"
105106
};
106107

107108
declare_parameter("plugin_lib_names", plugin_libs);

0 commit comments

Comments
 (0)