当前位置: 首页>>代码示例>>C++>>正文


C++ OsgHandle::changeColor方法代码示例

本文整理汇总了C++中OsgHandle::changeColor方法的典型用法代码示例。如果您正苦于以下问题:C++ OsgHandle::changeColor方法的具体用法?C++ OsgHandle::changeColor怎么用?C++ OsgHandle::changeColor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在OsgHandle的用法示例。


在下文中一共展示了OsgHandle::changeColor方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: start

  // starting function (executed once at the beginning of the simulation loop)
  void start(const OdeHandle& odeHandle, const OsgHandle& osgHandle, GlobalData& global)
  {
    setCameraHomePos(Pos(5.2728, 7.2112, 3.31768), Pos(140.539, -13.1456, 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:",1); // normally at -9.81
    // initialization

    Playground* playground = new Playground(odeHandle, osgHandle, osg::Vec3(25, 0.2, 1.5));
    playground->setPosition(osg::Vec3(0,0,0)); // playground positionieren und generieren
    global.obstacles.push_back(playground);

    for(int i=0; i<5; i++){
      PassiveSphere* s =
        new PassiveSphere(odeHandle,
                          osgHandle.changeColor(Color(184 / 255.0, 233 / 255.0, 237 / 255.0)), 0.2);
      s->setPosition(Pos(i*0.5-2, i*0.5, 1.0));
      s->setTexture("Images/dusty.rgb");
      global.obstacles.push_back(s);
    }

    OdeAgent* agent;
    AbstractWiring* wiring;
//    OdeRobot* robot;
    AbstractController *controller;

    CaterPillar* myCaterPillar;
    CaterPillarConf myCaterPillarConf = DefaultCaterPillar::getDefaultConf();
    //******* R A U P E  *********/
    myCaterPillarConf.segmNumber=6;
    myCaterPillarConf.jointLimit=M_PI/4;
    myCaterPillarConf.motorPower=0.8;
    myCaterPillarConf.frictionGround=0.04;
    myCaterPillar = new CaterPillar ( odeHandle, osgHandle.changeColor(Color(0.0f,1.0f,0.0f)), myCaterPillarConf, "Raupe1");
    ((OdeRobot*) myCaterPillar)->place(Pos(-5,-5,0.2));

    InvertMotorNStepConf invertnconf = InvertMotorNStep::getDefaultConf();
    invertnconf.cInit=2.0;
    controller = new InvertMotorNStep(invertnconf);
    wiring = new One2OneWiring(new ColorUniformNoise(0.1));
    agent = new OdeAgent( global, plotoptions );
    agent->init(controller, myCaterPillar, wiring);
    global.agents.push_back(agent);
    global.configs.push_back(controller);
    global.configs.push_back(myCaterPillar);
    myCaterPillar->setParam("gamma",/*gb");
      global.obstacles.push_back(s)0.0000*/ 0.0);

  }
开发者ID:CentreForBioRobotics,项目名称:lpzrobots,代码行数:54,代码来源:main.cpp

示例2: init

  void ContactSensor::init(const OdeHandle& odeHandle,
                           const OsgHandle& osgHandle,
                           Primitive* reference,
                           bool createSphere,
                           const osg::Matrix pose,
                           bool colorObject){
    assert(reference);
    this->colorObject = colorObject;
    this->reference   = reference;

    value = 0;
    lastvalue = -1;
    if(createSphere){
      sensorBody = new Sphere(size);
      transform = new Transform(reference, sensorBody, pose);
      origColor = osgHandle.getColor("joint");
      transform->init(odeHandle, 0, osgHandle.changeColor(origColor));
      transform->substance.setCollisionCallback(contactCollCallbackNoCol,this);
    }else{
      reference->substance.setCollisionCallback(contactCollCallback,this);
      if(reference->getOSGPrimitive())
        origColor = reference->getOSGPrimitive()->getColor();
      else
        colorObject = false;
    }

    update();
    initialised = true;
  };
开发者ID:Sosi,项目名称:lpzrobots,代码行数:29,代码来源:contactsensor.cpp

示例3: start

  // starting function (executed once at the beginning of the simulation loop)
  void start(const OdeHandle& odeHandle, const OsgHandle& osgHandle, GlobalData& global) 
  {
    setCameraHomePos(Pos(5.2728, 7.2112, 3.31768), Pos(140.539, -13.1456, 0));
    setCameraMode(Follow);
    global.odeConfig.setParam("noise",0.1);
    global.odeConfig.setParam("controlinterval",4);
    global.odeConfig.setParam("realtimefactor",4);
    
    //  global.odeConfig.setParam("gravity", 0); // no gravity

    for(int i=0; i<0; i++){
      PassiveSphere* s = new PassiveSphere(odeHandle, osgHandle.changeColor(Color(0.0,1.0,0.0)), 0.5);
      s->setPosition(osg::Vec3(5,0,i*3)); 
      global.obstacles.push_back(s);    
    }

    
    // Spherical Robot with axis orientation sensors:
    Sphererobot3MassesConf conf = Sphererobot3Masses::getDefaultConf();  
    conf.addSensor(new AxisOrientationSensor(AxisOrientationSensor::ZProjection));
    // regular behaviour
    conf.motorsensor=false;
    conf.diameter=1.0;
    conf.pendularrange= 0.25;
    conf.motorpowerfactor = 150;     
    
//     conf.diameter=1.0;
//     conf.pendularrange= 0.35;
    sphere1 = new Sphererobot3Masses ( odeHandle, osgHandle.changeColor(Color(1.0,0.0,0)), 
				       conf, "Sphere1", 0.2);     
    ((OdeRobot*)sphere1)->place ( Pos( 0 , 0 , 0.1 ));
    global.configs.push_back ( sphere1 );
    
    controller = new Sox(.8,true);
    controller->setParam("epsA",0.3); // model learning rate
    controller->setParam("epsC",1); // controller learning rate
    controller->setParam("causeaware",0.4); 
    controller->setParam("pseudo",2); 
    global.configs.push_back ( controller );

    One2OneWiring* wiring = new One2OneWiring ( new ColorUniformNoise() );
    OdeAgent* agent = new OdeAgent ( global );
    agent->init ( controller , sphere1 , wiring );
    if(track) agent->setTrackOptions(TrackRobot(true, true, true, false, "zaxis", 20)); 
    global.agents.push_back ( agent );

  }
开发者ID:amr1985,项目名称:playful,代码行数:48,代码来源:main.cpp

示例4: render

 void Sound::render(const OsgHandle& osgHandle){
   if(!visual){
     visual = new OSGSphere((intensity+1.0)/4.0);
     visual->init(osgHandle.changeColor(Color(255-int((frequency+1.0)*128.0),
                                              0,int((frequency+1.0)*128.0),0.4)));
     visual->setMatrix(osg::Matrix::translate(pos.x(), pos.y(), pos.z()+1));
   }
 }
开发者ID:Sosi,项目名称:lpzrobots,代码行数:8,代码来源:sound.cpp

示例5: init

 void Mesh::init(const OdeHandle& odeHandle, double mass, const OsgHandle& osgHandle,
                    char mode) {
   // 20100307; guettler: sometimes the Geom is created later (XMLBoundingShape),
   // if no body is created, this Mesh seems to be static. Then the BoundingShape must not attach
   // any Primitive to the body of the Mesh by a Transform.
   //assert(mode & Body || mode & Geom);
   if (!substanceManuallySet)
     substance = odeHandle.substance;
   this->mode=mode;
   double r=0.01;
   QMP_CRITICAL(7);
   if (mode & Draw){
     osgmesh->init(osgHandle);
     r =  osgmesh->getRadius();
   }
   else {
     osgmesh->virtualInit(osgHandle);
   }
   if (r<0) r=0.01;
   if (mode & Body){
     body = dBodyCreate (odeHandle.world);
     // Todo: use compound bounding box mass instead
     setMass(mass, mode & Density);
   }
   // read boundingshape file
   //    const osg::BoundingSphere& bsphere = osgmesh->getGroup()->getBound();
   // 20100307; guettler: if no Geom, don't create any Geom or Boundings (this is used e.g. for Meshes loaded from XML)
   if (mode & Geom) {
     short drawBoundingMode;
     if (osgHandle.drawBoundings)
       drawBoundingMode=Primitive::Geom | Primitive::Draw;
     else
       drawBoundingMode=Primitive::Geom;
     boundshape = new BoundingShape(filename+".bbox" ,this);
     if(!boundshape->init(odeHandle, osgHandle.changeColor(Color(1,0,0,0.3)), scale, drawBoundingMode)){
       printf("use default bounding box, because bbox file not found!\n");
       Primitive* bound = new Sphere(r);
       Transform* trans = new Transform(this,bound,Pose::translate(0.0f,0.0f,0.0f));
       trans->init(odeHandle, 0, osgHandle.changeColor(Color(1,0,0,0.3)),drawBoundingMode);
       osgmesh->setMatrix(Pose::translate(0.0f,0.0f,osgmesh->getRadius())*getPose()); // set obstacle higher
     }
   }
   QMP_END_CRITICAL(7);
 }
开发者ID:CentreForBioRobotics,项目名称:lpzrobots,代码行数:44,代码来源:primitive.cpp

示例6: init

 void TmpPrimitive::init(const OdeHandle& odeHandle, const OsgHandle& osgHandle){
   Color mcolor(color);
   if(useColorName){
     mcolor = osgHandle.getColor(colorname);
     mcolor.alpha() = alpha;
   }
   item->init(odeHandle, mass, osgHandle.changeColor(mcolor), mode);
   item->setPose(pose);
   initialized=true;
 }
开发者ID:CentreForBioRobotics,项目名称:lpzrobots,代码行数:10,代码来源:tmpprimitive.cpp

示例7: start

  // starting function (executed once at the beginning of the simulation loop)
  void start(const OdeHandle& odeHandle, const OsgHandle& osgHandle, GlobalData& global)
  {
    setCameraHomePos(Pos(-1.64766, 4.48823, 1.71381),  Pos(-158.908, -10.5863, 0));

    // initialization
    // - set noise to 0.0
    // - register file chess.ppm as a texture called chessTexture (used for the wheels)
    global.odeConfig.setParam("controlinterval",2);
    global.odeConfig.setParam("noise",0.1);
    global.odeConfig.setParam("realtimefactor",1);
    global.odeConfig.setParam("gravity", -3);

    // use Playground as boundary:
    playground = new Playground(odeHandle, osgHandle,
                                osg::Vec3(10, .2, 1));
    playground->setPosition(osg::Vec3(0,0,0.2));
    global.obstacles.push_back(playground);

    playground = new OctaPlayground(odeHandle, osgHandle);
    playground->setPosition(osg::Vec3(15,0,0.2));
    global.obstacles.push_back(playground);



    // add passive spheres as obstacles
    for (int i=0; i< 1/*2*/; i+=1){
      PassiveSphere* s1 = new PassiveSphere(odeHandle, osgHandle, 0.3);
      // s1->setPosition(osg::Vec3(-4.5+i*4.5,0,0));
      s1->setPosition(osg::Vec3(0,0,1+i*5));
      s1->setTexture("Images/dusty.rgb");
      global.obstacles.push_back(s1);
    }

    b = new OSGBoxTex(5,1,2);
    b->setTexture(0,TextureDescr("Images/dusty.rgb",1,1));
    b->setTexture(1,TextureDescr("Images/tire_full.rgb",3,1));
    b->setTexture(2,TextureDescr("Images/whitemetal_farbig_small.rgb",1,1));
    b->setTexture(3,TextureDescr("Images/wall.rgb",1,1));
    b->setTexture(4,TextureDescr("Images/really_white.rgb",1,1));
    b->setTexture(5,TextureDescr("Images/light_chess.rgb",-1,-1));
    b->init(osgHandle.changeColor(Color(1,1,0)));
    b->setMatrix(osg::Matrix::translate(0,-2,2));

    b2 = new OSGBox(5,1,2);
    b2->setTexture(TextureDescr("Images/light_chess.rgb",1,1));
    b2->init(osgHandle);
    b2->setMatrix(osg::Matrix::translate(7,0,2));




  }
开发者ID:CentreForBioRobotics,项目名称:lpzrobots,代码行数:53,代码来源:main.cpp

示例8: start

// starting function (executed once at the beginning of the simulation loop)
void OpenLoopSim::start(const OdeHandle& odeHandle, const OsgHandle& osgHandle, 
			  GlobalData& global) {
  int num_barrels=1;
  
  setCameraHomePos(Pos(-1.29913, 6.06201, 1.36947),  Pos(-165.217, -9.32904, 0));
  setCameraMode(Follow);
  // initialization
  global.odeConfig.setParam("noise",0);
  // the simulation runs with 100Hz and we control every second
  global.odeConfig.setParam("controlinterval",2); 

  // add a new parameter to be configured on the console
  global.odeConfig.addParameterDef("friction", &friction, 0.0, "rolling friction coefficient");
  global.odeConfig.addParameterDef("color", &color, 0, "color of noise (correlation length)");
  
  /* * * * 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;
    robot = new Barrel2Masses ( odeHandle, osgHandle.changeColor(Color(0.0,0.0,1.0)), 
				  conf, "Barrel", 0.4); 

    robot->place (osg::Matrix::rotate(M_PI/2, 1,0,0) /* rotate to laying position */ 
		  * osg::Matrix::rotate(M_PI/4, 0,1,0) /* both axis at 45Deg*/ 
		  * osg::Matrix::translate(0,0,.15+2*i)); // place at 0,0 and in some height
    
    controller = new SineController();  
    controller->setParam("period", 300);  
    controller->setParam("phaseshift", 1);
    
    noisegen = new ColorUniformNoise();
    wiring = new MotorNoiseWiring(noisegen, 0);
    
    OdeAgent* agent = new OdeAgent ( global );
    agent->init ( controller , robot , wiring );
    
    global.agents.push_back ( agent );
    global.configs.push_back ( agent );
  }
 
}
开发者ID:amr1985,项目名称:playful,代码行数:47,代码来源:openloop.cpp

