BehaviorTree
Core Library to create and execute Behavior Trees
Loading...
Searching...
No Matches
groot2_publisher.h
1#pragma once
2
3#include "behaviortree_cpp/loggers/abstract_logger.h"
4#include "behaviortree_cpp/loggers/groot2_protocol.h"
5
6#include <array>
7#include <future>
8
9namespace BT
10{
11
12/**
13 * @brief The Groot2Publisher is used to create an interface between
14 * your BT.CPP executor and Groot2.
15 *
16 * An inter-process communication mechanism allows the two processes
17 * to communicate through a TCP port. The user should provide the
18 * port to be used in the constructor.
19 */
21{
22 using Position = Monitor::Hook::Position;
23
24public:
25 Groot2Publisher(const BT::Tree& tree, unsigned server_port = 1667);
26
27 ~Groot2Publisher() override;
28
29 Groot2Publisher(const Groot2Publisher& other) = delete;
30 Groot2Publisher& operator=(const Groot2Publisher& other) = delete;
31
32 Groot2Publisher(Groot2Publisher&& other) = delete;
33 Groot2Publisher& operator=(Groot2Publisher&& other) = delete;
34
35 /**
36 * @brief setMaxHeartbeatDelay is used to tell the publisher
37 * when a connection with Groot2 should be cancelled, if no
38 * heartbeat is received.
39 *
40 * Default is 5000 ms
41 */
42 void setMaxHeartbeatDelay(std::chrono::milliseconds delay);
43
44 std::chrono::milliseconds maxHeartbeatDelay() const;
45
46private:
47 void callback(Duration timestamp, const TreeNode& node, NodeStatus prev_status,
48 NodeStatus status) override;
49
50 void flush() override;
51
52 void serverLoop();
53
54 void heartbeatLoop();
55
56 void updateStatusBuffer();
57
58 std::vector<uint8_t> generateBlackboardsDump(const std::string& bb_list);
59
60 bool insertHook(Monitor::Hook::Ptr breakpoint);
61
62 bool unlockBreakpoint(Position pos, uint16_t node_uid, NodeStatus result, bool remove);
63
64 bool removeHook(Position pos, uint16_t node_uid);
65
66 void removeAllHooks();
67
68 Monitor::Hook::Ptr getHook(Position pos, uint16_t node_uid);
69
70 struct PImpl;
71 std::unique_ptr<PImpl> _p;
72
73 void enableAllHooks(bool enable);
74};
75} // namespace BT
The Groot2Publisher is used to create an interface between your BT.CPP executor and Groot2.
Definition: groot2_publisher.h:21
void setMaxHeartbeatDelay(std::chrono::milliseconds delay)
setMaxHeartbeatDelay is used to tell the publisher when a connection with Groot2 should be cancelled,...
Definition: abstract_logger.h:16
Struct used to store a tree. If this object goes out of scope, the tree is destroyed.
Definition: bt_factory.h:96
Abstract base class for Behavior Tree Nodes.
Definition: tree_node.h:154
Definition: action_node.h:24
NodeStatus
Definition: basic_types.h:34
Definition: groot2_protocol.h:202