Skip to content

Commit f9b0a88

Browse files
authored
adding the uid to the log to uniquely identify the nodes (#502)
Signed-off-by: Christian Henkel <[email protected]>
1 parent 662aea2 commit f9b0a88

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

tools/bt_log_cat.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,18 +33,22 @@ int main(int argc, char* argv[])
3333

3434
std::unordered_map<uint16_t, std::string> names_by_uid;
3535
std::unordered_map<uint16_t, const Serialization::TreeNode*> node_by_uid;
36+
uint16_t max_uid = 0;
3637

3738
for (const Serialization::TreeNode* node : *(behavior_tree->nodes()))
3839
{
3940
names_by_uid.insert({node->uid(), std::string(node->instance_name()->c_str())});
4041
node_by_uid.insert({node->uid(), node});
42+
max_uid = std::max(max_uid, node->uid());
4143
}
44+
uint16_t digits_max_uid = std::to_string(max_uid).size();
4245

4346
printf("----------------------------\n");
4447

4548
std::function<void(uint16_t, int)> recursiveStep;
4649

4750
recursiveStep = [&](uint16_t uid, int indent) {
51+
printf("(%*d): ", digits_max_uid, uid);
4852
for (int i = 0; i < indent; i++)
4953
{
5054
printf(" ");
@@ -98,7 +102,8 @@ int main(int argc, char* argv[])
98102
const uint32_t t_sec = flatbuffers::ReadScalar<uint32_t>(&buffer[index]);
99103
const uint32_t t_usec = flatbuffers::ReadScalar<uint32_t>(&buffer[index + 4]);
100104

101-
printf("[%d.%06d]: %s%s %s -> %s\n", t_sec, t_usec, name.c_str(),
105+
printf("[%d.%06d] (%*d): %s%s %s -> %s\n", t_sec, t_usec,
106+
digits_max_uid, uid, name.c_str(),
102107
&whitespaces[std::min(ws_count, name.size())],
103108
printStatus(flatbuffers::ReadScalar<Serialization::NodeStatus>(&buffer[index + 10])),
104109
printStatus(flatbuffers::ReadScalar<Serialization::NodeStatus>(&buffer[index + 11])));

0 commit comments

Comments
 (0)