pinocchio_read_model.cpp
Go to the documentation of this file.
1 //
2 // Copyright (c) 2015 CNRS
3 //
4 //
5 // Code adapted from https://bitbucket.org/rbdl/rbdl
6 
7 #include <iostream>
8 
9 #include "pinocchio/multibody/model.hpp"
10 
11 #ifdef PINOCCHIO_WITH_URDFDOM
12  #include "pinocchio/parsers/urdf.hpp"
13 #endif
14 
15 #include "pinocchio/parsers/utils.hpp"
16 
17 using namespace std;
18 
19 void usage (const char* application_name) {
20  cerr << "Usage: " << application_name << " [-v] [-h] <model.extension>" << endl;
21  cerr << " -v | --verbose default parser verbosity" << endl;
22  cerr << " -h | --help print this help" << endl;
23  exit (1);
24 }
25 
26 int main(int argc, char *argv[])
27 {
28  if (argc < 2 || argc > 4) {
29  usage(argv[0]);
30  }
31 
32  std::string filename;
33 
34  bool verbose = false;
35 
36  for (int i = 1; i < argc; i++) {
37  if (string(argv[i]) == "-v" || string (argv[i]) == "--verbose")
38  verbose = true;
39  else if (string(argv[i]) == "-h" || string (argv[i]) == "--help")
40  usage(argv[0]);
41  else
42  filename = argv[i];
43  }
44 
45  // Check extension of the file
48 
49  switch(extension_type)
50  {
51  case pinocchio::URDF:
52 #ifdef PINOCCHIO_WITH_URDFDOM
53  pinocchio::urdf::buildModel(filename,model,verbose);
54 #else
55  std::cerr << "It seems that the URDFDOM module has not been found during the Cmake process." << std::endl;
56 #endif
57  break;
58  case pinocchio::UNKNOWN:
59  std::cerr << "Unknown extension of " << filename << std::endl;
60  return -1;
61  break;
62  }
63  return 0;
64 }
bool verbose
void usage(const char *application_name)
ModelFileExtensionType
Supported model file extensions.
Definition: utils.hpp:27
ModelFileExtensionType checkModelFileExtension(const std::string &filename)
Extract the type of the given model file according to its extension.
Definition: utils.hpp:39
int main(int argc, char *argv[])
ModelTpl< Scalar, Options, JointCollectionTpl > & buildModel(const std::string &filename, const typename ModelTpl< Scalar, Options, JointCollectionTpl >::JointModel &rootJoint, ModelTpl< Scalar, Options, JointCollectionTpl > &model, const bool verbose=false)
Build the model from a URDF file with a particular joint as root of the model tree inside the model g...


pinocchio
Author(s):
autogenerated on Tue Jun 1 2021 02:45:04