Skip to content

Commit

Permalink
Improve dotgraph
Browse files Browse the repository at this point in the history
  • Loading branch information
Levi-Armstrong committed Jul 24, 2024
1 parent d307c66 commit 8ff54de
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 27 deletions.
21 changes: 11 additions & 10 deletions tesseract_task_composer/core/src/task_composer_graph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -352,15 +352,15 @@ TaskComposerGraph::dump(std::ostream& os,

std::ostringstream sub_graphs;
const std::string tmp = toString(uuid_);
os << "subgraph cluster_" << tmp << " {\n color=black;\n label = \"" << name_ << "\\n(" << uuid_str_ << ")";
os << "\\n Inputs: " << input_keys_;
os << "\\n Outputs: " << output_keys_;
os << "\\n Conditional: " << ((conditional_) ? "True" : "False");
os << "subgraph cluster_" << tmp << " {\n color=black;\n label = \"" << name_ << "\\nUUID: " << uuid_str_ << "\\n";
os << "Inputs:\\l" << input_keys_;
os << "Outputs:\\l" << output_keys_;
os << "Conditional: " << ((conditional_) ? "True" : "False") << "\\l";
if (getType() == TaskComposerNodeType::PIPELINE || getType() == TaskComposerNodeType::GRAPH)
{
auto it = results_map.find(getUUID());
if (it != results_map.end())
os << "\\nTime: " << std::fixed << std::setprecision(3) << it->second->elapsed_time << "s";
os << "Time: " << std::fixed << std::setprecision(3) << it->second->elapsed_time << "s\\l";
}
os << "\";";
for (const auto& pair : nodes_)
Expand All @@ -377,12 +377,13 @@ TaskComposerGraph::dump(std::ostream& os,
const std::string tmp = toString(node->uuid_, "node_");
const TaskComposerKeys& input_keys = node->getInputKeys();
const TaskComposerKeys& output_keys = node->getOutputKeys();
os << std::endl << tmp << " [shape=box3d, label=\"Subgraph: " << node->name_ << "\\n(" << node->uuid_str_ << ")";
os << "\\n Inputs: " << input_keys;
os << "\\n Outputs: " << output_keys;
os << "\\n Conditional: " << ((node->isConditional()) ? "True" : "False");
os << std::endl
<< tmp << " [shape=box3d, label=\"Subgraph: " << node->name_ << "\\nUUID: " << node->uuid_str_ << "\\n";
os << "Inputs:\\l" << input_keys;
os << "Outputs:\\l" << output_keys;
os << "Conditional: " << ((node->isConditional()) ? "True" : "False") << "\\l";
if (it != results_map.end())
os << "\\nTime: " << std::fixed << std::setprecision(3) << it->second->elapsed_time << "s";
os << "Time: " << std::fixed << std::setprecision(3) << it->second->elapsed_time << "s\\l";

os << "\", margin=\"0.1\", color=" << color << "];\n"; // NOLINT
node->dump(sub_graphs, this, results_map);
Expand Down
10 changes: 3 additions & 7 deletions tesseract_task_composer/core/src/task_composer_keys.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,17 +87,16 @@ void TaskComposerKeys::serialize(Archive& ar, const unsigned int /*version*/)

std::ostream& operator<<(std::ostream& os, const TaskComposerKeys& keys)
{
os << "[";
std::size_t cnt{ 0 };
for (const auto& pair : keys.data())
{
if (pair.second.index() == 0)
{
os << pair.first << ":" << std::get<std::string>(pair.second);
os << "\t" << pair.first << ": " << std::get<std::string>(pair.second);
}
else
{
os << pair.first << ":[";
os << "\t" << pair.first << ":[";
const auto& vs = std::get<std::vector<std::string>>(pair.second);
for (std::size_t i = 0; i < vs.size(); ++i)
{
Expand All @@ -107,12 +106,9 @@ std::ostream& operator<<(std::ostream& os, const TaskComposerKeys& keys)
}
os << "]";
}
if (cnt < keys.size() - 1)
os << ", ";

os << "\\l";
++cnt;
}
os << "]";

return os;
}
Expand Down
25 changes: 15 additions & 10 deletions tesseract_task_composer/core/src/task_composer_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -363,14 +363,16 @@ TaskComposerNode::dump(std::ostream& os,
if (conditional_)
{
os << std::endl << tmp << " [shape=diamond, label=\"" << name_ << "\\n";
os << "Namespace: " << ns_ << "\\n(" << uuid_str_ << ")";
os << "\\n Inputs: " << input_keys_;
os << "\\n Outputs: " << output_keys_;
os << "UUID: " << uuid_str_ << "\\n";
os << "Namespace: " << ns_ << "\\l";
os << "Inputs:\\l" << input_keys_;
os << "Outputs:\\l" << output_keys_;

if (it != results_map.end())
{
os << "\\nTime: " << std::fixed << std::setprecision(3) << it->second->elapsed_time << "s"
<< "\\n`" << std::to_string(it->second->status_code) << "::" << it->second->status_message << "`";
os << "Time: " << std::fixed << std::setprecision(3) << it->second->elapsed_time << "s\\l"
<< "Status Code: " << std::to_string(it->second->status_code) << "\\l"
<< "Status Msg: " << it->second->status_message << "\\l";
}
os << "\", color=black, fillcolor=" << color << ", style=filled];\n";

Expand All @@ -384,14 +386,17 @@ TaskComposerNode::dump(std::ostream& os,
}
else
{
os << std::endl << tmp << " [label=\"" << name_ << "\\n(" << uuid_str_ << ")";
os << "\\n Inputs: " << input_keys_;
os << "\\n Outputs: " << output_keys_;
os << std::endl << tmp << " [label=\"" << name_ << "\\n";
os << "UUID: " << uuid_str_ << "\\n";
os << "Namespace: " << ns_ << "\\l";
os << "Inputs:\\l" << input_keys_;
os << "Outputs:\\l" << output_keys_;

if (it != results_map.end())
{
os << "\\nTime: " << std::fixed << std::setprecision(3) << it->second->elapsed_time << "s"
<< "\\n'" << std::to_string(it->second->status_code) << "::" << it->second->status_message << "'";
os << "Time: " << std::fixed << std::setprecision(3) << it->second->elapsed_time << "s\\l"
<< "Status Code: " << std::to_string(it->second->status_code) << "\\l"
<< "Status Msg: " << it->second->status_message << "\\l";
}
os << "\", color=black, fillcolor=" << color << ", style=filled];\n";

Expand Down

0 comments on commit 8ff54de

Please sign in to comment.