2 #include <boost/bind.hpp> 3 #include <boost/function.hpp> 4 #include <boost/python.hpp> 5 #include <boost/foreach.hpp> 6 #include <boost/range/value_type.hpp> 9 #include <hrpModel/ModelLoaderUtil.h> 11 #include <GLUT/glut.h> 15 #include <SDL_thread.h> 16 #include "hrpsys/util/GLbody.h" 17 #include "hrpsys/util/GLlink.h" 18 #include "hrpsys/util/GLutil.h" 19 #include "hrpsys/util/Project.h" 20 #include "hrpsys/util/OpenRTMUtil.h" 21 #include "hrpsys/util/BVutil.h" 36 std::cout <<
"createBody(" << name <<
"," << mitem.
url <<
")" << std::endl;
38 std::string args =
"PyBody?instance_name="+name;
43 OpenHRP::ModelLoader::ModelLoadOption opt;
45 opt.AABBdata.length(0);
46 opt.AABBtype = OpenHRP::ModelLoader::AABB_NUM;
47 binfo = modelloader->getBodyInfoEx(mitem.
url.c_str(), opt);
48 }
catch(OpenHRP::ModelLoader::ModelLoaderException ex){
49 std::cerr << ex.description << std::endl;
53 std::cerr <<
"failed to load model[" << mitem.
url <<
"]" << std::endl;
58 for (std::map<std::string, JointItem>::const_iterator it2=mitem.
joint.begin();
59 it2 != mitem.
joint.end(); it2++){
63 if (it2->second.collisionShape ==
""){
65 }
else if (it2->second.collisionShape ==
"convex hull"){
67 }
else if (it2->second.collisionShape ==
"AABB"){
70 std::cerr <<
"unknown value of collisionShape property:" 71 << it2->second.collisionShape << std::endl;
89 useBBox(false), maxLogLen(60)
116 char *argv[] = {(
char *)
"dummy"};
131 std::vector<char *> args(PySequence_Size(pyo)+1);
132 args[0] = (
char *)
"dummy";
133 for (
int i=0;
i<PySequence_Size(pyo);
i++) {
134 args[
i+1] = boost::python::extract<char *>(PySequence_GetItem(pyo,
i));
141 std::string nameServer = manager->
getConfig()[
"corba.nameservers"];
142 int comPos = nameServer.find(
",");
144 comPos = nameServer.length();
146 nameServer = nameServer.substr(0, comPos);
149 ModelLoader_var modelloader =
getModelLoader(CosNaming::NamingContext::_duplicate(
naming.getRootContext()));
150 OpenHRP::BodyInfo_var binfo;
152 binfo = modelloader->loadBodyInfo(url.c_str());
153 }
catch(OpenHRP::ModelLoader::ModelLoaderException ex){
154 std::cerr << ex.description << std::endl;
157 std::string args =
"PyBody?instance_name="+name;
162 std::cerr <<
"failed to load model[" << url <<
"]" << std::endl;
179 if (!prj.
parse(fname)){
180 std::cerr <<
"failed to parse " << fname << std::endl;
185 std::string nameServer = manager->
getConfig()[
"corba.nameservers"];
186 int comPos = nameServer.find(
",");
188 comPos = nameServer.length();
190 nameServer = nameServer.substr(0, comPos);
193 ModelLoader_var modelloader =
getModelLoader(CosNaming::NamingContext::_duplicate(
naming.getRootContext()));
204 std::cout <<
"timestep = " << prj.
timeStep() <<
", total time = " 259 std::string args =
"PyBody?instance_name="+name;
276 boost::python::list retval;
279 retval.append(boost::python::ptr(b));
281 return boost::python::incref(retval.ptr());
291 scene.requestCapture(fname.c_str());
301 return dynamic_cast<PyBody *
>(
body(name).get());
306 return scene.showSensors();
311 scene.showSensors(flag);
329 body(
i)->initializeConfiguration();
347 using namespace boost::python;
349 class_<PySimulator, boost::noncopyable>(
"Simulator")
350 .def(init<PyObject *>())
375 .add_property(
"timeStep",
378 .add_property(
"totalTime",
380 .add_property(
"showSensors",
382 .add_property(
"maxLogLength",
386 class_<PyBody, boost::noncopyable>(
"Body", no_init)
389 .def(
"link", &
PyBody::link, return_internal_reference<>())
406 class_<PyLink, boost::noncopyable>(
"Link", no_init)
438 class_<PyShape, boost::noncopyable>(
"Shape", no_init)
void convertToAABB(hrp::BodyPtr i_body)
void createInPort(const std::string &config)
void enableRingBuffer(int len)
void setRelPosition(PyObject *v)
PyLink * addChildLink(std::string name)
RTObject_impl * createComponent(const char *comp_args)
void setSize(int w, int h)
void deleteComponent(RTObject_impl *comp)
void setWindowSize(int s)
void setTranslationAxis(PyObject *v)
PyObject * getRelPosition()
static hrp::Link * createLink()
PyObject * getRelRotation()
void setRelRotation(PyObject *v)
double timeStep(void) const
void setListener(PySimulator *i_sim)
HRPMODEL_API OpenHRP::ModelLoader_var getModelLoader(CosNaming::NamingContext_var cxt)
bool parse(const std::string &filename)
void setPosition(PyObject *v)
int addBody(BodyPtr body)
void setName(const std::string &name)
void addBody(GLbody *i_body)
virtual void initialize()
void setRotation(PyObject *v)
void runManager(bool no_block=false)
void setInertia(PyObject *v)
void setShowSensors(bool flag)
void setCurrentTime(double tm)
void addCollisionCheckPair(PyBody *b1, PyBody *b2)
void setRootLink(Link *link)
hrp::BodyPtr createBody(const std::string &name, const ModelItem &mitem, ModelLoader_ptr modelloader, GLscene *scene, bool usebbox)
sample RT component which has one data input port and one data output port
GLshape * createPyShape()
void loadShapeFromBodyInfo(GLbody *body, BodyInfo_var i_binfo, GLshape *(*shapeFactory)())
void setJointType(std::string type)
std::vector< std::string > outports
static Manager & instance()
boost::shared_ptr< Body > BodyPtr
void setView(double T[16])
PyBody * getBody(std::string name)
PyBody * createBody(std::string name)
void setRotationAxis(PyObject *v)
LogManager< SceneState > log
PyObject * getRelRotation()
coil::Properties & getConfig()
PyObject * getTranslationAxis()
hrp::Link * GLlinkFactory()
void setUseBBox(bool flag)
void convertToConvexHull(hrp::BodyPtr i_body)
void capture(std::string)
BOOST_PYTHON_MODULE(hrpsysext)
void setAngVel(PyObject *v)
static Manager * init(int argc, char **argv)
PyObject * getRelPosition()
bool loadProject(std::string fname)
std::string getJointType()
void setTotalTime(double time)
void setRelPosition(PyObject *v)
PyObject * getRotationAxis()
void setPosture(PyObject *v)
std::vector< std::string > inports
void setMaxLogLength(double len)
void addCollisionCheckPair(BodyRTC *b1, BodyRTC *b2)
PyShape * addCube(double x, double y, double z)
void setRotation(PyObject *v)
unsigned int numJoints() const
PyLink * link(std::string name)
std::map< std::string, JointItem > joint
void setRelRotation(PyObject *v)
void setTimeStep(double dt)
void setPosition(PyObject *v)
void setDiffuseColor(PyObject *v)
int loadBodyFromBodyInfo(::World *world, const char *_name, BodyInfo_ptr bodyInfo)
void calcForwardKinematics()
double currentTime(void) const
unsigned int numLinks() const
void setLinVel(PyObject *v)
PyObject * getDiffuseColor()
static void moduleInit(RTC::Manager *)
void addShapeFromFile(std::string url)
boost::function2< hrp::BodyPtr, const std::string &, const ModelItem & > BodyFactory
PyBody * loadBody(std::string name, std::string url)
void createOutPort(const std::string &config)
void highlight(bool flag)