示例#1
0
 virtual void addCallback(GlobalData& globalData, bool draw, bool pause, bool control) {
   if(!pause){
     if(friction>0){
       OdeRobot* robot = globalData.agents[0]->getRobot();
       Pos vel = robot->getMainPrimitive()->getAngularVel();
       robot->getMainPrimitive()->applyTorque(-vel*friction);
     }
   }
 }
示例#2
0
文件: main.cpp 项目: Sosi/lpzrobots
 /** is called if a key was pressed.
     For keycodes see: osgGA::GUIEventAdapter
     @return true if the key was handled
 */
 virtual bool command(const OdeHandle&, const OsgHandle&, GlobalData& globalData,
                      int key, bool down) {
   if (down) { // only when key is pressed, not when released
     switch ( (char) key ) {
     case 'T' : robot->getMainPrimitive()->applyTorque(0 , 0 , 3 ); break;
     case 't' : robot->getMainPrimitive()->applyTorque(0 , 0 , -3 ); break;
     default:
       return false;
     }
     return true;
   } else return false;
 }
示例#3
0
 // add own key handling stuff here, just insert some case values
 virtual bool command(const OdeHandle&, const OsgHandle&, GlobalData& globalData, int key, bool down)
 {
   if (down) { // only when key is pressed, not when released
     switch ( (char) key )
       {
       case 'y' : dBodyAddForce ( sphere1->getMainPrimitive()->getBody() , 30 ,0 , 0 ); break;
       case 'Y' : dBodyAddForce ( sphere1->getMainPrimitive()->getBody() , -30 , 0 , 0 ); break;
       case 'x' : dBodyAddTorque ( sphere1->getMainPrimitive()->getBody() , 0 , 10 , 0 ); break;
       case 'X' : dBodyAddTorque ( sphere1->getMainPrimitive()->getBody() , 0 , -10 , 0 ); break;
       case 'S' : controller->setParam("sinerate", controller->getParam("sinerate")*1.2);
         printf("sinerate : %g\n", controller->getParam("sinerate"));
         break;
       case 's' : controller->setParam("sinerate", controller->getParam("sinerate")/1.2);
         printf("sinerate : %g\n", controller->getParam("sinerate"));
         break;
       default:
         return false;
         break;
       }
   }
   return false;
 }
示例#4
0
  // 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);
//     }



  }
