本文整理汇总了C++中Joint::init方法的典型用法代码示例。如果您正苦于以下问题:C++ Joint::init方法的具体用法?C++ Joint::init怎么用?C++ Joint::init使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Joint
的用法示例。
在下文中一共展示了Joint::init方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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(-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",1);
global.odeConfig.setParam("noise",0.01);
global.odeConfig.setParam("realtimefactor",1);
global.odeConfig.setParam("gravity", -6);
// global.odeConfig.setParam("cameraspeed", 250);
// int chessTexture = dsRegisterTexture("chess.ppm");
bool useDerivativeWiring=false;
// environemnt (type is set in constructor)
env.numSpheres = 0;
env.numBoxes = 0;
env.numCapsules = 0;
env.numSeeSaws = 0;
env.roughness = 1.0;
// use Playground as boundary:
if(barriers){
env.widthground = 4;
env.distance = 6;
env.numgrounds = 5;
env.height = 0.1;
env.heightincrease =0.1;
}else {
env.widthground = 32;
env.height = 1.0;
}
env.create(odeHandle, osgHandle, global);
global.configs.push_back(&env);
// Boxpile* boxpile = new Boxpile(odeHandle, osgHandle, Pos(10,10,0.2),
// 100,0, Pos(0.3,0.3,0.05), Pos(0.3,0.3,0.05)
// );
// boxpile->setColor("wall");
// boxpile->setPose(ROTM(M_PI/5.0,0,0,1)*TRANSM(0, 0 ,0.2));
// global.obstacles.push_back(boxpile);
for (int i=0; i< 1/*2*/; i++){ //Several dogs
// VierBeinerConf conf = VierBeiner::getDefaultConf();
VierBeinerConf conf = VierBeiner::getDefaultConfVelServos();
conf.dampingFactor = .0;
conf.powerFactor = 1.3;
if(air) conf.powerFactor = 0.3;
if (hippo) conf.powerFactor = 1.5;
conf.hipJointLimit = M_PI/3.0;
if ( barriers) conf.hipJointLimit = M_PI/2.5;
conf.kneeJointLimit = M_PI/3;
conf.legNumber = 4; /* for the dog's sake use only even numbers */
conf.useBigBox = false;
if(hippo) conf.useBigBox = false;
conf.drawstupidface=true;
conf.hippo = hippo;
// conf.onlyMainParameters = false; // all parameters
OdeHandle doghandle = odeHandle;
doghandle.substance.toRubber(10);
VierBeiner* dog = new VierBeiner(doghandle, osgHandle,conf, "Dog");
std::list<Sensor*> sensors;
sensors.push_back(new SpeedSensor(1,SpeedSensor::TranslationalRel));
AddSensors2RobotAdapter* robot =
new AddSensors2RobotAdapter(odeHandle,osgHandle,dog, sensors);
//dog->place(osg::Matrix::translate(0,0,0.15));
robot->place(osg::Matrix::translate(0,0,.5 + 4*i));
if(air || barriers){
Primitive* trunk = dog->getMainPrimitive();
fixator = new FixedJoint(trunk, global.environment);
fixator->init(odeHandle, osgHandle);
}
// create pointer to one2onewiring
//AbstractWiring* wiring = new One2OneWiring(new ColorUniformNoise(0.1));
double booster = 0.05;
if(air) booster=0;
AbstractWiring* wiring;
if(!useDerivativeWiring){
wiring = new ForceBoostWiring(new ColorUniformNoise(0.1), booster);
}else{
////////////////
AbstractWiring* fbw = new ForceBoostWiring(new NoNoise(), booster);
DerivativeWiringConf dc = DerivativeWiring::getDefaultConf();
//.........这里部分代码省略.........
示例2: start
// 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);
//.........这里部分代码省略.........