Hormodular 1.0
Locomotion gait discovery by using digital hormones on modular robots
bool ModularRobotEvalOp::initialize ( StateP  state)

Loads custom-made registry entries to the ECF.

{
    //-- Get the robot values from the registry:
    //-----------------------------------------------------------------------------------------
    //-- Number of modules:
    voidP sptr = state->getRegistry()->getEntry("robot.modules");
    n_modules = *((uint*) sptr.get() );
    std::cout << "[Evolve] Info: Loaded \"robot.modules\"="<< n_modules << std::endl;

    //-- Max runtime:
    sptr = state->getRegistry()->getEntry("robot.runtime");
    max_runtime =(unsigned long) *((uint*) sptr.get() );
    std::cout << "[Evolve] Info: Loaded \"robot.runtime\"="<< max_runtime << std::endl;

    //-- Time step:
    sptr = state->getRegistry()->getEntry("robot.timestep");
    timestep = *((float*) sptr.get() );
    std::cout << "[Evolve] Info: Loaded \"robot.timestep\"="<< timestep << std::endl;

    //-- Gait table file:
    sptr = state->getRegistry()->getEntry("robot.configfile");
    config_file = *((std::string*) sptr.get() );
    std::cout << "[Evolve] Info: Loaded \"robot.configfile\"="<< config_file << std::endl;

    //-- Get the oscillator parameters from the registry:
    //---------------------------------------------------------------------------------------
    //-- Max amplitude:
    sptr = state->getRegistry()->getEntry("osc.maxamplitude");
    int max_amplitude = *((uint*) sptr.get());
    max_amp_0_5 = max_amplitude / 2.0;
    std::cout << "[Evolve] Info: Loaded \"osc.maxamplitude\"="<< max_amplitude << std::endl;

    //-- Max offset:
    sptr = state->getRegistry()->getEntry("osc.maxoffset");
    max_offset = *((uint*) sptr.get());
    std::cout << "[Evolve] Info: Loaded \"osc.maxoffset\"="<< max_offset << std::endl;

    //-- Max phase:
    sptr = state->getRegistry()->getEntry("osc.maxphase");
    int max_phase = *((uint*) sptr.get());
    max_pha_0_5 = max_phase / 2.0;
    std::cout << "[Evolve] Info: Loaded \"osc.maxphase\"="<< max_phase << std::endl;

    //-- Max frequency:
    sptr = state->getRegistry()->getEntry("osc.maxfrequency");
    float max_frequency = *((float*) sptr.get());
    max_freq_0_5 = max_frequency / 2.0;
    std::cout << "[Evolve] Info: Loaded \"osc.maxfrequency\"="<< max_frequency << std::endl;

    //-- Create and configure the robot parts
    //---------------------------------------------------------------------------------------
    //-- Read test data
    if ( configParser.parse(config_file) != 0)
    {
        std::cerr << "[Evolve] Error: error parsing xml config file!" << std::endl;
        return false;
    }

    if ( configParser.getNumModules() != n_modules )
    {
        std::cerr << "[Evolve] Error: number of modules not consitent between config file and "
                  << "robot model." << std::endl;
        return false;
    }
    //-- Create robot, simulated type
    robotInterface = createModularRobotInterface( "simulated", configParser);

    //-- Create sinusoidal oscillators with the test parameters
    oscillators.clear();
    for ( int i = 0; i < configParser.getNumModules(); i++)
        oscillators.push_back(new SinusoidalOscillator( 0, 0, 0, 4000));

    robotInterface->reset();

    return true;
}

Here is the call graph for this function:

 All Classes Functions Variables Friends