Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

#include <memory>
#include <string>
#include <chrono>

#include "std_msgs/msg/string.hpp"

Expand Down Expand Up @@ -102,6 +103,7 @@ class ControllerSelector : public BT::SyncActionNode
rclcpp::executors::SingleThreadedExecutor callback_group_executor_;

std::string topic_name_;
std::chrono::milliseconds bt_loop_duration_;
};

} // namespace nav2_behavior_tree
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

#include <memory>
#include <string>
#include <chrono>

#include "std_msgs/msg/string.hpp"

Expand Down Expand Up @@ -102,6 +103,7 @@ class GoalCheckerSelector : public BT::SyncActionNode
rclcpp::executors::SingleThreadedExecutor callback_group_executor_;

std::string topic_name_;
std::chrono::milliseconds bt_loop_duration_;
};

} // namespace nav2_behavior_tree
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

#include <memory>
#include <string>
#include <chrono>

#include "std_msgs/msg/string.hpp"

Expand Down Expand Up @@ -103,6 +104,7 @@ class PlannerSelector : public BT::SyncActionNode
rclcpp::executors::SingleThreadedExecutor callback_group_executor_;

std::string topic_name_;
std::chrono::milliseconds bt_loop_duration_;
};

} // namespace nav2_behavior_tree
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

#include <memory>
#include <string>
#include <chrono>

#include "std_msgs/msg/string.hpp"

Expand Down Expand Up @@ -101,6 +102,7 @@ class ProgressCheckerSelector : public BT::SyncActionNode
rclcpp::executors::SingleThreadedExecutor callback_group_executor_;

std::string topic_name_;
std::chrono::milliseconds bt_loop_duration_;
};

} // namespace nav2_behavior_tree
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

#include <memory>
#include <string>
#include <chrono>

#include "std_msgs/msg/string.hpp"

Expand Down Expand Up @@ -102,6 +103,7 @@ class SmootherSelector : public BT::SyncActionNode
rclcpp::executors::SingleThreadedExecutor callback_group_executor_;

std::string topic_name_;
std::chrono::milliseconds bt_loop_duration_;
};

} // namespace nav2_behavior_tree
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include <string>
#include <memory>
#include <mutex>
#include <chrono>

#include "nav2_ros_common/lifecycle_node.hpp"
#include "sensor_msgs/msg/battery_state.hpp"
Expand Down Expand Up @@ -85,6 +86,7 @@ class IsBatteryChargingCondition : public BT::ConditionNode
nav2::Subscription<sensor_msgs::msg::BatteryState>::SharedPtr battery_sub_;
std::string battery_topic_;
bool is_battery_charging_;
std::chrono::milliseconds bt_loop_duration_;
};

} // namespace nav2_behavior_tree
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include <string>
#include <memory>
#include <mutex>
#include <chrono>

#include "nav2_ros_common/lifecycle_node.hpp"
#include "sensor_msgs/msg/battery_state.hpp"
Expand Down Expand Up @@ -93,6 +94,7 @@ class IsBatteryLowCondition : public BT::ConditionNode
double min_battery_;
bool is_voltage_;
bool is_battery_low_;
std::chrono::milliseconds bt_loop_duration_;
};

} // namespace nav2_behavior_tree
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

#include <memory>
#include <string>
#include <chrono>

#include "behaviortree_cpp/decorator_node.h"
#include "behaviortree_cpp/json_export.h"
Expand Down Expand Up @@ -110,6 +111,7 @@ class GoalUpdater : public BT::DecoratorNode
rclcpp::executors::SingleThreadedExecutor callback_group_executor_;
std::string goal_updater_topic_;
std::string goals_updater_topic_;
std::chrono::milliseconds bt_loop_duration_;
};

} // namespace nav2_behavior_tree
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,8 @@ ControllerSelector::ControllerSelector(
: BT::SyncActionNode(name, conf)
{
initialize();

// Spin multiple times due to rclcpp regression in Jazzy requiring a 'warm up' spin
callback_group_executor_.spin_some(std::chrono::nanoseconds(1));
bt_loop_duration_ =
config().blackboard->template get<std::chrono::milliseconds>("bt_loop_duration");
}

void ControllerSelector::initialize()
Expand Down Expand Up @@ -69,7 +68,7 @@ BT::NodeStatus ControllerSelector::tick()
initialize();
}

callback_group_executor_.spin_some();
callback_group_executor_.spin_all(bt_loop_duration_);

// This behavior always use the last selected controller received from the topic input.
// When no input is specified it uses the default controller.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ GoalCheckerSelector::GoalCheckerSelector(
: BT::SyncActionNode(name, conf)
{
initialize();
bt_loop_duration_ =
config().blackboard->template get<std::chrono::milliseconds>("bt_loop_duration");
}

void GoalCheckerSelector::initialize()
Expand Down Expand Up @@ -66,7 +68,7 @@ BT::NodeStatus GoalCheckerSelector::tick()
initialize();
}