示例9: addRobot

  void addRobot(const OdeHandle& odeHandle, const OsgHandle& osgHandle, GlobalData& global, int i){
    Color col;
    
    Sphererobot3MassesConf conf = Sphererobot3Masses::getDefaultConf();  
    conf.addSensor(new AxisOrientationSensor(AxisOrientationSensor::ZProjection));
    conf.diameter=1.0;
    conf.pendularrange= 0.30; // 0.15;
    conf.motorpowerfactor  = 150;     
    conf.spheremass = 1;
    conf.motorsensor=false;
    
    conf.addSensor(new SpeedSensor(5, SpeedSensor::RotationalRel));
    

    //SphererobotArms* sphere = new SphererobotArms ( odeHandle, conf);
    switch(i){
    case 0:
      col.r()=0;
      col.g()=1;
      col.b()=0.1;
      sphere = new Sphererobot3Masses ( odeHandle, osgHandle.changeColor(col), conf, "sphere 1", 0.4);
      sphere->place ( osg::Matrix::translate(9.5 , 0 , height+1 ));
      break;
    case 1:
      col.r()=1;
      col.g()=0.2;
      col.b()=0;
      sphere = new Sphererobot3Masses ( odeHandle, osgHandle.changeColor(col), conf, "sphere 2", 0.4);
      sphere->place ( osg::Matrix::translate( 2 , -2 , height+1 ));
      break;
    case 3:
      col.r()=0;
      col.g()=0;
      col.b()=1;
      sphere = new Sphererobot3Masses ( odeHandle, osgHandle.changeColor(col), conf, "sphere" + 
					string(envnames[env]), 0.4);
      sphere->place ( osg::Matrix::translate( 0 , 0 , .5 ));
      break;
    default:
    case 2:
      col.r()=0;
      col.g()=1;
      col.b()=0.4;
      sphere = new Sphererobot3Masses ( odeHandle, osgHandle.changeColor(col), conf, "sphere 3", 0.4);
      sphere->place ( osg::Matrix::translate( double(rand())/RAND_MAX*10 , 0 , height+1 ));
      break;
    }
  
    Sox* sox = new Sox(.8,true);  
    sox->setParam("epsC", 0.2);
    sox->setParam("epsA", 0.2);        
    if(env==ElipticBasin){
      sox->setParam("epsC", 0.3);
      sox->setParam("epsA", 0.3);        
    }
    sox->setParam("Logarithmic", 0);
    sox->setParam("sense", 0.5);
    AbstractController *controller = new GroupController(sox, 3); 
   
  
    //    AbstractWiring* wiring = new One2OneWiring ( new ColorUniformNoise() );   
  AbstractWiring* wiring = new SelectiveOne2OneWiring(new WhiteUniformNoise(), 
                                                      new select_from_to(0,2), 
                                                      AbstractWiring::Robot);
  
    OdeAgent* agent;
    if(i==0 || i==3 ){
      agent = new OdeAgent (global);
    }
    else
      agent = new OdeAgent (global, PlotOption(NoPlot));

    agent->init ( controller , sphere , wiring );
    if(track)
      agent->setTrackOptions(TrackRobot(true,true,true,false,"",2));

    global.agents.push_back ( agent );
    //global.configs.push_back ( controller );  
    global.configs.push_back ( sphere);  
  }
