Main Page
Modules
Namespaces
Classes
Files
File List
File Members
sample_nodes
movebase_node.cpp
Go to the documentation of this file.
1
#include "
movebase_node.h
"
2
#include "
behaviortree_cpp/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 periodicall _halt_requested and interrupt
26
// this tick() if it is true.
27
while
(!
_halt_requested
&& count++ < 25)
28
{
29
SleepMS
(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
}
bt_factory.h
MoveBaseAction::tick
BT::NodeStatus tick() override
Method to be implemented by the user.
Definition:
movebase_node.cpp:11
BT::NodeStatus::SUCCESS
Pose2D
Definition:
movebase_node.h:7
SleepMS
void SleepMS(int ms)
Definition:
movebase_node.h:12
Pose2D::x
double x
Definition:
movebase_node.h:9
BT_REGISTER_NODES
BT_REGISTER_NODES(factory)
Definition:
movebase_node.cpp:6
BT::RuntimeError
Definition:
exceptions.h:60
Pose2D::theta
double theta
Definition:
movebase_node.h:9
MoveBaseAction::_halt_requested
std::atomic_bool _halt_requested
Definition:
movebase_node.h:68
BT::NodeStatus::FAILURE
minitrace::count
static volatile int count
Definition:
minitrace.cpp:55
BT::NodeStatus
NodeStatus
Definition:
basic_types.h:35
MoveBaseAction
Definition:
movebase_node.h:48
Pose2D::y
double y
Definition:
movebase_node.h:9
movebase_node.h
MoveBaseAction::halt
virtual void halt() override
Definition:
movebase_node.cpp:36
behaviortree_cpp
Author(s): Michele Colledanchise, Davide Faconti
autogenerated on Sat Jun 8 2019 18:04:05