Skip to content

Commit

Permalink
adds an option size to hrpsys-simulator-python
Browse files Browse the repository at this point in the history
git-svn-id: https://hrpsys-base.googlecode.com/svn/trunk@448 a991ac11-fb38-5095-8c12-a1ddb0715245
  • Loading branch information
fkanehiro committed Aug 13, 2012
1 parent 5873cdd commit aa088ec
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 7 deletions.
1 change: 1 addition & 0 deletions doc/utilities.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ realtime execute simulation in real-time<br>
usebbox use bounding boxes instead of actual geometries<br>
endless never finish simulation<br>
showsensor show sensor output<br>
size [size] set window size<br>
Note:NameSever and openhrp-model-loader must be running
Expand Down
5 changes: 5 additions & 0 deletions lib/util/SDLUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -354,3 +354,8 @@ void SDLwindow::setView(double T[16])
radius = sqrt(SQR(xCenter - T[3])+SQR(yCenter - T[7])+SQR(zCenter - T[11]));
}

void SDLwindow::setSize(int w, int h)
{
width = w;
height = h;
}
1 change: 1 addition & 0 deletions lib/util/SDLUtil.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class SDLwindow : public ThreadedObject
void swapBuffers();
bool oneStep();
void setView(double T[16]);
void setSize(int w, int h);
private:
double sliderRatio(double x);
GLsceneBase *scene;
Expand Down
6 changes: 6 additions & 0 deletions util/simulator/PySimulator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,11 @@ void PySimulator::setUseBBox(bool flag)
useBBox = flag;
}

void PySimulator::setWindowSize(int s)
{
window.setSize(s,s);
}

BOOST_PYTHON_MODULE( hrpsys )
{
using namespace boost::python;
Expand All @@ -331,6 +336,7 @@ BOOST_PYTHON_MODULE( hrpsys )
.def("simulate", (void(PySimulator::*)(double))&PySimulator::simulate)
.def("realTime", &PySimulator::realTime)
.def("useBBox", &PySimulator::setUseBBox)
.def("windowSize", &PySimulator::setWindowSize)
.def("endless", &PySimulator::endless)
.def("start", &PySimulator::start)
.def("stop", &PySimulator::stop)
Expand Down
1 change: 1 addition & 0 deletions util/simulator/PySimulator.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class PySimulator : public Simulator
void setShowSensors(bool flag);
void reset();
void setUseBBox(bool flag);
void setWindowSize(int s);
private:
LogManager<SceneState> log;
GLscene scene;
Expand Down
2 changes: 1 addition & 1 deletion util/simulator/hrpsys-simulator-jython.in
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def runSimulator(*args):
argc = len(sys.argv)

if argc < 2:
print "Usage: hrpsys-simulator project.xml [script.py] [options for sdlsim]"
print "Usage: hrpsys-simulator-jython project.xml [script.py] [options for hrpsys-simulator]"
sys.exit(1)

if sys.argv[2][(len(sys.argv[2])-3):] == ".py":
Expand Down
15 changes: 9 additions & 6 deletions util/simulator/hrpsys-simulator-python.in
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,20 @@ else:
nodisplay = False
usebbox = False
endless = False
for arg in sys.argv:
if arg == "realtime":
for i in range(len(sys.argv)):
if sys.argv[i] == "realtime":
sim.realTime(True)
elif arg == "endless":
elif sys.argv[i] == "endless":
endless = True
elif arg == "nodisplay":
elif sys.argv[i] == "nodisplay":
nodisplay = True
elif arg == "showsensors":
elif sys.argv[i] == "showsensors":
sim.showSensors = True
elif arg == "usebbox":
elif sys.argv[i] == "usebbox":
sim.useBBox(True)
elif sys.argv[i] == "size":
sim.windowSize(int(sys.argv[i+1]))
i = i+1
if sim.loadProject(project):
if endless:
sim.endless(True)
Expand Down

0 comments on commit aa088ec

Please sign in to comment.