开发者ID:humm,项目名称:playful,代码行数:80,代码来源:main2.cpp

示例10: start

    // 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();
//.........这里部分代码省略.........
开发者ID:sinusoidplus,项目名称:lpzrobots,代码行数:101,代码来源:main.cpp

示例11: start

  // starting function (executed once at the beginning of the simulation loop)
  void start(const OdeHandle& odeHandle, const OsgHandle& osgHandle, GlobalData& global) 
  {
    setCameraHomePos(Pos(-16.4509, 15.6927, 12.5683),  Pos(-133.688, -26.4496, 0));
    setCameraMode(Static);
    global.odeConfig.setParam("noise",0.05);
    global.odeConfig.setParam("realtimefactor",2);
    //  global.odeConfig.setParam("gravity", 0);

    Playground* playground;
    if(env==ElipticBasin){
      playground = new Playground(odeHandle, osgHandle, 
				  osg::Vec3(20, 0.2, height+1.f), 2);
    }else{
      playground = new Playground(odeHandle, osgHandle, 
				  osg::Vec3(20, 0.2, height+0.3f), 1);
    }
    playground->setColor(Color(.1,0.7,.1));
    playground->setTexture("");
    playground->setPosition(osg::Vec3(0,0,0.01f)); // playground positionieren und generieren
    global.obstacles.push_back(playground);

    int numpassive=0;
    switch(env){
    case ThreeBump:
      {
        TerrainGround* terrainground = 
          new TerrainGround(odeHandle, osgHandle.changeColor(Color(1.0f,1.0,1.0)),
                            "terrains/macrospheresLMH_64.ppm","terrains/macrospheresTex_256.ppm", 
                            20, 20, height, OSGHeightField::LowMidHigh);
        terrainground->setPose(osg::Matrix::translate(0, 0, 0.1));
        global.obstacles.push_back(terrainground);
        addRobot(odeHandle, osgHandle, global, 0);
        addRobot(odeHandle, osgHandle, global, 1);
        numpassive=4;
      }
      break;
    case SingleBasin:
      // at Radius 3.92 height difference of 0.5 and at 6.2 height difference of 1 
      // ./start -single -track -f 2 -r 1297536669

    case ElipticBasin:
      // ./start -eliptic -f 5 -track -r 1297628680
      {
        TerrainGround* terrainground = 
          new TerrainGround(odeHandle, osgHandle.changeColor(Color(1.0f,1.0f,1.0f)),
			    //                        "terrains/dip128_flat.ppm","terrains/dip128_flat_texture.ppm", 
                            "terrains/dip128.ppm","terrains/dip128_texture.ppm", 
                            20, env == SingleBasin ? 20 : 40, height, OSGHeightField::Red);
        terrainground->setPose(osg::Matrix::translate(0, 0, 0.1));
        global.obstacles.push_back(terrainground);
        addRobot(odeHandle, osgHandle, global, 3);
      }
      break;
    }
        

    // 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< numpassive; i+=1){
      PassiveSphere* s1 = new PassiveSphere(odeHandle, osgHandle, 0.5,0.1);
      s1->setPosition(osg::Vec3(-8+2*i,-2,height+0.5));
      s1->setTexture("Images/dusty.rgb");
      global.obstacles.push_back(s1);
    }
  
  }
