MCPcopy Create free account
hub / github.com/BehaviorTree/BehaviorTree.CPP / callback

Method callback

src/loggers/groot2_publisher.cpp:200–226  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

198}
199
200void Groot2Publisher::callback(Duration ts, const TreeNode& node, NodeStatus prev_status,
201 NodeStatus new_status)
202{
203 const std::unique_lock<std::mutex> lk(_p->status_mutex);
204 auto status = static_cast<char>(new_status);
205
206 if(new_status == NodeStatus::IDLE)
207 {
208 status = static_cast<char>(10 + static_cast<int>(prev_status));
209 }
210 *(_p->status_buffermap.at(node.UID())) = status;
211
212 if(_p->recording)
213 {
214 Transition trans{};
215 trans.node_uid = node.UID();
216 trans.status = static_cast<uint8_t>(new_status);
217 auto timestamp = ts - _p->recording_fist_time;
218 trans.timestamp_usec =
219 std::chrono::duration_cast<std::chrono::microseconds>(timestamp).count();
220 _p->transitions_buffer.push_back(trans);
221 while(_p->transitions_buffer.size() > 1000)
222 {
223 _p->transitions_buffer.pop_front();
224 }
225 }
226}
227
228void Groot2Publisher::flush()
229{

Callers

nothing calls this directly

Calls 3

UIDMethod · 0.80
push_backMethod · 0.80
sizeMethod · 0.45

Tested by

no test coverage detected