7 #include "behaviortree_cpp/flatbuffers/BT_logger_generated.h"
23 struct sigaction action;
26 sigemptyset(&action.sa_mask);
27 sigaction(SIGINT, &action,
nullptr);
28 sigaction(SIGTERM, &action,
nullptr);
32 int main(
int argc,
char* argv[])
36 printf(
"Wrong number of arguments\nUsage: %s [filename]\n", argv[0]);
46 std::cout <<
"Trying to connect to [tcp://localhost:1666]\n" << std::endl;
49 subscriber.
connect(
"tcp://localhost:1666");
52 subscriber.set(zmq::sockopt::subscribe,
"");
54 printf(
"----------- Started -----------------\n");
56 bool first_message =
true;
57 std::ofstream file_os;
65 auto ret = subscriber.recv(update, zmq::recv_flags::none);
72 std::cout <<
"subscriber.recv() failed with exception: " << e.
what() << std::endl;
79 char* data_ptr =
static_cast<char*
>(update.
data());
80 const uint32_t header_size = flatbuffers::ReadScalar<uint32_t>(data_ptr);
84 printf(
"First message received\n");
85 first_message =
false;
88 file_os.write(data_ptr, 4 + header_size);
90 data_ptr += 4 + header_size;
92 const uint32_t transition_count = flatbuffers::ReadScalar<uint32_t>(data_ptr);
93 data_ptr +=
sizeof(uint32_t);
95 file_os.write(data_ptr, 12 * transition_count);
101 printf(
"Results saved to file\n");