示例#5
0
    // starting function (executed once at the beginning of the simulation loop)
    void start(const OdeHandle& odeHandle, const OsgHandle& osgHandle, GlobalData& global)
    {
        setCameraHomePos(Pos(-6.32561, 5.12705, 3.17278),  Pos(-130.771, -17.7744, 0));


        global.odeConfig.setParam("noise", 0.05);
        global.odeConfig.setParam("controlinterval", 2);
        global.odeConfig.setParam("cameraspeed", 250);
        global.odeConfig.setParam("gravity", -6);
        setParam("UseQMPThread", false);

        // use Playground as boundary:
        AbstractGround* playground =
            new Playground(odeHandle, osgHandle, osg::Vec3(8, 0.2, 1), 1);
        //     // playground->setColor(Color(0,0,0,0.8));
        playground->setGroundColor(Color(2,2,2,1));
        playground->setPosition(osg::Vec3(0,0,0.05)); // playground positionieren und generieren
        global.obstacles.push_back(playground);

        Boxpile* boxpile = new Boxpile(odeHandle, osgHandle);
        boxpile->setColor("wall");
        boxpile->setPose(ROTM(M_PI/5.0,0,0,1)*TRANSM(0, 0,0.2));
        global.obstacles.push_back(boxpile);


        //     global.obstacles.push_back(playground);
        // double diam = .90;
        // OctaPlayground* playground3 = new OctaPlayground(odeHandle, osgHandle, osg::Vec3(/*Diameter*/4.0*diam, 5,/*Height*/ .3), 12,
        //                                                  false);
        // //  playground3->setColor(Color(.0,0.2,1.0,1));
        // playground3->setPosition(osg::Vec3(0,0,0)); // playground positionieren und generieren
        // global.obstacles.push_back(playground3);

        controller=0;

        //    addParameter("gamma_s",&teacher);
        global.configs.push_back(this);

        for(int i=0; i< bars; 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(10+i*7,0,0));
            global.obstacles.push_back(b);
        }

        /*******  H E X A P O D  *********/
        int numhexapods = 1;
        for ( int ii = 0; ii< numhexapods; ii++) {

            HexapodConf myHexapodConf        = Hexapod::getDefaultConf();
            myHexapodConf.coxaPower          = 1.5;
            myHexapodConf.tebiaPower         = 0.8;
            myHexapodConf.coxaJointLimitV    = .9; // M_PI/8;  // angle range for vertical dir. of legs
            myHexapodConf.coxaJointLimitH    = 1.3; //M_PI/4;
            myHexapodConf.tebiaJointLimit    = 1.8; // M_PI/4; // +- 45 degree
            myHexapodConf.percentageBodyMass = .5;
            myHexapodConf.useBigBox          = false;
            myHexapodConf.tarsus             = true;
            myHexapodConf.numTarsusSections  = 1;
            myHexapodConf.useTarsusJoints    = true;
            //    myHexapodConf.numTarsusSections = 2;

            OdeHandle rodeHandle = odeHandle;
            rodeHandle.substance.toRubber(20);


            vehicle = new Hexapod(rodeHandle, osgHandle.changeColor("Green"),
                                  myHexapodConf, "Hexapod_" + std::itos(teacher*10000));

            // on the top
            vehicle->place(osg::Matrix::rotate(M_PI*1,1,0,0)*osg::Matrix::translate(0,0,1.5+ 2*ii));
            // normal position
            //    vehicle->place(osg::Matrix::translate(0,0,0));

//     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);

            SoMLConf sc = SoML::getDefaultConf();
            sc.useHiddenContr=true;
            sc.useHiddenModel=false;
            sc.someInternalParams=false;
            sc.useS=false;
            SoML* soml = new SoML(sc);
            soml->setParam("epsC",0.105);
            soml->setParam("epsA",0.05);

            Sox* sox = new Sox(1.2, false);
            sox->setParam("epsC",0.105);
            sox->setParam("epsA",0.05);
            sox->setParam("Logarithmic",1);


            SeMoXConf cc = SeMoX::getDefaultConf();
            //cc.cInit=.95;
            cc.cInit=.99;
            cc.modelExt=false;
            cc.someInternalParams=true;
            SeMoX* semox = new SeMoX(cc);

            DerInfConf dc = DerInf::getDefaultConf();
            dc.cInit=.599;
            dc.someInternalParams=false;
            AbstractController* derinf = new DerInf(dc);
            derinf->setParam("epsC",0.1);
            derinf->setParam("epsA",0.05);

            AbstractController* sine = 0;
            if(useSineController) {
                // sine = new SineController(~0, SineController::Sine);
                sine = new SineController(~0, SineController::Impulse);
                // //     // //     // motorpower 20
                sine->setParam("period", 30);
                sine->setParam("phaseshift", 0.5);
                sine->setParam("amplitude", 0.5);
            }

            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);


            if(useSineController) {
                controller = sine;
            } else {
                //      controller = semox;
                controller = sox;
                //  controller = soml;
                // controller = derinf;
            }

            One2OneWiring* wiring = new One2OneWiring(new ColorUniformNoise(0.1));
            // the feedbackwiring feeds here 75% of the motor actions as inputs and only 25% of real inputs
//     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->init(controller, vehicle, wiring);
            // add an operator to keep robot from falling over
            agent->addOperator(new LimitOrientationOperator(Axis(0,0,1), Axis(0,0,1), M_PI*0.5, 30));
            if(track) {
                TrackRobotConf c = TrackRobot::getDefaultConf();
                c.displayTrace = true;
                c.scene        = "";
                c.interval     = 1;
                c.trackSpeed   = false;
                c.displayTraceThickness = 0.01;
                agent->setTrackOptions(TrackRobot(c));
            }
            if(tracksegm) {
                TrackRobotConf c   = TrackRobot::getDefaultConf();
                Color      col = osgHandle.getColor("joint");
                c.displayTrace = true;
                c.scene        = "segm";
                c.interval     = 1;
                c.displayTraceThickness = 0.02;
                col.alpha()    = 0.5;
                agent->addTracking(5, TrackRobot(c), col);
                agent->addTracking(8, TrackRobot(c), col);
            }

            global.agents.push_back(agent);
            global.configs.push_back(agent);
            //agent->startMotorBabblingMode(5000);

            // this->getHUDSM()->setColor(Color(1.0,1.0,0));
            // this->getHUDSM()->setFontsize(18);
            // this->getHUDSM()->addMeasure(teacher,"gamma_s",ID,1);

        }
    }
