sample_nodes
movebase_node.cpp
Go to the documentation of this file.
1
#include "
movebase_node.h
"
2
#include "
behaviortree_cpp_v3/bt_factory.h
"
3
4
// This function must be implemented in the .cpp file to create
5
// a plugin that can be loaded at run-time
6
BT_REGISTER_NODES
(factory)
7
{
8
factory.registerNodeType<
MoveBaseAction
>(
"MoveBase"
);
9
}
10
11
BT::NodeStatus
MoveBaseAction::tick
()
12
{
13
Pose2D
goal;
14
if
( !getInput<Pose2D>(
"goal"
, goal))
15
{
16
throw
BT::RuntimeError
(
"missing required input [goal]"
);
17
}
18
19
printf(
"[ MoveBase: STARTED ]. goal: x=%.f y=%.1f theta=%.2f\n"
, goal.
x
, goal.
y
, goal.
theta
);
20
21
_halt_requested
.store(
false
);
22
int
count
= 0;
23
24
// Pretend that "computing" takes 250 milliseconds.
25
// It is up to you to check periodically _halt_requested and interrupt
26
// this tick() if it is true.
27
while
(!
_halt_requested
&&
count
++ < 25)
28
{
29
std::this_thread::sleep_for(std::chrono::milliseconds(10));
30
}
31
32
std::cout <<
"[ MoveBase: FINISHED ]"
<< std::endl;
33
return
_halt_requested
?
BT::NodeStatus::FAILURE
:
BT::NodeStatus::SUCCESS
;
34
}
35
36
void
MoveBaseAction::halt
()
37
{
38
_halt_requested
.store(
true
);
39
}
Pose2D
Definition:
ex04_waypoints.cpp:16
minitrace::count
static volatile int count
Definition:
minitrace.cpp:55
bt_factory.h
MoveBaseAction
Definition:
movebase_node.h:43
MoveBaseAction::halt
virtual void halt() override
Definition:
movebase_node.cpp:36
movebase_node.h
BT::NodeStatus::FAILURE
@ FAILURE
MoveBaseAction::tick
BT::NodeStatus tick() override
Method to be implemented by the user.
Definition:
movebase_node.cpp:11
BT::RuntimeError
Definition:
exceptions.h:58
Pose2D::y
double y
Definition:
ex04_waypoints.cpp:18
BT::NodeStatus::SUCCESS
@ SUCCESS
BT_REGISTER_NODES
BT_REGISTER_NODES(factory)
Definition:
movebase_node.cpp:6
MoveBaseAction::_halt_requested
std::atomic_bool _halt_requested
Definition:
movebase_node.h:63
Pose2D::theta
double theta
Definition:
ex04_waypoints.cpp:18
Pose2D::x
double x
Definition:
ex04_waypoints.cpp:18
BT::NodeStatus
NodeStatus
Definition:
basic_types.h:35
behaviortree_cpp_v3
Author(s): Michele Colledanchise, Davide Faconti
autogenerated on Wed Jun 26 2024 02:51:19