Exemplo n.º 1
0
bool  ObjectRenderer::Load(string name){
    char filename[256];
    XmlTree tree;
    sprintf(filename,"Worlds/Objects/%s.xml",name.c_str());
    if(FileFinder::Find(filename)){
        tree.LoadFromFile(FileFinder::GetCStr());
    }
    return Load(&tree);
}
Exemplo n.º 2
0
bool World::Load(string name){
    char filename[256];
    XmlTree tree;
    sprintf(filename,"Worlds/%s.xml",name.c_str());
    if(FileFinder::Find(filename)){
        if(tree.LoadFromFile(FileFinder::GetString())){
            return Load(&tree);
        }
    }
    return false;
}
RobotInterface::Status ExampleOpenLoopPIDControlModule::RobotInit(){

    // Sensors and actuators
    mSensorsGroup.SetSensorsList(mRobot->GetSensors());
    mActuatorsGroup.SetActuatorsList(mRobot->GetActuators());


    mJointTorques.Resize(mRobot->GetDOFCount());
    mJointTarget.Resize(mRobot->GetDOFCount());
    //mJointTorques.Print();



    if(mInternalRobot.Load(mRobot->GetType(),mRobot->GetSubType(),"")){
        cout << "Internal robot loaded as a copy of main robbot"<<endl;
    }else{
        cout << "Failed loading internal robot"<<endl;
        exit(0);
    }


    mInternalSensorsGroup.SetSensorsList(mInternalRobot.GetSensors());
    mInternalActuatorsGroup.SetActuatorsList(mInternalRobot.GetActuators());

    // Inverse dynamics
    mInvDynamics.SetRobot(mRobot);
    mInvDynamics.Init();
    mInvDynamics.SetGravityCompensationOnly(true);

    XmlTree tree;
    tree.LoadFromFile("./data/packages/WAMRobotModel/Misc/WAMDefaultPID.xml");
    mPIDCtrl.Init(&tree);

    mState  = 0;


    if(GetConsole()){
        AddConsoleCommand("Rest");
        AddConsoleCommand("Hit");
        AddConsoleCommand("GComp");
        GetConsole()->Print("Available commands are GComp Rest and Hit");
    }

    return STATUS_OK;
}
void MultiFingersObjImpController::LoadStructureXml(const char* xmlFileName)
{
    XmlTree config;
    bool bSuccess = config.LoadFromFile(xmlFileName);
    if(bSuccess)
    {
        //parse the xml file - config file for RobotToolKit
        pXmlTreeList pTList = config.GetSubTrees();
        vector<string> nameAndPatches;

        FileFinder::AddAdditionalPath("./config");
        FileFinder::AddAdditionalPath("./data");

        for(int i = 0; i < int(pTList->size()); ++i)
        {
            if(pTList->at(i)->GetName() == "Robot")
            {
                printf("Loading robot structure...\n");
                nameAndPatches = Tokenize(RemoveSpaces(pTList->at(i)->GetData()));
                if(nameAndPatches.size() > 0)
                {
                    bSuccess = mRobot.Load(nameAndPatches[0], Serialize(nameAndPatches, 1));
                    if(!bSuccess)
                    {
                        printf("Fail to load robot structure file.\n");
                    }
                    else
                    {
                        printf("Successfully load robot structure.\n");
                    }
                }
            }
        }
    }
    else
    {
        printf("Fail to load configuration file.\n");
    }
    return;
}