示例#6
0
  // starting function (executed once at the beginning of the simulation loop)
  void start(const OdeHandle& odeHandle, const OsgHandle& osgHandle, GlobalData& global)
  {
    int num_barrels=1;
    int num_barrels_test=0;

    sensor=0;
    setCameraMode(Follow);

    bool normalplayground=false;

    //    setCameraHomePos(Pos(-0.497163, 11.6358, 3.67419),  Pos(-179.213, -11.6718, 0));
    setCameraHomePos(Pos(-2.60384, 13.1299, 2.64348),  Pos(-179.063, -9.7594, 0));
    // initialization
    global.odeConfig.setParam("noise",0.1);
    //  global.odeConfig.setParam("gravity",-10);
    global.odeConfig.setParam("controlinterval",4);
    global.odeConfig.setParam("realtimefactor",5);

    // add a new parameter to be configured on the console
    global.odeConfig.addParameterDef("friction", &friction, 0.1, "rolling friction coefficient");


    if(normalplayground){
      Playground* playground = new Playground(odeHandle, osgHandle,osg::Vec3(20, 0.01, 0.01 ), 1);
      playground->setGroundColor(Color(255/255.0,200/255.0,0/255.0));
      playground->setGroundTexture("Images/really_white.rgb");
      playground->setColor(Color(255/255.0,200/255.0,21/255.0, 0.1));
      playground->setPosition(osg::Vec3(0,0,0.05));
      global.obstacles.push_back(playground);
    }


    /* * * * BARRELS * * * */
    for(int i=0; i< num_barrels; i++){
      //****************
      Sphererobot3MassesConf conf = Barrel2Masses::getDefaultConf();
      conf.pendularrange  = 0.3;//0.15;
      conf.motorpowerfactor  = 200;//150;
      conf.motorsensor=false;
      conf.addSensor(new AxisOrientationSensor(AxisOrientationSensor::ZProjection, Sensor::X | Sensor::Y));
      conf.spheremass   = 1;

      conf.addSensor(new SpeedSensor(10, SpeedSensor::Translational, Sensor::X ));
      conf.irAxis1=false;
      conf.irAxis2=false;
      conf.irAxis3=false;
      conf.axesShift = 0;
      // conf.axesShift = conf.diameter/2 - conf.pendularrange/2;
      sphere1 = new Barrel2Masses ( odeHandle, osgHandle.changeColor(Color(0.0,0.0,1.0)),
                                    conf, "Barrel1", 0.4);

      sphere1->place (osg::Matrix::rotate(M_PI/2, 1,0,0)*osg::Matrix::translate(0,0,0.2));

      // InvertMotorNStepConf cc = InvertMotorNStep::getDefaultConf();
      // cc.cInit=1;
      // //    cc.useSD=true;
      // controller = new InvertMotorNStep(cc);

      // controller->setParam("steps", 2);
      // controller->setParam("adaptrate", 0.0);
      // controller->setParam("nomupdate", 0.00);
      // controller->setParam("epsC", 0.03);
      // controller->setParam("epsA", 0.05);
      // controller->setParam("rootE", 0);
      // controller->setParam("logaE", 0);
      //controller = new PiMax();
      //controller->setParam("epsC", 0.001);

      // controller = new Sox();
      // controller->setParam("epsC", 0.5);
      controller = new ROSController("Test");

      AbstractWiring* wiring = new SelectiveOne2OneWiring(new ColorUniformNoise(), new select_from_to(0,1));
      //      OdeAgent* agent = new OdeAgent ( PlotOption(File, Robot, 1) );
      OdeAgent* agent = new OdeAgent ();
      agent->init ( controller , sphere1 , wiring );
      //  agent->setTrackOptions(TrackRobot(true, false, false, "ZSens_Ring10_11", 50));
      global.agents.push_back ( agent );
      global.configs.push_back ( controller );
    }


    /* * * * TEST BARRELS * * * */
    for(int i=0; i< num_barrels_test; i++){
      global.odeConfig.setParam("realtimefactor",1);
      //****************
      Sphererobot3MassesConf conf = Sphererobot3Masses::getDefaultConf();
      conf.pendularrange  = 0.15;
      conf.motorsensor=true;
      conf.irAxis1=false;
      conf.irAxis2=false;
      conf.irAxis3=false;
      conf.spheremass   = 1;
      sphere1 = new Barrel2Masses ( odeHandle, osgHandle.changeColor(Color(0.0,0.0,1.0)),
                                    conf, "Barrel1", 0.4);
      sphere1->place ( osg::Matrix::rotate(M_PI/2, 1,0,0));

      controller = new SineController();
      controller->setParam("sinerate", 15);
      controller->setParam("phaseshift", 0.45);

      //       DerivativeWiringConf dc = DerivativeWiring::getDefaultConf();
      //       dc.useId=true;
      //       dc.useFirstD=false;
      //       AbstractWiring* wiring = new DerivativeWiring(dc,new ColorUniformNoise());
      AbstractWiring* wiring = new One2OneWiring(new ColorUniformNoise());
      OdeAgent* agent = new OdeAgent ();
      agent->init ( controller , sphere1 , wiring );
      //  agent->setTrackOptions(TrackRobot(true, false, false, "ZSens_Ring10_11", 50));
      global.agents.push_back ( agent );
      global.configs.push_back ( controller );
    }



  }