开发者ID:humm,项目名称:playful,代码行数:71,代码来源:main2.cpp

示例12: playground_with_ramps_and_agents

void playground_with_ramps_and_agents(const OdeHandle& odeHandle, const OsgHandle& osgHandle, GlobalData& global){
    Playground* playground1 = new Playground(odeHandle, osgHandle, osg::Vec3(20.5, 0.2, 2.0),0.05, true);
    //    playground1->setColor(Color(0,0.8,0,0.2));
    //    playground1->setTexture("Images/really_white.rgb");
    playground1->setPosition(osg::Vec3(0,0,0)); // playground positionieren und generieren
    //    global.obstacles.push_back(playground1);

    playground1->setColor(Color(1,0,0));

//     Playground* playground2 = new Playground(odeHandle, osgHandle, osg::Vec3(20.5, 0.2, 2.0),0.05);
//     playground2->setColor(Color(0,0.8,0,0.2));
//     playground2->setTexture("Images/really_white.rgb");
//     playground2->setPosition(osg::Vec3(0,1.4,0)); // playground positionieren und generieren
//     global.obstacles.push_back(playground2);

    Box* box = new Box(3, 2.6 ,0.1);
    box->init(odeHandle, 0, osgHandle, Primitive::Geom | Primitive::Draw);
    box->setPose(osg::Matrix::rotate(-M_PI/6,osg::Vec3(0,1,0)) * osg::Matrix::translate(9.0,0.7,0.4));
    box->update();

//     box = new Box(3, 2.6 ,0.1);
//     box->init(odeHandle, 0, osgHandle, Primitive::Geom | Primitive::Draw);
//     box->setPose(osg::Matrix::rotate(M_PI/6,osg::Vec3(0,1,0)) * osg::Matrix::translate(-9.0,0.7,0.4));
//     box->update();

    Box* b = new Box(1,2,3);
    b->init(odeHandle, 0, osgHandle.changeColor(Color(0,1,1)),
                        Primitive::Geom | Primitive::Draw);
    b->setPose(osg::Matrix::translate(0.0f,0.0f,-0.05f));
    b->setTexture("Images/greenground.rgb",true,true);

    delete b;
    b = new Box(1,2,3);
    b->init(odeHandle, 0, osgHandle.changeColor(Color(0,1,1)),
                        Primitive::Geom | Primitive::Draw);
    b->setPose(osg::Matrix::translate(0.0f,0.0f,-0.05f));
    b->setTexture("Images/greenground.rgb",true,true);


//     ForcedSphereConf conf;
//     ForcedSphere* sphere1;
//     ForcedSphere* sphere2;
//     AbstractWiring* wiring;
//     OdeAgent* agent;

//     //////// AGENT 1

//     conf = ForcedSphere::getDefaultConf();
//     //    conf.addSensor(new AxisOrientationSensor(AxisOrientationSensor::OnlyZAxis));
//     RelativePositionSensor* s = new RelativePositionSensor(4,1,RelativePositionSensor::X);
//     s->setReference(playground1->getMainPrimitive());
//     conf.addSensor(s);
//     conf.radius = 0.5;
//     conf.drivenDimensions = ForcedSphere::X;
//     sphere1 = new ForcedSphere ( odeHandle, osgHandle.changeColor(Color(1.0,0.0,0)),
//                                  conf, "Agent1");
//     ((OdeRobot*)sphere1)->place ( Pos( 0 , 0 , 0.5 ));

//     //    controller = new InvertMotorSpace(50);
//     controller = new InvertMotorNStep();
//     controller->setParam("epsA",0.005); // model learning rate
//     controller->setParam("epsC",0.02); // controller learning rate
//     //    controller->setParam("rootE",3);    // model and contoller learn with square rooted error
//     controller->setParam("factorB",0);
//     controller->setParam("noiseB",0);
//     controller->setParam("adaptrate",0.0);
//     controller->setParam("noiseY",0.0);
//     global.configs.push_back ( controller );

//     //controller = new SineController();
//     //global.configs.push_back ( controller );


//     // wiring = new One2OneWiring ( new ColorUniformNoise() );
//     DerivativeWiringConf wc = DerivativeWiring::getDefaultConf();
//     wc.useId=false;
//     wc.useSecondD=true;
//     wc.eps=1;
//     wc.derivativeScale=100;
//     wiring = new DerivativeWiring ( wc, new ColorUniformNoise());
//     agent = new OdeAgent ( plotoptions );
//     agent->init ( controller , sphere1 , wiring );
//     global.agents.push_back ( agent );


    //////// AGENT 2

//     conf = ForcedSphere::getDefaultConf();
//     //    conf.addSensor(new AxisOrientationSensor(AxisOrientationSensor::OnlyZAxis));
//     s = new RelativePositionSensor(4,1,RelativePositionSensor::X);
//     s->setReference(playground2->getMainPrimitive());
//     conf.addSensor(s);
//     conf.radius = 0.5;
//     conf.drivenDimensions = ForcedSphere::X;
//     sphere2 = new ForcedSphere ( odeHandle, osgHandle.changeColor(Color(0.0,0.0,1.0)),
//                                  conf, "Agent2");
//     ((OdeRobot*)sphere2)->place ( Pos( 0 , 1.4 , 0.5 ));

//     controller = new InvertMotorSpace(50);
//     controller->setParam("epsA",0.05); // model learning rate
//.........这里部分代码省略.........
开发者ID:CentreForBioRobotics,项目名称:lpzrobots,代码行数:101,代码来源:main.cpp

示例13: start

  // 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),
//.........这里部分代码省略.........
开发者ID:CentreForBioRobotics,项目名称:lpzrobots,代码行数:101,代码来源:main.cpp

示例14: start

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


    }
