Skip to content

Commit 2b8cc4d

Browse files
authored
Revert double spin (#5477)
* Revert "Add double spin_some in some BT nodes (#5055)" This reverts commit 4e8469e. Signed-off-by: mini-1235 <[email protected]> * Update spin some to use spin all Signed-off-by: mini-1235 <[email protected]> * Replace 50 ms with bt loop duration Signed-off-by: mini-1235 <[email protected]> --------- Signed-off-by: mini-1235 <[email protected]>
1 parent c057c95 commit 2b8cc4d

26 files changed

+64
-28
lines changed

nav2_behavior_tree/include/nav2_behavior_tree/plugins/action/controller_selector_node.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
#include <memory>
2020
#include <string>
21+
#include <chrono>
2122

2223
#include "std_msgs/msg/string.hpp"
2324

@@ -102,6 +103,7 @@ class ControllerSelector : public BT::SyncActionNode
102103
rclcpp::executors::SingleThreadedExecutor callback_group_executor_;
103104

104105
std::string topic_name_;
106+
std::chrono::milliseconds bt_loop_duration_;
105107
};
106108

107109
} // namespace nav2_behavior_tree

nav2_behavior_tree/include/nav2_behavior_tree/plugins/action/goal_checker_selector_node.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
#include <memory>
2020
#include <string>
21+
#include <chrono>
2122

2223
#include "std_msgs/msg/string.hpp"
2324

@@ -102,6 +103,7 @@ class GoalCheckerSelector : public BT::SyncActionNode
102103
rclcpp::executors::SingleThreadedExecutor callback_group_executor_;
103104

104105
std::string topic_name_;
106+
std::chrono::milliseconds bt_loop_duration_;
105107
};
106108

107109
} // namespace nav2_behavior_tree

nav2_behavior_tree/include/nav2_behavior_tree/plugins/action/planner_selector_node.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
#include <memory>
2020
#include <string>
21+
#include <chrono>
2122

2223
#include "std_msgs/msg/string.hpp"
2324

@@ -103,6 +104,7 @@ class PlannerSelector : public BT::SyncActionNode
103104
rclcpp::executors::SingleThreadedExecutor callback_group_executor_;
104105

105106
std::string topic_name_;
107+
std::chrono::milliseconds bt_loop_duration_;
106108
};
107109

108110
} // namespace nav2_behavior_tree

nav2_behavior_tree/include/nav2_behavior_tree/plugins/action/progress_checker_selector_node.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
#include <memory>
1919
#include <string>
20+
#include <chrono>
2021

2122
#include "std_msgs/msg/string.hpp"
2223

@@ -101,6 +102,7 @@ class ProgressCheckerSelector : public BT::SyncActionNode
101102
rclcpp::executors::SingleThreadedExecutor callback_group_executor_;
102103

103104
std::string topic_name_;
105+
std::chrono::milliseconds bt_loop_duration_;
104106
};
105107

106108
} // namespace nav2_behavior_tree

nav2_behavior_tree/include/nav2_behavior_tree/plugins/action/smoother_selector_node.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
#include <memory>
2020
#include <string>
21+
#include <chrono>
2122

2223
#include "std_msgs/msg/string.hpp"
2324

@@ -102,6 +103,7 @@ class SmootherSelector : public BT::SyncActionNode
102103
rclcpp::executors::SingleThreadedExecutor callback_group_executor_;
103104

104105
std::string topic_name_;
106+
std::chrono::milliseconds bt_loop_duration_;
105107
};
106108

107109
} // namespace nav2_behavior_tree

nav2_behavior_tree/include/nav2_behavior_tree/plugins/condition/is_battery_charging_condition.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include <string>
1919
#include <memory>
2020
#include <mutex>
21+
#include <chrono>
2122

2223
#include "nav2_ros_common/lifecycle_node.hpp"
2324
#include "sensor_msgs/msg/battery_state.hpp"
@@ -85,6 +86,7 @@ class IsBatteryChargingCondition : public BT::ConditionNode
8586
nav2::Subscription<sensor_msgs::msg::BatteryState>::SharedPtr battery_sub_;
8687
std::string battery_topic_;
8788
bool is_battery_charging_;
89+
std::chrono::milliseconds bt_loop_duration_;
8890
};
8991

9092
} // namespace nav2_behavior_tree

nav2_behavior_tree/include/nav2_behavior_tree/plugins/condition/is_battery_low_condition.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include <string>
2020
#include <memory>
2121
#include <mutex>
22+
#include <chrono>
2223

2324
#include "nav2_ros_common/lifecycle_node.hpp"
2425
#include "sensor_msgs/msg/battery_state.hpp"
@@ -93,6 +94,7 @@ class IsBatteryLowCondition : public BT::ConditionNode
9394
double min_battery_;
9495
bool is_voltage_;
9596
bool is_battery_low_;
97+
std::chrono::milliseconds bt_loop_duration_;
9698
};
9799

98100
} // namespace nav2_behavior_tree

nav2_behavior_tree/include/nav2_behavior_tree/plugins/decorator/goal_updater_node.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
#include <memory>
2121
#include <string>
22+
#include <chrono>
2223

2324
#include "behaviortree_cpp/decorator_node.h"
2425
#include "behaviortree_cpp/json_export.h"
@@ -110,6 +111,7 @@ class GoalUpdater : public BT::DecoratorNode
110111
rclcpp::executors::SingleThreadedExecutor callback_group_executor_;
111112
std::string goal_updater_topic_;
112113
std::string goals_updater_topic_;
114+
std::chrono::milliseconds bt_loop_duration_;
113115
};
114116

115117
} // namespace nav2_behavior_tree

nav2_behavior_tree/plugins/action/controller_selector_node.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,8 @@ ControllerSelector::ControllerSelector(
3333
: BT::SyncActionNode(name, conf)
3434
{
3535
initialize();
36-
37-
// Spin multiple times due to rclcpp regression in Jazzy requiring a 'warm up' spin
38-
callback_group_executor_.spin_some(std::chrono::nanoseconds(1));
36+
bt_loop_duration_ =
37+
config().blackboard->template get<std::chrono::milliseconds>("bt_loop_duration");
3938
}
4039

4140
void ControllerSelector::initialize()
@@ -69,7 +68,7 @@ BT::NodeStatus ControllerSelector::tick()
6968
initialize();
7069
}
7170

72-
callback_group_executor_.spin_some();
71+
callback_group_executor_.spin_all(bt_loop_duration_);
7372

7473
// This behavior always use the last selected controller received from the topic input.
7574
// When no input is specified it uses the default controller.

nav2_behavior_tree/plugins/action/goal_checker_selector_node.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ GoalCheckerSelector::GoalCheckerSelector(
3333
: BT::SyncActionNode(name, conf)
3434
{
3535
initialize();
36+
bt_loop_duration_ =
37+
config().blackboard->template get<std::chrono::milliseconds>("bt_loop_duration");
3638
}
3739

3840
void GoalCheckerSelector::initialize()
@@ -66,7 +68,7 @@ BT::NodeStatus GoalCheckerSelector::tick()
6668
initialize();
6769
}
6870

69-
callback_group_executor_.spin_some();
71+
callback_group_executor_.spin_all(bt_loop_duration_);
7072

7173
// This behavior always use the last selected goal checker received from the topic input.
7274
// When no input is specified it uses the default goal checker.

0 commit comments

Comments
 (0)