示例#7
0
文件: main.cpp 项目: amr1985/playful
  /// start() is called at the start and should create all the object (obstacles, agents...).
  virtual void start(const OdeHandle& odeHandle, const OsgHandle& osgHandle, GlobalData& global){
    
    setCameraHomePos(Pos(1.86452, 21.1998, 8.7964),  Pos(174.993, -10.688, 0));
    setCameraMode(Follow);

    global.odeConfig.setParam("controlinterval",1);
    global.odeConfig.setParam("gravity", -9.81); 

    global.odeConfig.setParam("noise", 0);
    global.odeConfig.setParam("realtimefactor", 1.);

    int sliderwheelies = 1;
    int snakes = 0;

    Playground* playground = new Playground(odeHandle, osgHandle, 
			    osg::Vec3(120, 0.2, 2.5),.5,true);
    //    playground->setColor(Color(1,0.2,0,0.1));
    playground->setPosition(osg::Vec3(0,0,0)); // playground positionieren und generieren
    global.obstacles.push_back(playground);
    

    // Creation of Obstacle
    PassiveBox* b = 
      new  PassiveBox(odeHandle, 
                      osgHandle.changeColor(Color(180.0 / 255.0, 180.0 / 255.0, 130.0 / 255.0)), 
                      osg::Vec3(4.0, 20.0, .8), 0);
    b->setTexture(0,TextureDescr("Images/playfulmachines.rgb",1,1));
    b->setPosition(Pos(-32, 0, 0)); 
    global.obstacles.push_back(b);    
    


      /******* S L I D E R - W H E E L I E *********/
    for(int i=0; i<sliderwheelies; i++){
      SliderWheelieConf mySliderWheelieConf = SliderWheelie::getDefaultConf();
      mySliderWheelieConf.segmNumber=12;
      mySliderWheelieConf.jointLimitIn=M_PI/3;
      mySliderWheelieConf.frictionGround=0.5;
      mySliderWheelieConf.motorPower=8;
      mySliderWheelieConf.motorDamp=0.05;
      mySliderWheelieConf.sliderLength=0.5;
      mySliderWheelieConf.segmLength=1.4;
      OdeRobot* robot = new SliderWheelie(odeHandle, osgHandle, mySliderWheelieConf, "Slider Armband");
      robot->place(Pos(0,0,2.0)); 

      //controller = new Sos(1.0);
      controller = new OneControllerPerChannel(new ControlGen(),"OnePerJoint");
      AbstractWiring* wiring = new One2OneWiring(new ColorUniformNoise(0.05)); 
      OdeAgent* agent = new OdeAgent(global);
      // only the first controller is exported to guilogger and Co
      agent->addInspectable(((OneControllerPerChannel*)controller)->getControllers()[0]);
      agent->init(controller, robot, wiring);
      if(track) 
        agent->setTrackOptions(TrackRobot(true,true,false,false,"split_control",1));
      global.agents.push_back(agent);
      global.configs.push_back(agent);
    }


    //****** SNAKES **********/
    for(int i=0; i<snakes; i++){

      //****************/
      SchlangeConf conf = Schlange::getDefaultConf();
      // conf.segmMass   = .2;
      // conf.segmLength= .5// 0.8;
      //   conf.segmDia=.6;
      // conf.motorPower=.5;
      conf.segmNumber = 12+2*i;//-i/2; 
      conf.jointLimit=conf.jointLimit* 1.6;
      conf.frictionJoint=0.02;
      conf.useServoVel=true;

      SchlangeServo2* schlange1;
      if (i==0) {
	schlange1 = 

	  new SchlangeServo2 ( odeHandle, osgHandle.changeColor(Color(0.1, 0.3, 0.8)),
			       conf, "S1");
      } else {
	schlange1 = 
	  new SchlangeServo2 ( odeHandle, osgHandle.changeColor(Color(0.1, 0.3, 0.8)),
			       conf, "S2");
      }
      //Positionieren und rotieren 
      schlange1->place(osg::Matrix::rotate(M_PI/2,0, 1, 0)*
		        osg::Matrix::translate(-.7+0.7*i,0,(i+1)*(.2+conf.segmNumber)/2.0/*+2*/));
                     // osg::Matrix::translate(5-i,2 + i*2,height+2));
      schlange1->setTexture("Images/whitemetal_farbig_small.rgb");
      if (i==0) {
	schlange1->setHeadColor(Color(1.0,0,0));
      } else {
	schlange1->setHeadColor(Color(0,1.0,0));
      }      
      OneControllerPerChannel *controller = new OneControllerPerChannel(new ControlGen(),"OnePerJoint");
      AbstractWiring* wiring = new One2OneWiring(new ColorUniformNoise(0.05)); 

      OdeAgent* agent = new OdeAgent(global);
      agent->addInspectable(controller->getControllers()[0]);
      agent->init(controller, schlange1, wiring);
      global.agents.push_back(agent);
      global.configs.push_back(agent);
 
    }//creation of snakes End

  }
