Skip to content

Commit 849ff3f

Browse files
padhupradheepRBT22
authored andcommitted
fixing path longer on approach (ros-navigation#4622) (ros-navigation#4766)
* fixing path longer on approach * removing the short circuit * adding additional layer of check --------- Signed-off-by: Pradheep <padhupradheep@gmail.com>
1 parent 9e62442 commit 849ff3f

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

‎nav2_behavior_tree/plugins/decorator/path_longer_on_approach.cpp‎

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,10 @@ bool PathLongerOnApproach::isPathUpdated(
3434
nav_msgs::msg::Path & new_path,
3535
nav_msgs::msg::Path & old_path)
3636
{
37-
return new_path != old_path && old_path.poses.size() != 0 &&
37+
return old_path.poses.size() != 0 &&
3838
new_path.poses.size() != 0 &&
39-
old_path.poses.back().pose == new_path.poses.back().pose;
39+
new_path.poses.size() != old_path.poses.size() &&
40+
old_path.poses.back().pose.position == new_path.poses.back().pose.position;
4041
}
4142

4243
bool PathLongerOnApproach::isRobotInGoalProximity(
@@ -62,10 +63,12 @@ inline BT::NodeStatus PathLongerOnApproach::tick()
6263
getInput("prox_len", prox_len_);
6364
getInput("length_factor", length_factor_);
6465

65-
if (status() == BT::NodeStatus::IDLE) {
66-
// Reset the starting point since we're starting a new iteration of
67-
// PathLongerOnApproach (moving from IDLE to RUNNING)
68-
first_time_ = true;
66+
if (first_time_ == false) {
67+
if (old_path_.poses.empty() || new_path_.poses.empty() ||
68+
old_path_.poses.back().pose != new_path_.poses.back().pose)
69+
{
70+
first_time_ = true;
71+
}
6972
}
7073

7174
setStatus(BT::NodeStatus::RUNNING);
@@ -78,13 +81,12 @@ inline BT::NodeStatus PathLongerOnApproach::tick()
7881
const BT::NodeStatus child_state = child_node_->executeTick();
7982
switch (child_state) {
8083
case BT::NodeStatus::RUNNING:
81-
return BT::NodeStatus::RUNNING;
84+
return child_state;
8285
case BT::NodeStatus::SUCCESS:
83-
old_path_ = new_path_;
84-
return BT::NodeStatus::SUCCESS;
8586
case BT::NodeStatus::FAILURE:
8687
old_path_ = new_path_;
87-
return BT::NodeStatus::FAILURE;
88+
resetChild();
89+
return child_state;
8890
default:
8991
old_path_ = new_path_;
9092
return BT::NodeStatus::FAILURE;

0 commit comments

Comments
 (0)