Skip to content

Commit abe4149

Browse files
SteveMacenskithandalantonkesyCihatAltiparmakakchobby
authored
Humble Sync 9: Jan 23, 2024 (#4064)
* Update README.md: fix typo (#3842) * Update package.xml * fix typo (#3850) * adjust link to point to v3.8 of behavior tree docs (#3851) BT.CPP_v3 is used, thereby the correct docs should be linked * Fix bug in nav2_behavior_tree/bt_action_node (#3849) * Fix bug in nav2_behavior_tree/bt_action_node * Fixed the bug in halt function inside nav2_behavior_tree/plugin/action/bt_action_node.hpp * Added new case to nav2_behavior_tree/plugin/action/bt_action_node.hpp for testing the scenario to cancel * Refactored existing cases in nav2_behavior_tree/plugin/action/bt_action_node.hpp Signed-off-by: CihatAltiparmak <[email protected]> * Fix bug in nav2_behavior_tree/bt_action_node * Fixed the bug in halt function inside nav2_behavior_tree/plugin/action/bt_action_node.hpp * Added new case to nav2_behavior_tree/plugin/action/bt_action_node.hpp for testing the scenario to cancel * Refactored existing cases in nav2_behavior_tree/plugin/action/bt_action_node.hpp Signed-off-by: CihatAltiparmak <[email protected]> --------- Signed-off-by: CihatAltiparmak <[email protected]> * simplication of lattice_generator.py, fixes #3858 (#3859) * simplification of equation to compute the max_value/outer edge of the lattice based on number of headings. * Fix class doxygen * fix minor typos (#3892) Signed-off-by: Anton Kesy <[email protected]> * fix use after free (#3910) * fix build mppi (#3927) Signed-off-by: kevin <[email protected]> Co-authored-by: kevin <[email protected]> * Removing old TODOs * Fixed links for install and build in README (#3963) Currently the readme is linking to an invalida page in the docs (404 error). * fix a few outdated comments in smac planners (#3978) * Update README.md * bump to 1.1.13 for release --------- Signed-off-by: CihatAltiparmak <[email protected]> Signed-off-by: Anton Kesy <[email protected]> Signed-off-by: kevin <[email protected]> Co-authored-by: thandal <[email protected]> Co-authored-by: Anton Kesy <[email protected]> Co-authored-by: CihatAltiparmak <[email protected]> Co-authored-by: Anil Kumar Chavali <[email protected]> Co-authored-by: 정찬희 <[email protected]> Co-authored-by: kevin <[email protected]> Co-authored-by: Abiel Fernandez <[email protected]> Co-authored-by: Michael Ferguson <[email protected]>
1 parent d29de3d commit abe4149

File tree

62 files changed

+244
-102
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+244
-102
lines changed

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
For detailed instructions on how to:
1010
- [Getting Started](https://navigation.ros.org/getting_started/index.html)
1111
- [Concepts](https://navigation.ros.org/concepts/index.html)
12-
- [Build](https://navigation.ros.org/build_instructions/index.html#build)
13-
- [Install](https://navigation.ros.org/build_instructions/index.html#install)
12+
- [Build](https://navigation.ros.org/development_guides/build_docs/index.html#build)
13+
- [Install](https://navigation.ros.org/development_guides/build_docs/index.html#install)
1414
- [General Tutorials](https://navigation.ros.org/tutorials/index.html) and [Algorithm Developer Tutorials](https://navigation.ros.org/plugin_tutorials/index.html)
1515
- [Configure](https://navigation.ros.org/configuration/index.html)
1616
- [Navigation Plugins](https://navigation.ros.org/plugins/index.html)
@@ -20,6 +20,8 @@ For detailed instructions on how to:
2020

2121
Please visit our [documentation site](https://navigation.ros.org/). [Please visit our community Slack here](https://join.slack.com/t/navigation2/shared_invite/zt-hu52lnnq-cKYjuhTY~sEMbZXL8p9tOw) (if this link does not work, please contact maintainers to reactivate).
2222

23+
If you need professional services related to Nav2, please contact Open Navigation at [email protected].
24+
2325
## Our Sponsors
2426

2527
Please thank our amazing sponsors for their generous support of Nav2 on behalf of the community to allow the project to continue to be professionally maintained, developed, and supported for the long-haul! [Open Navigation LLC](https://www.opennav.org/) provides project leadership, maintenance, development, and support services to the Nav2 & ROS community.

nav2_amcl/package.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
33
<package format="3">
44
<name>nav2_amcl</name>
5-
<version>1.1.12</version>
5+
<version>1.1.13</version>
66
<description>
77
<p>
88
amcl is a probabilistic localization system for a robot moving in

nav2_behavior_tree/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,4 +63,4 @@ The BehaviorTree engine has a run method that accepts an XML description of a BT
6363
6464
See the code in the [BT Navigator](../nav2_bt_navigator/src/bt_navigator.cpp) for an example usage of the BehaviorTreeEngine.
6565
66-
For more information about the behavior tree nodes that are available in the default BehaviorTreeCPP library, see documentation here: https://www.behaviortree.dev/docs/learn-the-basics/bt_basics/
66+
For more information about the behavior tree nodes that are available in the default BehaviorTreeCPP library, see documentation here: https://www.behaviortree.dev/docs/3.8/learn-the-basics/BT_basics

nav2_behavior_tree/include/nav2_behavior_tree/bt_action_node.hpp

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ class BtActionNode : public BT::ActionNodeBase
162162
}
163163

164164
/**
165-
* @brief Function to perform some user-defined operation whe the action is aborted.
165+
* @brief Function to perform some user-defined operation when the action is aborted.
166166
* @return BT::NodeStatus Returns FAILURE by default, user may override return another value
167167
*/
168168
virtual BT::NodeStatus on_aborted()
@@ -265,7 +265,7 @@ class BtActionNode : public BT::ActionNodeBase
265265
// Action related failure that should not fail the tree, but the node
266266
return BT::NodeStatus::FAILURE;
267267
} else {
268-
// Internal exception to propogate to the tree
268+
// Internal exception to propagate to the tree
269269
throw e;
270270
}
271271
}
@@ -299,6 +299,7 @@ class BtActionNode : public BT::ActionNodeBase
299299
void halt() override
300300
{
301301
if (should_cancel_goal()) {
302+
auto future_result = action_client_->async_get_result(goal_handle_);
302303
auto future_cancel = action_client_->async_cancel_goal(goal_handle_);
303304
if (callback_group_executor_.spin_until_future_complete(future_cancel, server_timeout_) !=
304305
rclcpp::FutureReturnCode::SUCCESS)
@@ -307,6 +308,16 @@ class BtActionNode : public BT::ActionNodeBase
307308
node_->get_logger(),
308309
"Failed to cancel action server for %s", action_name_.c_str());
309310
}
311+
312+
if (callback_group_executor_.spin_until_future_complete(future_result, server_timeout_) !=
313+
rclcpp::FutureReturnCode::SUCCESS)
314+
{
315+
RCLCPP_ERROR(
316+
node_->get_logger(),
317+
"Failed to get result for %s in node halt!", action_name_.c_str());
318+
}
319+
320+
on_cancelled();
310321
}
311322

312323
setStatus(BT::NodeStatus::IDLE);

nav2_behavior_tree/package.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
33
<package format="3">
44
<name>nav2_behavior_tree</name>
5-
<version>1.1.12</version>
5+
<version>1.1.13</version>
66
<description>TODO</description>
77
<maintainer email="[email protected]">Michael Jeronimo</maintainer>
88
<maintainer email="[email protected]">Carlos Orduno</maintainer>

nav2_behavior_tree/test/plugins/action/test_bt_action_node.cpp

Lines changed: 132 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,17 @@ class FibonacciActionServer : public rclcpp::Node
5454
sleep_duration_ = sleep_duration;
5555
}
5656

57+
void setServerLoopRate(std::chrono::nanoseconds server_loop_rate)
58+
{
59+
server_loop_rate_ = server_loop_rate;
60+
}
61+
5762
protected:
5863
rclcpp_action::GoalResponse handle_goal(
5964
const rclcpp_action::GoalUUID &,
6065
std::shared_ptr<const test_msgs::action::Fibonacci::Goal>)
6166
{
67+
RCLCPP_INFO(this->get_logger(), "Goal is received..");
6268
if (sleep_duration_ > 0ms) {
6369
std::this_thread::sleep_for(sleep_duration_);
6470
}
@@ -73,6 +79,13 @@ class FibonacciActionServer : public rclcpp::Node
7379

7480
void handle_accepted(
7581
const std::shared_ptr<rclcpp_action::ServerGoalHandle<test_msgs::action::Fibonacci>> handle)
82+
{
83+
// this needs to return quickly to avoid blocking the executor, so spin up a new thread
84+
std::thread{std::bind(&FibonacciActionServer::execute, this, _1), handle}.detach();
85+
}
86+
87+
void execute(
88+
const std::shared_ptr<rclcpp_action::ServerGoalHandle<test_msgs::action::Fibonacci>> handle)
7689
{
7790
// this needs to return quickly to avoid blocking the executor, so spin up a new thread
7891
if (handle) {
@@ -88,8 +101,17 @@ class FibonacciActionServer : public rclcpp::Node
88101
sequence.push_back(0);
89102
sequence.push_back(1);
90103

104+
rclcpp::Rate rate(server_loop_rate_);
91105
for (int i = 1; (i < goal->order) && rclcpp::ok(); ++i) {
106+
if (handle->is_canceling()) {
107+
RCLCPP_INFO(this->get_logger(), "Goal is canceling.");
108+
handle->canceled(result);
109+
return;
110+
}
111+
112+
RCLCPP_INFO(this->get_logger(), "Goal is feedbacking.");
92113
sequence.push_back(sequence[i] + sequence[i - 1]);
114+
rate.sleep();
93115
}
94116

95117
handle->succeed(result);
@@ -99,6 +121,7 @@ class FibonacciActionServer : public rclcpp::Node
99121
protected:
100122
rclcpp_action::Server<test_msgs::action::Fibonacci>::SharedPtr action_server_;
101123
std::chrono::milliseconds sleep_duration_;
124+
std::chrono::nanoseconds server_loop_rate_;
102125
};
103126

104127
class FibonacciAction : public nav2_behavior_tree::BtActionNode<test_msgs::action::Fibonacci>
@@ -121,6 +144,13 @@ class FibonacciAction : public nav2_behavior_tree::BtActionNode<test_msgs::actio
121144
return BT::NodeStatus::SUCCESS;
122145
}
123146

147+
BT::NodeStatus on_cancelled() override
148+
{
149+
config().blackboard->set<std::vector<int>>("sequence", result_.result->sequence);
150+
config().blackboard->set<bool>("on_cancelled_triggered", true);
151+
return BT::NodeStatus::SUCCESS;
152+
}
153+
124154
static BT::PortsList providedPorts()
125155
{
126156
return providedBasicPorts({BT::InputPort<int>("order", "Fibonacci order")});
@@ -144,6 +174,7 @@ class BTActionNodeTestFixture : public ::testing::Test
144174
config_->blackboard->set<std::chrono::milliseconds>("server_timeout", 20ms);
145175
config_->blackboard->set<std::chrono::milliseconds>("bt_loop_duration", 10ms);
146176
config_->blackboard->set<bool>("initial_pose_received", false);
177+
config_->blackboard->set<bool>("on_cancelled_triggered", false);
147178

148179
BT::NodeBuilder builder =
149180
[](const std::string & name, const BT::NodeConfiguration & config)
@@ -220,6 +251,7 @@ TEST_F(BTActionNodeTestFixture, test_server_timeout_success)
220251

221252
// setting a small action server goal handling duration
222253
action_server_->setHandleGoalSleepDuration(2ms);
254+
action_server_->setServerLoopRate(10ns);
223255

224256
// to keep track of the number of ticks it took to reach a terminal result
225257
int ticks = 0;
@@ -255,15 +287,22 @@ TEST_F(BTActionNodeTestFixture, test_server_timeout_success)
255287
// start a new execution cycle with the previous BT to ensure previous state doesn't leak into
256288
// the new cycle
257289

258-
// halt BT for a new execution cycle
290+
// halt BT for a new execution cycle,
291+
// get if the on_cancelled is triggered from blackboard and assert
292+
// that the on_cancelled triggers after halting node
293+
RCLCPP_INFO(node_->get_logger(), "Tree is halting.");
259294
tree_->haltTree();
295+
bool on_cancelled_triggered = config_->blackboard->get<bool>("on_cancelled_triggered");
296+
EXPECT_EQ(on_cancelled_triggered, false);
260297

261298
// setting a large action server goal handling duration
262299
action_server_->setHandleGoalSleepDuration(100ms);
300+
action_server_->setServerLoopRate(10ns);
263301

264302
// reset state variables
265303
ticks = 0;
266304
result = BT::NodeStatus::RUNNING;
305+
config_->blackboard->set<bool>("on_cancelled_triggered", false);
267306

268307
// main BT execution loop
269308
while (rclcpp::ok() && result == BT::NodeStatus::RUNNING) {
@@ -300,6 +339,7 @@ TEST_F(BTActionNodeTestFixture, test_server_timeout_failure)
300339

301340
// the action server will take 100ms before accepting the goal
302341
action_server_->setHandleGoalSleepDuration(100ms);
342+
action_server_->setServerLoopRate(10ns);
303343

304344
// to keep track of the number of ticks it took to reach a terminal result
305345
int ticks = 0;
@@ -327,14 +367,21 @@ TEST_F(BTActionNodeTestFixture, test_server_timeout_failure)
327367
// the new cycle
328368

329369
// halt BT for a new execution cycle
370+
// get if the on_cancel is triggered from blackboard and assert
371+
// that the on_cancelled never can trigger after halting node
372+
RCLCPP_INFO(node_->get_logger(), "Tree is halting.");
330373
tree_->haltTree();
374+
bool on_cancelled_triggered = config_->blackboard->get<bool>("on_cancelled_triggered");
375+
EXPECT_EQ(on_cancelled_triggered, false);
331376

332377
// setting a small action server goal handling duration
333378
action_server_->setHandleGoalSleepDuration(25ms);
379+
action_server_->setServerLoopRate(10ns);
334380

335381
// reset state variables
336382
ticks = 0;
337383
result = BT::NodeStatus::RUNNING;
384+
config_->blackboard->set<bool>("on_cancelled_triggered", false);
338385

339386
// main BT execution loop
340387
while (rclcpp::ok() && result == BT::NodeStatus::RUNNING) {
@@ -348,6 +395,90 @@ TEST_F(BTActionNodeTestFixture, test_server_timeout_failure)
348395
EXPECT_EQ(result, BT::NodeStatus::SUCCESS);
349396
}
350397

398+
TEST_F(BTActionNodeTestFixture, test_server_cancel)
399+
{
400+
// create tree
401+
std::string xml_txt =
402+
R"(
403+
<root main_tree_to_execute = "MainTree" >
404+
<BehaviorTree ID="MainTree">
405+
<Fibonacci order="1000000" />
406+
</BehaviorTree>
407+
</root>)";
408+
409+
// setting a server timeout smaller than the time the action server will take to accept the goal
410+
// to simulate a server timeout scenario
411+
config_->blackboard->set<std::chrono::milliseconds>("server_timeout", 100ms);
412+
config_->blackboard->set<std::chrono::milliseconds>("bt_loop_duration", 10ms);
413+
414+
tree_ = std::make_shared<BT::Tree>(factory_->createTreeFromText(xml_txt, config_->blackboard));
415+
416+
// the action server will take 2ms before accepting the goal
417+
// and the feedback period of the action server will be 50ms
418+
action_server_->setHandleGoalSleepDuration(2ms);
419+
action_server_->setServerLoopRate(50ms);
420+
421+
// to keep track of the number of ticks it took to reach expected tick count
422+
int ticks = 0;
423+
424+
BT::NodeStatus result = BT::NodeStatus::RUNNING;
425+
426+
// BT loop execution rate
427+
rclcpp::WallRate loopRate(100ms);
428+
429+
// main BT execution loop
430+
while (rclcpp::ok() && result == BT::NodeStatus::RUNNING && ticks < 5) {
431+
result = tree_->tickRoot();
432+
ticks++;
433+
loopRate.sleep();
434+
}
435+
436+
// halt BT for testing if the action node cancels the goal correctly
437+
RCLCPP_INFO(node_->get_logger(), "Tree is halting.");
438+
tree_->haltTree();
439+
440+
// get if the on_cancel is triggered from blackboard and assert
441+
// that the on_cancel is triggered after halting node
442+
bool on_cancelled_triggered = config_->blackboard->get<bool>("on_cancelled_triggered");
443+
EXPECT_EQ(on_cancelled_triggered, true);
444+
445+
// ticks variable must be 5 because execution time of the action server
446+
// is at least 1000000 x 50 ms
447+
EXPECT_EQ(ticks, 5);
448+
449+
// send new goal to the action server for a new execution cycle
450+
451+
// the action server will take 2ms before accepting the goal
452+
// and the feedback period of the action server will be 1000ms
453+
action_server_->setHandleGoalSleepDuration(2ms);
454+
action_server_->setServerLoopRate(50ms);
455+
456+
// reset state variable
457+
ticks = 0;
458+
config_->blackboard->set<bool>("on_cancelled_triggered", false);
459+
result = BT::NodeStatus::RUNNING;
460+
461+
// main BT execution loop
462+
while (rclcpp::ok() && result == BT::NodeStatus::RUNNING && ticks < 7) {
463+
result = tree_->tickRoot();
464+
ticks++;
465+
loopRate.sleep();
466+
}
467+
468+
// halt BT for testing if the action node cancels the goal correctly
469+
RCLCPP_INFO(node_->get_logger(), "Tree is halting.");
470+
tree_->haltTree();
471+
472+
// get if the on_cancel is triggered from blackboard and assert
473+
// that the on_cancel is triggered after halting node
474+
on_cancelled_triggered = config_->blackboard->get<bool>("on_cancelled_triggered");
475+
EXPECT_EQ(on_cancelled_triggered, true);
476+
477+
// ticks variable must be 7 because execution time of the action server
478+
// is at least 1000000 x 50 ms
479+
EXPECT_EQ(ticks, 7);
480+
}
481+
351482
int main(int argc, char ** argv)
352483
{
353484
::testing::InitGoogleTest(&argc, argv);

nav2_behaviors/package.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
33
<package format="3">
44
<name>nav2_behaviors</name>
5-
<version>1.1.12</version>
5+
<version>1.1.13</version>
66
<description>TODO</description>
77
<maintainer email="[email protected]">Carlos Orduno</maintainer>
88
<maintainer email="[email protected]">Steve Macenski</maintainer>

nav2_bringup/package.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
33
<package format="3">
44
<name>nav2_bringup</name>
5-
<version>1.1.12</version>
5+
<version>1.1.13</version>
66
<description>Bringup scripts and configurations for the Nav2 stack</description>
77
<maintainer email="[email protected]">Michael Jeronimo</maintainer>
88
<maintainer email="[email protected]">Steve Macenski</maintainer>

nav2_bt_navigator/include/nav2_bt_navigator/navigators/navigate_through_poses.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ namespace nav2_bt_navigator
3232
{
3333

3434
/**
35-
* @class NavigateToPoseNavigator
35+
* @class NavigateThroughPosesNavigator
3636
* @brief A navigator for navigating to a a bunch of intermediary poses
3737
*/
3838
class NavigateThroughPosesNavigator

nav2_bt_navigator/package.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
33
<package format="3">
44
<name>nav2_bt_navigator</name>
5-
<version>1.1.12</version>
5+
<version>1.1.13</version>
66
<description>TODO</description>
77
<maintainer email="[email protected]">Michael Jeronimo</maintainer>
88
<license>Apache-2.0</license>

0 commit comments

Comments
 (0)