示例#8
0
  virtual void addCallback(GlobalData& global, bool draw, bool pause, bool control) {
    if(!control || pause) return;
    if(counter == maxCounter){
      counter = 0;
      if(sphere) {
        // measure final speed
        double dat[3];
        speedsensor->sense(global);
        speedsensor->get(dat,3);
        Matrix s(1,3,dat);
        logfile << s << endl;
        cout << "End:   " << s << endl;
        if(runcounter>=startAngles.size()){
          this->pause=true;
          simulation_time_reached=true;
          return;
        }

        // destroy sphere
        global.agents.pop_back();
        delete sphere;
        delete controller;
        delete wiring;
        delete agent;
      }
      // create new sphere
      sphere = new Sphererobot3Masses ( odeHandle, osgHandle.changeColor(Color(0,0.0,2.0)),
                                        conf, "Sphere_test_sat", 0.3);

      // we will accelerate the sphere in positive x direction
      //  we place it the way that all (straight) rolling modes are possible
      double theta = startAngles[runcounter].val(0,0);
      double omega = startAngles[runcounter].val(1,0);
      sphere->place ( osg::Matrix::rotate(omega, 0,0,1)*osg::Matrix::rotate(theta, 1,0,0));

      //      sphere->place ( osg::Matrix::rotate(M_PI/2, 0,1,0));
      //      sphere->place ( osg::Matrix::rotate(M_PI/2, 0,0,1));

      speedsensor->init(sphere->getMainPrimitive());

      //      controller = new SatNetControl(networkfilename);
      controller = new SatNetControl_NoY(networkfilename);

      wiring = new One2OneWiring ( new ColorUniformNoise(0.20) );
      agent = new OdeAgent ( plotoptions );
      agent->init ( controller , sphere , wiring );
      //      agent->setTrackOptions(TrackRobot(true, true, false, true, "ZSens", 50));
      global.agents.push_back ( agent );

      runcounter++;
    } else if(counter > 1 && counter < accelerationTime){
      // speed up sphere
      double power = startAngles[runcounter-1].val(2,0);
      dBodyAddTorque ( sphere->getMainPrimitive()->getBody() , 0, power, 0 );
    }else if(counter == accelerationTime){ // measure start speed
      double dat[3];
      speedsensor->sense(global);
      speedsensor->get(dat,3);
      Matrix s(1,3,dat);
      logfile << s;
      cout << "Run: " << runcounter << "/" << startAngles.size() << endl;
      cout << "Start: " << s <<  endl;

    }

    counter++;
  }
