Esempio n. 1
0
    void ReadFile(RobotBasePtr& probot, const std::string& filename, const AttributesList& atts)
    {
        std::ifstream f(filename.c_str());
        if( !f ) {
            throw OPENRAVE_EXCEPTION_FORMAT("failed to read %s filename",filename,ORE_InvalidArguments);
        }
        f.seekg(0,ios::end);
        std::vector<char> filedata(static_cast<size_t>(f.tellg())+1, 0); // need a null-terminator
        f.seekg(0,ios::beg);
        f.read(&filedata[0], filedata.size());
        Read(probot,filedata,atts);
        probot->__struri = filename;
#if defined(HAVE_BOOST_FILESYSTEM) && BOOST_VERSION >= 103600 // stem() was introduced in 1.36
        boost::filesystem::path bfpath(filename);
#if defined(BOOST_FILESYSTEM_VERSION) && BOOST_FILESYSTEM_VERSION >= 3
        probot->SetName(utils::ConvertToOpenRAVEName(bfpath.stem().string()));
#else
        probot->SetName(utils::ConvertToOpenRAVEName(bfpath.stem()));
#endif
#endif
    }
Esempio n. 2
0
 void Read(RobotBasePtr& probot, const std::vector<char>& data,const AttributesList& atts)
 {
     _ProcessAtts(atts);
     if( !probot ) {
         probot = RaveCreateRobot(_penv,_bodytype);
     }
     probot->SetName(_bodyname);
     Assimp::XFileParserOpenRAVE parser(data);
     _Read(probot,parser.GetImportedData());
     if( probot->GetName().size() == 0 ) {
         probot->SetName("robot");
     }
     // add manipulators
     FOREACH(itmanip,_listendeffectors) {
         RobotBase::ManipulatorInfo manipinfo;
         manipinfo._name = itmanip->first->_info._name;
         manipinfo._sEffectorLinkName = itmanip->first->GetName();
         manipinfo._sBaseLinkName = probot->GetLinks().at(0)->GetName();
         manipinfo._tLocalTool = itmanip->second;
         manipinfo._vdirection=Vector(1,0,0);
         probot->_vecManipulators.push_back(RobotBase::ManipulatorPtr(new RobotBase::Manipulator(probot,manipinfo)));
     }