Skip to content

Commit 8303cdc

Browse files
committed
fix
Signed-off-by: Tony Najjar <tony.najjar.1997@gmail.com>
1 parent b416253 commit 8303cdc

File tree

1 file changed

+12
-14
lines changed

1 file changed

+12
-14
lines changed

nav2_behavior_tree/plugins/decorator/goal_updater_node.cpp

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -71,21 +71,19 @@ inline BT::NodeStatus GoalUpdater::tick()
7171
callback_group_executor_.spin_all(std::chrono::milliseconds(1));
7272
callback_group_executor_.spin_all(std::chrono::milliseconds(49));
7373

74-
if (last_goal_received_.header.stamp != rclcpp::Time(0)) {
75-
auto last_goal_received_time = rclcpp::Time(last_goal_received_.header.stamp);
76-
auto goal_time = rclcpp::Time(goal.header.stamp);
77-
if (last_goal_received_time > goal_time) {
78-
goal = last_goal_received_;
79-
} else {
80-
RCLCPP_WARN(
81-
node_->get_logger(), "The timestamp of the received goal (%f) is older than the "
82-
"current goal (%f). Ignoring the received goal.",
83-
last_goal_received_time.seconds(), goal_time.seconds());
84-
}
74+
auto last_goal_received_time = rclcpp::Time(last_goal_received_.header.stamp);
75+
auto goal_time = rclcpp::Time(goal.header.stamp);
76+
if (last_goal_received_time > goal_time) {
77+
goal = last_goal_received_;
78+
} else {
79+
RCLCPP_WARN(
80+
node_->get_logger(), "The timestamp of the received goal (%f) is older than the "
81+
"current goal (%f). Ignoring the received goal.",
82+
last_goal_received_time.seconds(), goal_time.seconds());
8583
}
8684
setOutput("output_goal", goal);
8785

88-
if (last_goals_received_.header.stamp != rclcpp::Time(0) && !last_goals_received_.poses.empty()) {
86+
if (!last_goals_received_.poses.empty()) {
8987
auto last_goals_received_time = rclcpp::Time(last_goals_received_.header.stamp);
9088
rclcpp::Time most_recent_goal_time = rclcpp::Time(0, 0, node_->get_clock()->get_clock_type());
9189
for (const auto & g : goals) {
@@ -98,12 +96,12 @@ inline BT::NodeStatus GoalUpdater::tick()
9896
} else {
9997
RCLCPP_WARN(
10098
node_->get_logger(), "None of the received goals (most recent: %f) are more recent than the "
101-
"current goals (oldest: %f). Ignoring the received goals.",
99+
"current goals (oldest current goal: %f). Ignoring the received goals.",
102100
last_goals_received_time.seconds(), most_recent_goal_time.seconds());
103101
}
102+
setOutput("output_goals", goals);
104103
}
105104

106-
setOutput("output_goals", goals);
107105
return child_node_->executeTick();
108106
}
109107

0 commit comments

Comments
 (0)