//---------------------------------------------------------------------------------------------------------------------- void SMCAgent::init() { m_radius = 0.02; if (SETTINGS->hasChild("Config/GA/Evolvable")) { const ci::XmlTree& xml = SETTINGS->getChild("Config/GA/Evolvable"); // Todo: move to respective sensor class!!! // Distance sensor if (xml.getChild("DistanceSensor").getValue<bool>(0)) { m_distanceSensor = new DistanceSensor(); m_distanceSensor->fromXml(xml.getChild("DistanceSensor")); setSensorMode(xml.getChild("DistanceSensor").getAttributeValue<std::string>("Mode", "Absolute")); } else { m_distanceSensor = NULL; } // Gradient sensor if (xml.getChild("GradientSensor").getValue<bool>(0)) { m_gradientSensor = new GradientSensor(); m_gradientSensor->fromXml(xml.getChild("GradientSensor")); } else { m_gradientSensor = NULL; } // Torus sensor if (xml.getChild("TorusSensor").getValue<bool>(0)) { m_torusSensor = new TorusSensor(); m_torusSensor->fromXml(xml.getChild("TorusSensor")); } else { m_torusSensor = NULL; } setMaxSpeed(xml.getChild("MaxSpeed").getValue<double>(1.0)); setMaxAngularSpeed(degreesToRadians(xml.getChild("MaxAngularSpeed").getValue<double>(180))); setMaxAngle(degreesToRadians(xml.getChild("MaxAngle").getValue<double>(90))); setMaxPosition(xml.getChild("MaxPosition").getValue<double>(0.5)); setAngleWraps(xml.getChild("AngleWraps").getValue<bool>(1)); setPositionWraps(xml.getChild("PositionWraps").getValue<bool>(1)); m_energyInitial = xml.getChild("Energy").getAttributeValue<float>("initial", 30.0); m_energySpeedTresh = xml.getChild("Energy").getAttributeValue<float>("threshForSpeed", -1); m_evMin = xml.getChild("Energy").getAttributeValue<float>("evMin", 0); m_evMax = xml.getChild("Energy").getAttributeValue<float>("evMax", 10); m_engReplFoodSens = xml.getChild("Energy").getAttributeValue<bool>("engReplFoodSens", false); getEnvironment().fromXml(xml.getChild("Environment")); } reset(); }
void CIrrOdeWorld::initPhysics() { if (m_bPhysicsInitialized) return; m_iNodesInitialized=0; CIrrOdeSceneNode::initPhysics(); m_iWorldId=m_pOdeDevice->worldCreate(); m_iJointGroupId=m_pOdeDevice->jointGroupCreate(0); if (!m_pWorldSpace) m_pWorldSpace=new CIrrOdeSpace(this,m_pSceneManager); if (m_pWorldSpace!=NULL) m_pWorldSpace->initPhysics(); setLinearDamping (m_fDampingLinear ); setAngularDamping (m_fDampingAngular ); setLinearDampingThreshold (m_fDampingLinearThreshold ); setAngularDampingThreshold(m_fDampingAngularThreshold); setAutoDisableFlag (m_iAutoDisableFlag ); setAutoDisableLinearThreshold (m_fAutoDisableLinearThreshold ); setAutoDisableAngularThreshold(m_fAutoDisableAngularThreshold); setAutoDisableSteps (m_iAutoDisableSteps ); setAutoDisableTime (m_fAutoDisableTime ); setGravity(m_cGravity); if (m_fMaxAngularSpeed!=_DEFAULT_MAX_ANGULAR_SPEED) setMaxAngularSpeed(m_fMaxAngularSpeed); #ifdef _TRACE_INIT_PHYSICS printf("world created .. id=%i\n",(int)m_iWorldId); #endif irr::core::list<CIrrOdeSpace *>::Iterator s; for (s=m_pSpaces.begin(); s!=m_pSpaces.end(); s++) { #ifdef _TRACE_INIT_PHYSICS printf("CIrrOdeWorld::initPhysics: init space\n"); #endif CIrrOdeSpace *pSpace=(*s); pSpace->initPhysics(); } irr::core::list<CIrrOdeGeom *>::Iterator i; for (i=m_pGeoms.begin(); i!=m_pGeoms.end(); i++) { #ifdef _TRACE_INIT_PHYSICS printf("CIrrOdeWorld::initPhysics: init geom\n"); #endif CIrrOdeGeom *pGeom=(*i); pGeom->initPhysics(); } irr::core::list<CIrrOdeBody *>::Iterator b,ib2; for (b=m_pBodies.begin(); b!=m_pBodies.end(); b++) { #ifdef _TRACE_INIT_PHYSICS printf("CIrrOdeWorld::initPhysics: init body\n"); #endif CIrrOdeBody *b1=*b; b1->initPhysics(); } irr::core::list<irr::ode::IIrrOdeStepMotor *>::Iterator it; for (it=m_lStepMotors.begin(); it!=m_lStepMotors.end(); it++) (*it)->initPhysics(); m_bPhysicsInitialized = true; }