本文整理汇总了C++中OdeAgent::setTrackOptions方法的典型用法代码示例。如果您正苦于以下问题:C++ OdeAgent::setTrackOptions方法的具体用法?C++ OdeAgent::setTrackOptions怎么用?C++ OdeAgent::setTrackOptions使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OdeAgent
的用法示例。
在下文中一共展示了OdeAgent::setTrackOptions方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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));
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 );
}
示例2: 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 global noise sensor to 0.05
global.odeConfig.setParam("noise",0.05);
// global.odeConfig.setParam("gravity", 0); // no gravity
// 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 initial position of the playground: setPosition(osg::Vec3(double x, double y, double z))
// - push playground to the global list of obstacles (global list comes from simulation.cpp)
OctaPlayground* playground = new OctaPlayground(odeHandle, osgHandle, osg::Vec3(10, 0.2, 1), 12);
playground->setPosition(osg::Vec3(0,0,0)); // place and create playground
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
// - add sphere to list of obstacles
for(int i=0; i<8; 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 (gyro) sensors:
// - get default configuration for robot
// - create pointer to spherical robot (with odeHandle, osgHandle and configuration)
// - place robot (unfortunatelly there is a type cast necessary, which is not quite understandable)
Sphererobot3MassesConf conf = Sphererobot3Masses::getDefaultConf();
conf.addSensor(new AxisOrientationSensor(AxisOrientationSensor::ZProjection));
conf.diameter=1.0;
conf.pendularrange= 0.35;
robot = new Sphererobot3Masses ( odeHandle, osgHandle.changeColor(Color(1.0,0.0,0)),
conf, "Spherical", 0.2);
(robot)->place ( Pos( 0 , 0 , 0.1 ));
// Selforg - Controller (Note there are several: use Sos or Sox now)
// create pointer to controller
// set some parameters
// push controller in global list of configurables
controller = new InvertMotorSpace(10);
controller->setParam("epsA",0.05); // model learning rate
controller->setParam("epsC",0.2); // controller learning rate
controller->setParam("rootE",3); // model and contoller learn with square rooted error
global.configs.push_back ( controller );
// SineController (produces just sine waves)
// controller = new SineController();
// controller->setParam("sinerate", 40);
// controller->setParam("phaseshift", 0.0);
// create pointer to one2onewiring which uses colored-noise
One2OneWiring* wiring = new One2OneWiring ( new ColorUniformNoise() );
// 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 , robot , wiring );
if(track){
// the following line will enables a position tracking of the robot, which is written into a file
// you can customize what is logged with the TrackRobotConf
TrackRobotConf tc = TrackRobot::getDefaultConf();
tc.scene = "zaxis";
tc.displayTrace = true;
agent->setTrackOptions(TrackRobot(tc));
}
global.agents.push_back ( agent );
}
示例3: start
// 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);
//.........这里部分代码省略.........
示例4: start
//.........这里部分代码省略.........
// 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);
}
}
示例5: 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);
}
示例6: start
//.........这里部分代码省略.........
}
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);
}
示例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(-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);
}