callback_group_executor_.spin_some();
callback_group_executor_.spin_all(bt_loop_duration_);

// This behavior always use the last selected goal checker received from the topic input.
// When no input is specified it uses the default goal checker.
Expand Down
7 changes: 3 additions & 4 deletions nav2_behavior_tree/plugins/action/planner_selector_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,8 @@ PlannerSelector::PlannerSelector(
: BT::SyncActionNode(name, conf)
{
initialize();

// Spin multiple times due to rclcpp regression in Jazzy requiring a 'warm up' spin
callback_group_executor_.spin_some(std::chrono::nanoseconds(1));
bt_loop_duration_ =
config().blackboard->template get<std::chrono::milliseconds>("bt_loop_duration");
}

void PlannerSelector::initialize()
Expand Down Expand Up @@ -69,7 +68,7 @@ BT::NodeStatus PlannerSelector::tick()
initialize();
}

callback_group_executor_.spin_some();
callback_group_executor_.spin_all(bt_loop_duration_);

// This behavior always use the last selected planner received from the topic input.
// When no input is specified it uses the default planner.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ ProgressCheckerSelector::ProgressCheckerSelector(
: BT::SyncActionNode(name, conf)
{
initialize();
bt_loop_duration_ =
config().blackboard->template get<std::chrono::milliseconds>("bt_loop_duration");
}

void ProgressCheckerSelector::initialize()
Expand Down Expand Up @@ -65,7 +67,7 @@ BT::NodeStatus ProgressCheckerSelector::tick()
initialize();
}

callback_group_executor_.spin_some();
callback_group_executor_.spin_all(bt_loop_duration_);

// This behavior always use the last selected progress checker received from the topic input.
// When no input is specified it uses the default goaprogressl checker.
Expand Down
7 changes: 3 additions & 4 deletions nav2_behavior_tree/plugins/action/smoother_selector_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,8 @@ SmootherSelector::SmootherSelector(
: BT::SyncActionNode(name, conf)
{
initialize();

// Spin multiple times due to rclcpp regression in Jazzy requiring a 'warm up' spin
callback_group_executor_.spin_some(std::chrono::nanoseconds(1));
bt_loop_duration_ =
config().blackboard->template get<std::chrono::milliseconds>("bt_loop_duration");
}

void SmootherSelector::initialize()
Expand Down Expand Up @@ -70,7 +69,7 @@ BT::NodeStatus SmootherSelector::tick()
initialize();
}

callback_group_executor_.spin_some();
callback_group_executor_.spin_all(bt_loop_duration_);

// This behavior always use the last selected smoother received from the topic input.
// When no input is specified it uses the default smoother.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,8 @@ IsBatteryChargingCondition::IsBatteryChargingCondition(
is_battery_charging_(false)
{
initialize();

// Spin multiple times due to rclcpp regression in Jazzy requiring a 'warm up' spin
callback_group_executor_.spin_some(std::chrono::nanoseconds(1));
bt_loop_duration_ =
config().blackboard->template get<std::chrono::milliseconds>("bt_loop_duration");
}

void IsBatteryChargingCondition::initialize()
Expand Down Expand Up @@ -65,7 +64,7 @@ BT::NodeStatus IsBatteryChargingCondition::tick()
initialize();
}

