|
Hormodular 1.0
Locomotion gait discovery by using digital hormones on modular robots
|
Extract the oscillator parameters encoded in the genotype and set them in the oscillators. {
std::vector<float> amplitudes;
std::vector<float> offsets;
std::vector<float> phases;
float frequency;
for(int i = 0; i < (int) n_modules; i++)
{
float amplitude = genotype->realValue[i*3] * max_amp_0_5 + max_amp_0_5;
float offset = genotype->realValue[i*3+1] * max_offset;
float phase = genotype->realValue[i*3+2] * max_pha_0_5 + max_pha_0_5;
amplitudes.push_back(amplitude);
offsets.push_back(offset);
phases.push_back(phase);
}
frequency = genotype->realValue[n_modules*3] * max_freq_0_5 + max_freq_0_5;
//-- Set the parameters to the oscillators:
int period = (int) ( 1000.0 / frequency);
for (int i = 0; i < (int) oscillators.size(); i++)
oscillators[i]->setParameters( amplitudes[i], offsets[i], phases[i], period);
}
|
1.7.4