TestOrOctomap.cpp
Go to the documentation of this file.
1 // TestOrOctomap.cpp
3 //
4 // Created on: Jan 28, 2014
5 // Author: mklingen
7 
8 #include <openrave-core.h>
9 #include <vector>
10 #include <cstring>
11 #include <sstream>
12 #include <boost/thread/thread.hpp>
13 #include <boost/bind.hpp>
14 
15 using namespace OpenRAVE;
16 using namespace std;
17 void SetViewer(EnvironmentBasePtr penv, const string& viewername)
18 {
19  ViewerBasePtr viewer = RaveCreateViewer(penv, viewername);
20  BOOST_ASSERT(!!viewer);
21  // attach it to the environment:
22  penv->Add(viewer);
23  // finally call the viewer's infinite loop (this is why a separate thread is needed)
24  bool showgui = true;
25  viewer->main(showgui);
26 }
27 
28 int main(int argc, char ** argv)
29 {
30  //int num = 1;
31  string scenefilename = "/opt/pr/pr_ordata/ordata/objects/household/fuze_bottle.kinbody.xml";
32  string viewername = "or_rviz";
33  // parse the command line options
34  int i = 1;
35  while (i < argc)
36  {
37  if ((strcmp(argv[i], "-h") == 0) || (strcmp(argv[i], "-?") == 0)
38  || (strcmp(argv[i], "/?") == 0)
39  || (strcmp(argv[i], "--help") == 0)
40  || (strcmp(argv[i], "-help") == 0))
41  {
42  RAVELOG_INFO(
43  "orloadviewer [--num n] [--scene filename] viewername\n");
44  return 0;
45  }
46  else if (strcmp(argv[i], "--scene") == 0)
47  {
48  scenefilename = argv[i + 1];
49  i += 2;
50  }
51  else
52  break;
53  }
54  if (i < argc)
55  {
56  viewername = argv[i++];
57  }
58  RaveInitialize(true); // start openrave core
59  EnvironmentBasePtr penv = RaveCreateEnvironment(); // create the main environment
60  RaveLoadPlugin("or_octomap");
61  OpenRAVE::SensorSystemBasePtr sensors = RaveCreateSensorSystem(penv, "or_octomap");
62  string out;
63  sensors->SendCommand(out, "Enable");
64  RaveSetDebugLevel(Level_Debug);
65  boost::thread thviewer(boost::bind(SetViewer, penv, viewername));
66  penv->Load(scenefilename); // load the scene
67  thviewer.join(); // wait for the viewer thread to exit
68  penv->Destroy(); // destroy
69  return 0;
70 }
static int argc
Definition: Plugin.cpp:17
static char * argv[1]
Definition: Plugin.cpp:16
int main(int argc, char **argv)
void SetViewer(EnvironmentBasePtr penv, const string &viewername)


or_octomap_plugin
Author(s): Yan Yu
autogenerated on Tue Oct 24 2017 18:02:48