callback_group_executor_.spin_some();
callback_group_executor_.spin_all(bt_loop_duration_);
if (is_battery_charging_) {
return BT::NodeStatus::SUCCESS;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,8 @@ IsBatteryLowCondition::IsBatteryLowCondition(
is_battery_low_(false)
{
initialize();

// Spin multiple times due to rclcpp regression in Jazzy requiring a 'warm up' spin
callback_group_executor_.spin_some(std::chrono::nanoseconds(1));
bt_loop_duration_ =
config().blackboard->template get<std::chrono::milliseconds>("bt_loop_duration");
}

void IsBatteryLowCondition::initialize()
Expand Down Expand Up @@ -71,7 +70,7 @@ BT::NodeStatus IsBatteryLowCondition::tick()
initialize();
}

callback_group_executor_.spin_some();
callback_group_executor_.spin_all(bt_loop_duration_);
if (is_battery_low_) {
return BT::NodeStatus::SUCCESS;
}
Expand Down
7 changes: 3 additions & 4 deletions nav2_behavior_tree/plugins/decorator/goal_updater_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,8 @@ GoalUpdater::GoalUpdater(
goals_updater_topic_("goals_update")
{
initialize();

// Spin multiple times due to rclcpp regression in Jazzy requiring a 'warm up' spin
callback_group_executor_.spin_all(std::chrono::milliseconds(1));
bt_loop_duration_ =
config().blackboard->template get<std::chrono::milliseconds>("bt_loop_duration");
}

void GoalUpdater::initialize()
Expand Down Expand Up @@ -91,7 +90,7 @@ inline BT::NodeStatus GoalUpdater::tick()
getInput("input_goal", goal);
getInput("input_goals", goals);

callback_group_executor_.spin_all(std::chrono::milliseconds(49));
callback_group_executor_.spin_all(bt_loop_duration_);

if (last_goal_received_set_) {
if (last_goal_received_.header.stamp == rclcpp::Time(0)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ class ControllerSelectorTestFixture : public ::testing::Test
config_->blackboard = BT::Blackboard::create();
// Put items on the blackboard
config_->blackboard->set("node", node_);
config_->blackboard->set<std::chrono::milliseconds>(
"bt_loop_duration",
std::chrono::milliseconds(10));

BT::NodeBuilder builder = [](const std::string & name, const BT::NodeConfiguration & config) {
return std::make_unique<nav2_behavior_tree::ControllerSelector>(name, config);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ class GoalCheckerSelectorTestFixture : public ::testing::Test
config_->blackboard = BT::Blackboard::create();
// Put items on the blackboard
config_->blackboard->set("node", node_);
config_->blackboard->set<std::chrono::milliseconds>(
"bt_loop_duration",
std::chrono::milliseconds(10));

BT::NodeBuilder builder = [](const std::string & name, const BT::NodeConfiguration & config) {
return std::make_unique<nav2_behavior_tree::GoalCheckerSelector>(name, config);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ class PlannerSelectorTestFixture : public ::testing::Test
config_->blackboard = BT::Blackboard::create();
// Put items on the blackboard
config_->blackboard->set("node", node_);
config_->blackboard->set<std::chrono::milliseconds>(
"bt_loop_duration",
std::chrono::milliseconds(10));

BT::NodeBuilder builder = [](const std::string & name, const BT::NodeConfiguration & config) {
return std::make_unique<nav2_behavior_tree::PlannerSelector>(name, config);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ class ProgressCheckerSelectorTestFixture : public ::testing::Test
config_->blackboard = BT::Blackboard::create();
// Put items on the blackboard
config_->blackboard->set("node", node_);
config_->blackboard->set<std::chrono::milliseconds>(
"bt_loop_duration",
std::chrono::milliseconds(10));

BT::NodeBuilder builder = [](const std::string & name, const BT::NodeConfiguration & config) {
return std::make_unique<nav2_behavior_tree::ProgressCheckerSelector>(name, config);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ class SmootherSelectorTestFixture : public ::testing::Test
config_->blackboard = BT::Blackboard::create();
// Put items on the blackboard
config_->blackboard->set("node", node_);
config_->blackboard->set<std::chrono::milliseconds>(
"bt_loop_duration",
std::chrono::milliseconds(10));

BT::NodeBuilder builder = [](const std::string & name, const BT::NodeConfiguration & config) {
return std::make_unique<nav2_behavior_tree::SmootherSelector>(name, config);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ class IsBatteryChargingConditionTestFixture : public ::testing::Test
config_->blackboard->set(
"node",
node_);
config_->blackboard->set<std::chrono::milliseconds>(
"bt_loop_duration",
std::chrono::milliseconds(10));

factory_->registerNodeType<nav2_behavior_tree::IsBatteryChargingCondition>("IsBatteryCharging");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ class IsBatteryLowConditionTestFixture : public ::testing::Test
config_->blackboard->set(
"node",
node_);
config_->blackboard->set<std::chrono::milliseconds>(
"bt_loop_duration",
std::chrono::milliseconds(10));

factory_->registerNodeType<nav2_behavior_tree::IsBatteryLowCondition>("IsBatteryLow");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ class GoalUpdaterTestFixture : public ::testing::Test
config_->blackboard->set(
"node",
node_);
config_->blackboard->set<std::chrono::milliseconds>(
"bt_loop_duration",
std::chrono::milliseconds(10));

BT::NodeBuilder builder =
[](const std::string & name, const BT::NodeConfiguration & config)
Expand Down
1 change: 0 additions & 1 deletion nav2_route/test/test_graph_loader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ TEST(GraphLoader, test_transformation_api)
tf_broadcaster->sendTransform(transform);
rclcpp::Rate(1).sleep();
tf_broadcaster->sendTransform(transform);
rclcpp::spin_all(node->get_node_base_interface(), std::chrono::milliseconds(1));
rclcpp::spin_all(node->get_node_base_interface(), std::chrono::milliseconds(50));

graph[0].coords.frame_id = "map_test";
Expand Down
1 change: 0 additions & 1 deletion nav2_route/test/test_graph_saver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,6 @@ TEST(GraphSaver, test_transformation_api)
tf_broadcaster->sendTransform(transform);
rclcpp::Rate(1).sleep();
tf_broadcaster->sendTransform(transform);
rclcpp::spin_all(node->get_node_base_interface(), std::chrono::milliseconds(1));
rclcpp::spin_all(node->get_node_base_interface(), std::chrono::milliseconds(50));

GraphSaver graph_saver(node, tf, frame);
Expand Down
Loading