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 @@ -53,7 +53,7 @@ class WaitAction : public BtActionNode<nav2_msgs::action::Wait>
{
return providedBasicPorts(
{
BT::InputPort<int>("wait_duration", 1, "Wait time")
BT::InputPort<double>("wait_duration", 1.0, "Wait time")
});
}
};
Expand Down
7 changes: 4 additions & 3 deletions nav2_behavior_tree/plugins/action/wait_action.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

#include <string>
#include <memory>
#include <cmath>

#include "nav2_behavior_tree/plugins/action/wait_action.hpp"

Expand All @@ -26,16 +27,16 @@ WaitAction::WaitAction(
const BT::NodeConfiguration & conf)
: BtActionNode<nav2_msgs::action::Wait>(xml_tag_name, action_name, conf)
{
int duration;
double duration;
getInput("wait_duration", duration);
if (duration <= 0) {
RCLCPP_WARN(
node_->get_logger(), "Wait duration is negative or zero "
"(%i). Setting to positive.", duration);
"(%f). Setting to positive.", duration);
duration *= -1;
}

goal_.time.sec = duration;
goal_.time = rclcpp::Duration::from_seconds(duration);
}

void WaitAction::on_tick()
Expand Down
8 changes: 4 additions & 4 deletions nav2_behavior_tree/test/plugins/action/test_wait_action.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,18 +120,18 @@ TEST_F(WaitActionTestFixture, test_ports)
</root>)";

tree_ = std::make_shared<BT::Tree>(factory_->createTreeFromText(xml_txt, config_->blackboard));
EXPECT_EQ(tree_->rootNode()->getInput<int>("wait_duration"), 1);
EXPECT_EQ(tree_->rootNode()->getInput<double>("wait_duration"), 1.0);

xml_txt =
R"(
<root main_tree_to_execute = "MainTree" >
<BehaviorTree ID="MainTree">
<Wait wait_duration="10" />
<Wait wait_duration="10.0" />
</BehaviorTree>
</root>)";

tree_ = std::make_shared<BT::Tree>(factory_->createTreeFromText(xml_txt, config_->blackboard));
EXPECT_EQ(tree_->rootNode()->getInput<int>("wait_duration"), 10);
EXPECT_EQ(tree_->rootNode()->getInput<double>("wait_duration"), 10.0);
}

TEST_F(WaitActionTestFixture, test_tick)
Expand All @@ -140,7 +140,7 @@ TEST_F(WaitActionTestFixture, test_tick)
R"(
<root main_tree_to_execute = "MainTree" >
<BehaviorTree ID="MainTree">
<Wait wait_duration="-5"/>
<Wait wait_duration="-5.0"/>
</BehaviorTree>
</root>)";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
<ClearEntireCostmap name="ClearGlobalCostmap-Subtree" service_name="global_costmap/clear_entirely_global_costmap"/>
</Sequence>
<Spin spin_dist="1.57"/>
<Wait wait_duration="5"/>
<Wait wait_duration="5.0"/>
<BackUp backup_dist="0.30" backup_speed="0.05"/>
</RoundRobin>
</ReactiveFallback>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
<ClearEntireCostmap name="ClearGlobalCostmap-Subtree" service_name="global_costmap/clear_entirely_global_costmap"/>
</Sequence>
<Spin spin_dist="1.57" error_code_id="{spin_error_code}"/>
<Wait wait_duration="5"/>
<Wait wait_duration="5.0"/>
<BackUp backup_dist="0.30" backup_speed="0.05" error_code_id="{backup_error_code}"/>
</RoundRobin>
</ReactiveFallback>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
<ClearEntireCostmap name="ClearGlobalCostmap-Subtree" service_name="global_costmap/clear_entirely_global_costmap"/>
</Sequence>
<Spin spin_dist="1.57" error_code_id="{spin_error_code}"/>
<Wait wait_duration="5"/>
<Wait wait_duration="5.0"/>
<BackUp backup_dist="0.30" backup_speed="0.05" error_code_id="{backup_code_id}"/>
</RoundRobin>
</ReactiveFallback>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<RetryUntilSuccessful num_attempts="1">
<SequenceStar name="CancelingControlAndWait">
<CancelControl name="ControlCancel"/>
<Wait wait_duration="5"/>
<Wait wait_duration="5.0"/>
</SequenceStar>
</RetryUntilSuccessful>
</PathLongerOnApproach>
Expand All @@ -38,7 +38,7 @@
<ClearEntireCostmap name="ClearGlobalCostmap-Subtree" service_name="global_costmap/clear_entirely_global_costmap"/>
</Sequence>
<Spin spin_dist="1.57"/>
<Wait wait_duration="5"/>
<Wait wait_duration="5.0"/>
<BackUp backup_dist="0.30" backup_speed="0.05"/>
</RoundRobin>
</ReactiveFallback>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
<ClearEntireCostmap name="ClearGlobalCostmap-Subtree" service_name="global_costmap/clear_entirely_global_costmap"/>
</Sequence>
<Spin name="SpinRecovery" spin_dist="1.57"/>
<Wait name="WaitRecovery" wait_duration="5"/>
<Wait name="WaitRecovery" wait_duration="5.0"/>
<BackUp name="BackUpRecovery" backup_dist="0.30" backup_speed="0.05"/>
</RoundRobin>
</ReactiveFallback>
Expand Down