movebase_node.h
Go to the documentation of this file.
1 #ifndef MOVEBASE_BT_NODES_H
2 #define MOVEBASE_BT_NODES_H
3 
5 
6 // Custom type
7 struct Pose2D
8 {
9  double x, y, theta;
10 };
11 
12 namespace BT
13 {
14 // This template specialization is needed only if you want
15 // to AUTOMATICALLY convert a NodeParameter into a Pose2D
16 // In other words, implement it if you want to be able to do:
17 //
18 // TreeNode::getInput<Pose2D>(key, ...)
19 //
20 template <> inline
22 {
23  // three real numbers separated by semicolons
24  auto parts = BT::splitString(key, ';');
25  if (parts.size() != 3)
26  {
27  throw BT::RuntimeError("invalid input)");
28  }
29  else
30  {
31  Pose2D output;
32  output.x = convertFromString<double>(parts[0]);
33  output.y = convertFromString<double>(parts[1]);
34  output.theta = convertFromString<double>(parts[2]);
35  return output;
36  }
37 }
38 } // end namespace BT
39 
40 // This is an asynchronous operation that will run in a separate thread.
41 // It requires the input port "goal".
42 
44 {
45  public:
46  // Any TreeNode with ports must have a constructor with this signature
47  MoveBaseAction(const std::string& name, const BT::NodeConfiguration& config)
49  {
50  }
51 
52  // It is mandatory to define this static method.
54  {
55  return{ BT::InputPort<Pose2D>("goal") };
56  }
57 
58  BT::NodeStatus tick() override;
59 
60  virtual void halt() override;
61 
62  private:
63  std::atomic_bool _halt_requested;
64 };
65 
66 #endif // MOVEBASE_BT_NODES_H
BT
Definition: ex01_wrap_legacy.cpp:29
Pose2D
Definition: ex04_waypoints.cpp:16
BT::AsyncActionNode
The AsyncActionNode uses a different thread, where the action will be executed.
Definition: action_node.h:114
BT::PortsList
std::unordered_map< std::string, PortInfo > PortsList
Definition: basic_types.h:342
MoveBaseAction
Definition: movebase_node.h:43
BT::TreeNode::config
const NodeConfiguration & config() const
Definition: tree_node.cpp:127
BT::NodeConfiguration
Definition: tree_node.h:44
BT::convertFromString
Point3D convertFromString(StringView key)
Definition: ex01_wrap_legacy.cpp:32
MoveBaseAction::halt
virtual void halt() override
Definition: movebase_node.cpp:36
MoveBaseAction::tick
BT::NodeStatus tick() override
Method to be implemented by the user.
Definition: movebase_node.cpp:11
BT::RuntimeError
Definition: exceptions.h:58
BT::splitString
std::vector< StringView > splitString(const StringView &strToSplit, char delimeter)
Definition: basic_types.cpp:267
Pose2D::y
double y
Definition: ex04_waypoints.cpp:18
behavior_tree.h
MoveBaseAction::MoveBaseAction
MoveBaseAction(const std::string &name, const BT::NodeConfiguration &config)
Definition: movebase_node.h:47
MoveBaseAction::providedPorts
static BT::PortsList providedPorts()
Definition: movebase_node.h:53
BT::TreeNode::name
const std::string & name() const
Name of the instance, not the type.
Definition: tree_node.cpp:101
MoveBaseAction::_halt_requested
std::atomic_bool _halt_requested
Definition: movebase_node.h:63
BT::convertFromString< double >
double convertFromString< double >(StringView str)
Definition: basic_types.cpp:127
BT::AsyncActionNode::AsyncActionNode
AsyncActionNode(const std::string &name, const NodeConfiguration &config)
Definition: action_node.h:117
Pose2D::theta
double theta
Definition: ex04_waypoints.cpp:18
Pose2D::x
double x
Definition: ex04_waypoints.cpp:18
BT::StringView
nonstd::string_view StringView
Definition: basic_types.h:55
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