Skip to content

Commit

Permalink
Change output file of urdf_to_graphiz (#144)
Browse files Browse the repository at this point in the history
* Add extra argument for output file
* Add deprecated warning
* Add usage string

Co-authored-by: hwied <[email protected]>
  • Loading branch information
hwiedPro and hwied authored Oct 30, 2020
1 parent 6faba17 commit afd0ae2
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions urdf_parser/src/urdf_to_graphiz.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,18 @@ void printTree(LinkConstSharedPtr link, string file)

int main(int argc, char** argv)
{
if (argc != 2){
std::cerr << "Usage: urdf_to_graphiz input.xml" << std::endl;
if (argc < 2 || argc > 3) {
std::cerr << "Usage: urdf_to_graphiz input.xml [OUTPUT]"
<< " Will create either $ROBOT_NAME.gv & $ROBOT_NAME.pdf in CWD"
<< " or OUTPUT.gv & OUTPUT.pdf." << std::endl;
return -1;
}
if (argc != 3) {
std::cerr << "WARNING: OUTPUT not given. This type of usage is deprecated!"
<< "Usage: urdf_to_graphiz input.xml [OUTPUT]"
<< " Will create either $ROBOT_NAME.gv & $ROBOT_NAME.pdf in CWD"
<< " or OUTPUT.gv & OUTPUT.pdf." << std::endl;
}

// get the entire file
std::string xml_string;
Expand All @@ -106,7 +114,10 @@ int main(int argc, char** argv)
std::cerr << "ERROR: Model Parsing the xml failed" << std::endl;
return -1;
}

string output = robot->getName();
if (argc == 3)
output = argv[2];

// print entire tree to file
printTree(robot->getRoot(), output+".gv");
Expand Down

0 comments on commit afd0ae2

Please sign in to comment.