示例#9
0
  // starting function (executed once at the beginning of the simulation loop)
  void start(const OdeHandle& odeHandle, const OsgHandle& osgHandle, GlobalData& global)
  {
    // first: position(x,y,z) second: view(alpha,beta,gamma)
    // gamma=0;
    // alpha == horizontal angle
    // beta == vertical angle
    setCameraHomePos(Pos(-0.18, 20.36, 13.63), Pos(-179.93, -34.37, 0));

    // initialization
    // - set noise to 0.1
    global.odeConfig.noise=0.1;
    global.odeConfig.setParam("controlinterval", 10);

    // use Playground as boundary:
    // - create pointer to playground (odeHandle contains things like world and space the
    //   playground should be created in; odeHandle is generated in simulation.cpp)
    // - setting geometry for each wall of playground:
    //   setGeometry(double length, double width, double        height)
    // - setting initial position of the playground: setPosition(double x, double y, double z)
    // - push playground in the global list of obstacles(globla list comes from simulation.cpp)


    bool labyrint=false;
    bool squarecorridor=false;
    bool normalplayground=true;
    bool boxes = true;

    if(normalplayground){
      //     Playground* playground = new Playground(odeHandle, osgHandle, osg::Vec3(12, 0.2, 0.5));
      Playground* playground = new Playground(odeHandle, osgHandle, osg::Vec3(17, 0.2, 1.0));
      playground->setPosition(osg::Vec3(0,0,0.05)); // playground positionieren und generieren
      // register playground in obstacles list
      global.obstacles.push_back(playground);
    }

    if(squarecorridor){
      Playground* playground = new Playground(odeHandle, osgHandle,osg::Vec3(15, 0.2, 1.2 ), 1);
      playground->setGroundColor(Color(255/255.0,200/255.0,0/255.0));
      playground->setGroundTexture("Images/really_white.rgb");
      playground->setColor(Color(255/255.0,200/255.0,21/255.0, 0.1));
      playground->setPosition(osg::Vec3(0,0,0.1));
      playground->setTexture("");
      global.obstacles.push_back(playground);
      //     // inner playground
      playground = new Playground(odeHandle, osgHandle,osg::Vec3(10, 0.2, 1.2), 1, false);
      playground->setColor(Color(255/255.0,200/255.0,0/255.0, 0.1));
      playground->setPosition(osg::Vec3(0,0,0.1));
      playground->setTexture("");
      global.obstacles.push_back(playground);
    }

    if(labyrint){
      double radius=7.5;
      Playground* playground = new Playground(odeHandle, osgHandle,osg::Vec3(radius*2+1, 0.2, 5 ), 1);
      playground->setGroundColor(Color(255/255.0,200/255.0,0/255.0));
      playground->setGroundTexture("Images/really_white.rgb");
      playground->setColor(Color(255/255.0,200/255.0,21/255.0, 0.1));
      playground->setPosition(osg::Vec3(0,0,0.1));
      playground->setTexture("");
      global.obstacles.push_back(playground);
      int obstanz=30;
      OsgHandle rotOsgHandle = osgHandle.changeColor(Color(255/255.0, 47/255.0,0/255.0));
      OsgHandle gruenOsgHandle = osgHandle.changeColor(Color(0,1,0));
      for(int i=0; i<obstanz; i++){
        PassiveBox* s = new PassiveBox(odeHandle, (i%2)==0 ? rotOsgHandle : gruenOsgHandle,
                                       osg::Vec3(random_minusone_to_one(0)+1.2,
                                                 random_minusone_to_one(0)+1.2 ,1),5);
        s->setPose(osg::Matrix::translate(radius/(obstanz+10)*(i+10),0,i)
                   * osg::Matrix::rotate(2*M_PI/obstanz*i,0,0,1));
        global.obstacles.push_back(s);
      }
    }

    if(boxes) {
      for (int i=0; i<= 2; i+=2){
        PassiveBox* s1 = new PassiveBox(odeHandle, osgHandle, osg::Vec3(1,1,1), 0.4);
        s1->setTexture("Images/dusty.rgb");
        s1->setPosition(osg::Vec3(-5+i*5,0,0));
        global.obstacles.push_back(s1);
        Joint* fixator;
        Primitive* p = s1->getMainPrimitive();
        fixator = new FixedJoint(p, global.environment);
        fixator->init(odeHandle, osgHandle);

        s1 = new PassiveBox(odeHandle, osgHandle, osg::Vec3(1,1,1), 0.4);
        s1->setTexture("Images/dusty.rgb");
        s1->setPosition(osg::Vec3(0,-5+i*5,0));
        global.obstacles.push_back(s1);
        p = s1->getMainPrimitive();
        fixator = new FixedJoint(p, global.environment);
        fixator->init(odeHandle, osgHandle);

        s1 = new PassiveBox(odeHandle, osgHandle, osg::Vec3(1,1,1), 0.4);
        s1->setTexture("Images/dusty.rgb");
        s1->setPosition(osg::Vec3(-3.5+i*3.5,-3.5+i*3.5,0));
        global.obstacles.push_back(s1);
        p = s1->getMainPrimitive();
        fixator = new FixedJoint(p, global.environment);
        fixator->init(odeHandle, osgHandle);

        s1 = new PassiveBox(odeHandle, osgHandle, osg::Vec3(1,1,1), 0.4);
        s1->setTexture("Images/dusty.rgb");
        s1->setPosition(osg::Vec3(-3.5+i*3.5,3.5-i*3.5,0));
        global.obstacles.push_back(s1);
        p = s1->getMainPrimitive();
        fixator = new FixedJoint(p, global.environment);
        fixator->init(odeHandle, osgHandle);
      }
    }


    // add passive spheres as obstacles
    // - create pointer to sphere (with odehandle, osghandle and
    //   optional parameters radius and mass,where the latter is not used here) )
    // - set Pose(Position) of sphere
    // - set a texture for the sphere
    // - add sphere to list of obstacles
    for (int i=0; i < 0/*2*/; i++){
      PassiveSphere* s1 = new PassiveSphere(odeHandle, osgHandle, 0.5);
      s1->setPosition(osg::Vec3(-4.5+i*4.5,0,0));
      s1->setTexture("Images/dusty.rgb");
      global.obstacles.push_back(s1);
    }

    // use Nimm2 vehicle as robot:
    // - get default configuration for nimm2
    // - activate bumpers, cigar mode and infrared front sensors of the nimm2 robot
    // - create pointer to nimm2 (with odeHandle, osg Handle and configuration)
    // - place robot
    Nimm2Conf c = Nimm2::getDefaultConf();
    c.bumper  = false;//true;
    c.cigarMode  = false;//true;
        c.irFront = true;
        c.irBack = true;
        //c.irSide = true;
        c.irRange = 1.2;//2;//3;
    c.force=2;
    c.speed=8;
    OdeRobot* vehicle = new Nimm2(odeHandle, osgHandle, c, "Nimm2");
    vehicle->place(Pos(0,0,0.5));
    //    vehicle->place(Pos(0,6.25,0));


    // use Nimm4 vehicle as robot:
    // - create pointer to nimm4 (with odeHandle and osg Handle and possible other settings, see nimm4.h)
    // - place robot
    //OdeRobot* vehicle = new Nimm4(odeHandle, osgHandle, "Nimm4");
    //vehicle->place(Pos(0,1,0));


    // create pointer to controller
    // push controller in global list of configurables
    AbstractController *controller = new LayeredController(10);
    controller->setParam("eps",0.1);
    controller->setParam("factor_a",0.1);
    controller->setParam("eps_hebb",0.03);
    global.configs.push_back(controller);

    // create pointer to one2onewiring
    One2OneWiring* wiring = new One2OneWiring(new ColorUniformNoise(0.1));

    // create pointer to agent
    // initialize pointer with controller, robot and wiring
    // push agent in globel list of agents
    OdeAgent* agent = new OdeAgent(global);
    agent->init(controller, vehicle, wiring);
    agent->setTrackOptions(TrackRobot(true, false, false, false, "hebbh" ,1));
    global.agents.push_back(agent);


  }