开发者ID:tnachstedt,项目名称:lpzrobots,代码行数:75,代码来源:main.cpp

示例15: start

	// starting function (executed once at the beginning of the simulation loop)
	void start(const OdeHandle& odeHandle, const OsgHandle& osgHandle, GlobalData& global)
	{

		// set initial camera position
		setCameraHomePos(Pos(-1.14383, 10.1945, 42.7865),  Pos(179.991, -77.6244, 0));


		// initialization simulation parameters

		//1) - set noise to 0.1
		global.odeConfig.noise= 0.02;//0.05;

		//2) - set controlinterval -> default = 1
		global.odeConfig.setParam("controlinterval", 1);/*update frequency of the simulation ~> amos = 20*/
		//3) - set simulation setp size
		global.odeConfig.setParam("simstepsize", 0.01); /*stepsize of the physical simulation (in seconds)*/
		//Update frequency of simulation = 1*0.01 = 0.01 s ; 100 Hz

		//4) - set gravity if not set then it uses -9.81 =earth gravity
		//global.odeConfig.setParam("gravity", -9.81);


		//5) - set 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


		double length_pg = 35;//28;//0.0; //45, 32, 22
		double width_pg = 0.5;//0.0;  //0.2
		double height_pg = 0.5;//0.0; //0.5

		Playground* playground = new Playground(odeHandle, osgHandle.changeColor(Color(0.6,0.0,0.6)),
				osg::Vec3(length_pg /*length*/, width_pg /*width*/, height_pg/*height*/), /*factorxy = 1*/1, /*createGround=true*/true /*false*/);
		playground->setPosition(osg::Vec3(4,0,0.0)); // playground positionieren und generieren
		// register playground in obstacles list
		global.obstacles.push_back(playground);

//    Playground* playground =
//      new Playground(odeHandle, osgHandle.changeColor(Color(0.88f,0.4f,0.26f,0.2f)),osg::Vec3(18, 0.2, 2.0));
//    playground->setPosition(osg::Vec3(0,0,0)); // playground positionieren und generieren
//    Substance substance;
//    substance.toRubber(40);
//    playground->setGroundSubstance(substance);
//    global.obstacles.push_back(playground);

//    for(int i=0; i<0; i++)
//    {
//      PassiveSphere* s =
//        new PassiveSphere(odeHandle,
//                          osgHandle.changeColor(Color(184 / 255.0, 233 / 255.0, 237 / 255.0)), 0.2);
//      s->setTexture("Images/dusty.rgb");
//      s->setPosition(Pos(i*0.5-2, i*0.5, 1.0));
//      global.obstacles.push_back(s);
//    }

		if(!ico_learning_task)
		{

		  for (int j=0;j<4;j++)
		  {
		    for(int i=0; i<4; i++)
		    {
		      PassiveBox* b =
		          new PassiveBox(odeHandle,
		              osgHandle.changeColor(Color(1.0f,0.2f,0.2f,0.5f)), osg::Vec3(1.5+i*0.01,1.5+i*0.01,1.5+i*0.01),40.0);
		      b->setTexture("Images/light_chess.rgb");
		      b->setPosition(Pos(i*4-5, -5+j*4, 1.0));
		      global.obstacles.push_back(b);
		    }
		  }

		}

		//6) - add passive spheres as TARGET!
		// - 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

		PassiveSphere* s1;

		double target_z_position = 1.5;

		if(ico_learning_task)
		{
		  target_z_position = 0.5;
		}


		for (int i=0; i < number_spheres; i++){
			s1 = new PassiveSphere(odeHandle, osgHandle, 0.5);
//.........这里部分代码省略.........
开发者ID:pmanoonpong,项目名称:gorobots_edu,代码行数:101,代码来源:main.cpp


注:本文中的OsgHandle::changeColor方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。