movebase_node.cpp
Go to the documentation of this file.
1 #include "movebase_node.h"
3 
4 // This function must be implemented in the .cpp file to create
5 // a plugin that can be loaded at run-time
7 {
8  factory.registerNodeType<MoveBaseAction>("MoveBase");
9 }
10 
12 {
13  if(!getInput<Pose2D>("goal", _goal))
14  {
15  throw BT::RuntimeError("missing required input [goal]");
16  }
17  printf("[ MoveBase: SEND REQUEST ]. goal: x=%.1f y=%.1f theta=%.1f\n", _goal.x, _goal.y,
18  _goal.theta);
19 
20  // We use this counter to simulate an action that takes a certain
21  // amount of time to be completed (220 ms)
22  _completion_time = chr::system_clock::now() + chr::milliseconds(220);
23 
25 }
26 
28 {
29  // Pretend that we are checking if the reply has been received
30  // you don't want to block inside this function too much time.
31  std::this_thread::sleep_for(chr::milliseconds(10));
32 
33  // Pretend that, after a certain amount of time,
34  // we have completed the operation
35  if(chr::system_clock::now() >= _completion_time)
36  {
37  std::cout << "[ MoveBase: FINISHED ]" << std::endl;
39  }
41 }
42 
44 {
45  printf("[ MoveBase: ABORTED ]");
46 }
bt_factory.h
MoveBaseAction
Definition: movebase_node.h:54
MoveBaseAction::_goal
Pose2D _goal
Definition: movebase_node.h:79
movebase_node.h
BT::RuntimeError
Definition: exceptions.h:58
Pose2D::y
double y
Definition: t18_waypoints.cpp:15
BT::NodeStatus::SUCCESS
@ SUCCESS
BT_REGISTER_NODES
BT_REGISTER_NODES(factory)
Definition: movebase_node.cpp:6
BT::NodeStatus::RUNNING
@ RUNNING
MoveBaseAction::onHalted
void onHalted() override
Definition: movebase_node.cpp:43
MoveBaseAction::_completion_time
chr::system_clock::time_point _completion_time
Definition: movebase_node.h:80
MoveBaseAction::onRunning
BT::NodeStatus onRunning() override
method invoked when the action is already in the RUNNING state.
Definition: movebase_node.cpp:27
Pose2D::theta
double theta
Definition: t18_waypoints.cpp:15
Pose2D::x
double x
Definition: t18_waypoints.cpp:15
BT::NodeStatus
NodeStatus
Definition: basic_types.h:33
MoveBaseAction::onStart
BT::NodeStatus onStart() override
Definition: movebase_node.cpp:11


behaviortree_cpp_v4
Author(s): Davide Faconti
autogenerated on Fri Jun 28 2024 02:20:07