示例#10
0
    // starting function (executed once at the beginning of the simulation loop)
    void start(const OdeHandle& odeHandle, const OsgHandle& osgHandle, GlobalData& global)
    {
        setCameraHomePos(Pos(-5.44372, 7.37141, 3.31768),  Pos(-142.211, -21.1623, 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);

        // use Playground as boundary:
//    playground = new Playground(odeHandle, osgHandle, osg::Vec3(8, 0.2, 1), 1);
//     // playground->setColor(Color(0,0,0,0.8));
//     playground->setGroundColor(Color(2,2,2,1));
//     playground->setPosition(osg::Vec3(0,0,0.05)); // playground positionieren und generieren
//     global.obstacles.push_back(playground);
        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,0.1));
        global.configs.push_back(vehicle);

        // create pointer to controller
        // push controller in global list of configurables
        InvertMotorNStepConf cc = InvertMotorNStep::getDefaultConf();
        cc.cInit=1.0;
        cc.useS=false;
        cc.someInternalParams=true;
        controller = new InvertMotorNStep(cc);
//     AbstractController* controller = new SineController(~0, SineController::Sine);   // local variable!
// //     // motorpower 20
//     controller->setParam("period", 300);
//     controller->setParam("phaseshift", 0.3);

        controller->setParam("adaptrate", 0.000);
        if(useSym) {
            controller->setParam("epsC", 0.1);
            controller->setParam("epsA", 0.1);
        } else {
            controller->setParam("epsC", 0.1);
            controller->setParam("epsA", 0.1);
        }
        controller->setParam("rootE", 3);
        controller->setParam("steps", 1);
        controller->setParam("s4avg", 1);
        controller->setParam("continuity", 0.005);

        controller->setParam("teacher", teacher);

        //    One2OneWiring* wiring = new One2OneWiring(new ColorUniformNoise(0.1));
        AbstractWiring* wiring = new FeedbackWiring(new ColorUniformNoise(0.1),
                FeedbackWiring::Motor, 0.75);
        //plotoptions.push_back(PlotOption(GuiLogger,Robot,5));
        OdeAgent* agent = new OdeAgent(global);
        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);


    }
