Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
src
cppexamples
orloadviewer.cpp
Go to the documentation of this file.
1
21
#include <
openrave-core.h
>
22
#include <vector>
23
#include <cstring>
24
#include <sstream>
25
26
#include <boost/thread/thread.hpp>
27
#include <boost/bind.hpp>
28
29
using namespace
OpenRAVE;
30
using namespace
std;
31
32
void
SetViewer
(
EnvironmentBasePtr
penv,
const
string
& viewername)
33
{
34
ViewerBasePtr
viewer =
RaveCreateViewer
(penv,viewername);
35
BOOST_ASSERT(!!viewer);
36
37
// attach it to the environment:
38
penv->Add(viewer);
39
40
// finally call the viewer's infinite loop (this is why a separate thread is needed)
41
bool
showgui =
true
;
42
viewer->main(showgui);
43
}
44
45
int
main
(
int
argc,
char
** argv)
46
{
47
//int num = 1;
48
string
scenefilename =
"data/lab1.env.xml"
;
49
string
viewername =
"qtcoin"
;
50
51
// parse the command line options
52
int
i = 1;
53
while
(i < argc) {
54
if
((strcmp(argv[i],
"-h"
) == 0)||(strcmp(argv[i],
"-?"
) == 0)||(strcmp(argv[i],
"/?"
) == 0)||(strcmp(argv[i],
"--help"
) == 0)||(strcmp(argv[i],
"-help"
) == 0)) {
55
RAVELOG_INFO
(
"orloadviewer [--num n] [--scene filename] viewername\n"
);
56
return
0;
57
}
58
else
if
( strcmp(argv[i],
"--scene"
) == 0 ) {
59
scenefilename = argv[i+1];
60
i += 2;
61
}
62
else
63
break
;
64
}
65
if
( i < argc ) {
66
viewername = argv[i++];
67
}
68
69
RaveInitialize
(
true
);
// start openrave core
70
EnvironmentBasePtr
penv =
RaveCreateEnvironment
();
// create the main environment
71
RaveSetDebugLevel
(
Level_Debug
);
72
73
boost::thread thviewer(boost::bind(
SetViewer
,penv,viewername));
74
penv->Load(scenefilename);
// load the scene
75
thviewer.join();
// wait for the viewer thread to exit
76
penv->Destroy();
// destroy
77
return
0;
78
}
Generated on Mon Mar 18 2013 07:25:55 for OpenRAVE by
1.8.2