rdl_urdfreader_util.cc
Go to the documentation of this file.
1 
2 #include "rdl_dynamics/Model.h"
4 
6 
7 using namespace std;
8 
9 bool verbose = false;
10 bool floatbase = false;
11 string filename = "";
12 
13 void usage(const char *argv_0)
14 {
15  cerr << "Usage: " << argv_0 << "[-v] [-m] [-d] <robot.urdf>" << endl;
16  cerr << " -v | --verbose enable additional output" << endl;
17  cerr << " -d | --dof-overview print an overview of the degress of freedom" << endl;
18  cerr << " -m | --model-hierarchy print the hierarchy of the model" << endl;
19  cerr << " -h | --help print this help" << endl;
20  exit(1);
21 }
22 
23 int main(int argc, char *argv[])
24 {
25  if(argc < 2 || argc > 4)
26  {
27  usage(argv[0]);
28  }
29 
30  bool verbose = false;
31  bool dof_overview = false;
32  bool model_hierarchy = false;
33 
34  string filename = argv[1];
35 
36  for(int i = 1; i < argc; i++)
37  {
38  if(string(argv[i]) == "-v" || string(argv[i]) == "--verbose")
39  {
40  verbose = true;
41  }
42  else if(string(argv[i]) == "-d" || string(argv[i]) == "--dof-overview")
43  {
44  dof_overview = true;
45  }
46  else if(string(argv[i]) == "-m" || string(argv[i]) == "--model-hierarchy")
47  {
48  model_hierarchy = true;
49  }
50  else if(string(argv[i]) == "-f" || string(argv[i]) == "--floatbase")
51  {
52  floatbase = true;
53  }
54  else if(string(argv[i]) == "-h" || string(argv[i]) == "--help")
55  {
56  usage(argv[0]);
57  }
58  else
59  {
60  filename = argv[i];
61  }
62  }
63 
65 
66  if(!RobotDynamics::Urdf::urdfReadFromFile(filename.c_str(), model, floatbase, verbose))
67  {
68  cerr << "Loading of urdf model failed!" << endl;
69  return -1;
70  }
71 
72  cout << "Model loading successful!" << endl;
73 
74  if(dof_overview)
75  {
76  cout << "Degree of freedom overview:" << endl;
78  }
79 
80  if(model_hierarchy)
81  {
82  cout << "Model Hierarchy:" << endl;
84  }
85 
86  return 0;
87 }
bool verbose
std::shared_ptr< Model > ModelPtr
std::string getModelHierarchy(const Model &model)
std::string getModelDOFOverview(const Model &model)
bool floatbase
void usage(const char *argv_0)
string filename
int main(int argc, char *argv[])
bool urdfReadFromFile(const char *filename, ModelPtr model, bool floating_base, bool verbose=false)
Read urdf from file path.
Definition: urdfreader.cc:390


rdl_urdfreader
Author(s):
autogenerated on Tue Apr 20 2021 02:25:38