示例#11
0
  // starting function (executed once at the beginning of the simulation loop)
  void start(const OdeHandle& odeHandle, const OsgHandle& osgHandle, GlobalData& global)
  {
    setCameraHomePos(Pos(-0.0114359, 6.66848, 0.922832),  Pos(178.866, -7.43884, 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("cameraspeed", 250);

    // use Playground as boundary:
//    playground = new Playground(odeHandle, osgHandle, osg::Vec3(8, 0.2, 1), 1);
//     // playground->setColor(Color(0,0,0,0.8));
//     playground->setGroundColor(Color(2,2,2,1));
//     playground->setPosition(osg::Vec3(0,0,0.05)); // playground positionieren und generieren
//     global.obstacles.push_back(playground);
    controller=0;

    addParameter("k",&k);
    addParameter("gamma_s",&teacher);
    global.configs.push_back(this);

    for(int i=0; i< bars; i++){
      PassiveBox* b = new PassiveBox(odeHandle, osgHandle.changeColor(Color(0.,0.,0.)),
                                     osg::Vec3(1,10,0.3+i*.1),0.0);
      b->setPosition(osg::Vec3(10+i*7,0,0));
      global.obstacles.push_back(b);
    }

    double h = 0.;
    RandGen rgen;
    rgen.init(2);
    for(int i=0; i<stairs; i++){
      do{
        h+=(rgen.rand()-.5)*0.6; // values between (-.25.25)
      }while(h<0);
      PassiveBox* b = new PassiveBox(odeHandle, osgHandle.changeColor(Color(0.3,0.3,0.3)),
                                     osg::Vec3(1,10,h),0.0);
      b->setPosition(osg::Vec3(5+i,0,0));
      global.obstacles.push_back(b);
    }

    /******* 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.showCenter   = false;
    vehicle = new SliderWheelie(odeHandle, osgHandle.changeColor(Color(1,222/255.0,0)),
                                mySliderWheelieConf, "sliderWheelie_" + std::itos(teacher*10000));

    vehicle->place(Pos(0,0,.1));
    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=.95;
    cc.cInit=.5;
    cc.modelExt=false;
    //    cc.someInternalParams=true;
    cc.someInternalParams=false;
    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);

    //        AbstractWiring* wiring = new One2OneWiring(new ColorUniformNoise(0.1));
    //AbstractWiring* wiring = new MotorAsSensors(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->init(controller, vehicle, wiring);
    if(track) agent->setTrackOptions(TrackRobot(true,false,false, false,
                                                 change != 0 ? 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(k_double,"k",ID,1);

    setCMC(k);
    blink=0;


  }
示例#12
0
文件: main.cpp 项目: amr1985/playful
  // 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);
//     }

  }
示例#13
0
  // starting function (executed once at the beginning of the simulation loop/first cycle)
  void start(const OdeHandle& odeHandle, const OsgHandle& osgHandle, GlobalData& global)
  {
    // first: position(x,y,z) second: view(alpha,beta,gamma)
    // gamma=0;
    // alpha == horizontal angle
    // beta == vertical angle
    setCameraHomePos(Pos(5.2728, 7.2112, 3.31768), Pos(140.539, -13.1456, 0));
    // initialization
    // - set noise to 0.1
    global.odeConfig.noise=0.05;
    // set realtimefactor to maximum
    global.odeConfig.setParam("realtimefactor", 0);

    // use Playground as boundary:
    // - create pointer to playground (odeHandle contains things like world and space the
    //   playground should be created in; odeHandle is generated in simulation.cpp)
    // - setting geometry for each wall of playground:
    //   setGeometry(double length, double width, double        height)
    // - setting initial position of the playground: setPosition(double x, double y, double z)
    // - push playground in the global list of obstacles(globla list comes from simulation.cpp)

    // odeHandle and osgHandle are global references
    // vec3 == length, width, height
    Playground* playground = new Playground(odeHandle, osgHandle, osg::Vec3(32, 0.2, 0.5));
    playground->setPosition(osg::Vec3(0,0,0.05)); // playground positionieren und generieren
    // register playground in obstacles list
    global.obstacles.push_back(playground);

    // add passive spheres as obstacles
    // - create pointer to sphere (with odehandle, osghandle and
    //   optional parameters radius and mass,where the latter is not used here) )
    // - set Pose(Position) of sphere
    // - set a texture for the sphere
    // - add sphere to list of obstacles
    for (int i=0; i < 0/*2*/; i++){
      PassiveSphere* s1 = new PassiveSphere(odeHandle, osgHandle, 0.5);
      s1->setPosition(osg::Vec3(-4.5+i*4.5,0,0));
      s1->setTexture("Images/dusty.rgb");
      global.obstacles.push_back(s1);
    }

    // use Nimm2 vehicle as robot:
    // - get default configuration for nimm2
    // - activate bumpers, cigar mode and infrared front sensors of the nimm2 robot
    // - create pointer to nimm2 (with odeHandle, osg Handle and configuration)
    // - place robot
    Nimm2Conf c = Nimm2::getDefaultConf();
    c.force   = 4;
    c.bumper  = true;
    c.cigarMode  = true;
    // c.irFront = true;
    vehicle = new Nimm2(odeHandle, osgHandle, c, "Nimm2");
    vehicle->place(Pos(0,0,0));

    // use Nimm4 vehicle as robot:
    // - create pointer to nimm4 (with odeHandle and osg Handle and possible other settings, see nimm4.h)
    // - place robot
    //OdeRobot* vehicle = new Nimm4(odeHandle, osgHandle, "Nimm4");
    //vehicle->place(Pos(0,1,0));


    // create pointer to controller
    // push controller in global list of configurables
    //  AbstractController *controller = new InvertNChannelController(10);
    AbstractController *controller = new InvertMotorSpace(10);
    global.configs.push_back(controller);

    // create pointer to one2onewiring
    One2OneWiring* wiring = new One2OneWiring(new ColorUniformNoise(0.1));

    // create pointer to agent
    // initialize pointer with controller, robot and wiring
    // push agent in globel list of agents
    agent = new OdeAgent(global);
    agent->init(controller, vehicle, wiring);
    global.agents.push_back(agent);


  }