// starting function (executed once at the beginning of the simulation loop) void start(const OdeHandle& odeHandle, const OsgHandle& osgHandle, GlobalData& global) { D=0; setCameraHomePos(Pos(-1.55424, 10.0881, 1.58559), Pos(-170.16, -7.29053, 0)); // initialization // - set noise to 0.1 // - register file chess.ppm as a texture called chessTexture (used for the wheels) global.odeConfig.setParam("noise", 0.05); global.odeConfig.setParam("controlinterval", 1); // global.odeConfig.setParam("gravity", 0); for(int i=0; i< 2; i++){ PassiveBox* b = new PassiveBox(odeHandle, osgHandle.changeColor(Color(0.,0.,0.)), osg::Vec3(1,10,0.3+i*.1),10); b->setPosition(osg::Vec3(30+i*7,0,0)); global.obstacles.push_back(b); } controller=0; /******* S L I D E R - w H E E L I E *********/ SliderWheelieConf mySliderWheelieConf = SliderWheelie::getDefaultConf(); mySliderWheelieConf.segmNumber = segmnum; mySliderWheelieConf.motorPower = 5; mySliderWheelieConf.jointLimitIn = M_PI/3; // mySliderWheelieConf.frictionGround=0.5; // mySliderWheelieConf.segmLength=1.4; mySliderWheelieConf.sliderLength = 0; mySliderWheelieConf.motorType = SliderWheelieConf::CenteredServo; //mySliderWheelieConf.drawCenter = false; vehicle = new SliderWheelie(odeHandle, osgHandle.changeColor(Color(1,222/255.0,0)), mySliderWheelieConf, "sliderWheelie_" + std::itos(teacher*10000)); vehicle->place(Pos(0,0,2)); global.configs.push_back(vehicle); // InvertMotorNStepConf cc = InvertMotorNStep::getDefaultConf(); // cc.cInit=1.0; // cc.useS=false; // cc.someInternalParams=true; // InvertMotorNStep *semox = new InvertMotorNStep(cc); // semox->setParam("steps", 1); // semox->setParam("continuity", 0.005); // semox->setParam("teacher", teacher); SeMoXConf cc = SeMoX::getDefaultConf(); cc.cInit=1.2; cc.modelExt=false; cc.someInternalParams=true; SeMoX* semox = new SeMoX(cc); // AbstractController* controller = new SineController(~0, SineController::Sine); // local variable! // // // motorpower 20 // controller->setParam("period", 300); // controller->setParam("phaseshift", 0.3); if(useSym){ semox->setParam("epsC", 0.1); semox->setParam("epsA", 0.1); }else{ semox->setParam("epsC", 0.1); semox->setParam("epsA", 0.1); } semox->setParam("rootE", 3); semox->setParam("s4avg", 1); semox->setParam("gamma_cont", 0.005); semox->setParam("gamma_teach", teacher); //controller=semox; controller = new CrossMotorCoupling( semox, semox, 0.4); // One2OneWiring* wiring = new One2OneWiring(new ColorUniformNoise(0.1)); AbstractWiring* wiring = new FeedbackWiring(new ColorUniformNoise(0.1), FeedbackWiring::Motor, 0.75); //global.plotoptions.push_back(PlotOption(GuiLogger,Robot,5)); OdeAgent* agent = new OdeAgent(global); agent->addCallbackable(&stats); agent->init(controller, vehicle, wiring); if(track) agent->setTrackOptions(TrackRobot(true,false,false, false, change < 50 ? std::itos(change).c_str() : "uni", 50)); global.agents.push_back(agent); global.configs.push_back(controller); this->getHUDSM()->setColor(Color(1.0,1.0,0)); this->getHUDSM()->setFontsize(18); this->getHUDSM()->addMeasure(teacher,"Gamma_s",ID,1); this->getHUDSM()->addMeasure(D,"D",ID,1); // if(useSym){ // int k= 0; // std::list<int> perm; // int len = controller->getMotorNumber(); // for(int i=0; i<len; i++){ // perm.push_back((i+k+(len)/2)%len); // } // CMC cmc = controller->getPermutationCMC(perm); // controller->setCMC(cmc); // } }
// starting function (executed once at the beginning of the simulation loop) void start(const OdeHandle& odeHandle, const OsgHandle& osgHandle, GlobalData& global) { setCameraHomePos(Pos(-0.777389, 6.34573, 1.83396), Pos(-170.594, -5.10046, 0)); setCameraMode(Follow); // initialization // - set noise to 0.1 // - register file chess.ppm as a texture called chessTexture (used for the wheels) global.odeConfig.setParam("noise", 0.05); global.odeConfig.setParam("controlinterval", 1); global.odeConfig.setParam("realtimefactor", 1); // global.odeConfig.setParam("gravity", 0); for(int i=0; i< 4; i++){ PassiveBox* b = new PassiveBox(odeHandle, osgHandle.changeColor(Color(.6, .6, .4)), osg::Vec3(1,10,0.3+i*0.02),0); b->setTexture(0,TextureDescr("Images/playfulmachines.rgb",1,1)); b->setPosition(osg::Vec3(-75+i*30,0,0)); global.obstacles.push_back(b); } controller=0; /******* S L I D E R - w H E E L I E *********/ SliderWheelieConf mySliderWheelieConf = SliderWheelie::getDefaultConf(); mySliderWheelieConf.segmNumber = segmnum; mySliderWheelieConf.motorPower = 5; mySliderWheelieConf.jointLimitIn = M_PI/3; // mySliderWheelieConf.frictionGround=0.5; // mySliderWheelieConf.segmLength=1.4; mySliderWheelieConf.sliderLength = 0; mySliderWheelieConf.motorType = SliderWheelieConf::CenteredServo; //mySliderWheelieConf.drawCenter = false; vehicle = new SliderWheelie(odeHandle, osgHandle.changeColor(Color(1,222/255.0,0)), mySliderWheelieConf, "Armband"); vehicle->place(Pos(0,0,.1)); SeMoXConf cc = SeMoX::getDefaultConf(); cc.cInit=1.1; cc.modelExt=false; cc.someInternalParams=false; SeMoX* semox = new SeMoX(cc); if(useSym){ semox->setParam("epsC", 0.1); semox->setParam("epsA", 0.1); }else{ semox->setParam("epsC", 0.1); semox->setParam("epsA", 0.1); } semox->setParam("rootE", 3); semox->setParam("s4avg", 1); semox->setParam("gamma_cont", 0.005); semox->setParam("gamma_teach", teacher); //controller=semox; controller = new CrossMotorCoupling( semox, semox, 0.4); // One2OneWiring* wiring = new One2OneWiring(new ColorUniformNoise(0.1)); AbstractWiring* wiring = new FeedbackWiring(new ColorUniformNoise(0.1), FeedbackWiring::Motor, 0.75); //global.plotoptions.push_back(PlotOption(GuiLogger,Robot,5)); OdeAgent* agent = new OdeAgent(global); agent->addCallbackable(&stats); agent->init(controller, vehicle, wiring); if(track) agent->setTrackOptions(TrackRobot(true,false,false, false, "uni", 20)); global.agents.push_back(agent); global.configs.push_back(agent); thisConfig.controller=controller; global.configs.push_back(&thisConfig); this->getHUDSM()->setColor(osgHandle.getColor("hud")); this->getHUDSM()->setFontsize(16); // this->getHUDSM()->setColor(Color(1.0,1.0,0)); // this->getHUDSM()->setFontsize(18); this->getHUDSM()->addMeasure(teacher,"Gamma",ID,1); this->getHUDSM()->addMeasure(thisConfig.D_display,"D",ID,1); // if(useSym){ // int k= 0; // std::list<int> perm; // int len = controller->getMotorNumber(); // for(int i=0; i<len; i++){ // perm.push_back((i+k+(len)/2)%len); // } // CMC cmc = controller->getPermutationCMC(perm); // controller->setCMC(cmc); // } }