Exemple #1
0
    def run_simulation(self, render, logging):
        cpg_params = self.simulation['cpg_params']
        self.model_file = None
        if not self.experiment['default_morphology']:
            self.model_file = '/Users/Siebe/Dropbox/Thesis/Scratches/model.xml'
        elif self.experiment['variation_params']:
            model_files, variation_dicts = generate_model_variations(
                self.experiment['default_morphology'],
                self.experiment['variation_params'],
                num=1)
            print(variation_dicts)
            self.model_file = model_files[0]
        elif not self.experiment['delta_dicts']:
            self.model_file = generate_temp_model_file(
                self.experiment['default_morphology'])
        elif not self.model_file:
            model_config = dict_elementwise_operator(
                self.experiment['default_morphology'],
                self.experiment['delta_dicts'][
                    self.simulation['variation_index']])
            self.model_file = generate_temp_model_file(model_config)

        perturbations = self.simulation.get('perturbation', [])
        return evaluate(self.model_file, self.closed_loop, cpg_params,
                        perturbations, render, logging)
def generate_variations(morphology, test_percentage, num_variations=100):
    spring_std_dev = test_percentage * BASE_STIFFNESS / 100

    variation_params = variation_params = {
        'legs': {
            'FL': {
                'spring_stiffness': {
                    'normal': [0, spring_std_dev**2]
                },
            },
            'FR': {
                'spring_stiffness': {
                    'normal': [0, spring_std_dev**2]
                },
            },
            'BL': {
                'spring_stiffness': {
                    'normal': [0, spring_std_dev**2]
                },
            },
            'BR': {
                'spring_stiffness': {
                    'normal': [0, spring_std_dev**2]
                },
            },
        }
    }

    variation_paths, _ = generate_model_variations(morphology,
                                                   variation_params,
                                                   num_variations)
    return variation_paths
Exemple #3
0
 def setup_model_variations(self):
     self.model_files = []
     if not self.variation_params:
         self.model_files.append(
             generate_temp_model_file(self.default_morphology))
     else:
         variation_xml_paths, delta_dicts = generate_model_variations(
             self.default_morphology, self.variation_params,
             self.num_variations)
         self.model_files.extend(variation_xml_paths)
         self.variation_delta_dicts = delta_dicts
Exemple #4
0
    def sample_variations(self, num):
        model_files = []
        variation_delta_dicts = []
        if not self.variation_params:
            model_files.append(
                generate_temp_model_file(self.default_morphology))
        else:
            variation_xml_paths, delta_dicts = generate_model_variations(
                self.default_morphology, self.variation_params, num)
            model_files.extend(variation_xml_paths)
            variation_delta_dicts = delta_dicts

        return (model_files, variation_delta_dicts)
Exemple #5
0
def generate_variations(morphology, test_percentage, num_variations=100):
    mass_std_dev = test_percentage * BASE_MASS / 100

    variation_params = {
        'body': {
            'front': {
                'mass': {
                    'normal': [0, mass_std_dev**2]
                },
            },
            'hind': {
                'mass': {
                    'normal': [0, mass_std_dev**2]
                },
            },
        },
    }

    variation_paths, _ = generate_model_variations(morphology,
                                                   variation_params,
                                                   num_variations)
    return variation_paths
def generate_variations(morphology, test_percentage, num_variations=100):
	friction_std_dev_front = test_percentage * BASE_FRICTION_FRONT/100
	friction_std_dev_back = test_percentage * BASE_FRICTION_BACK/100

	variation_params = variation_params = {
		'legs': {
			'FL': {
				'foot_friction': {'normal': [0, friction_std_dev_front**2]},
			},
			'FR': {
				'foot_friction': {'normal': [0, friction_std_dev_front**2]},
			},
			'BL': {
				'foot_friction': {'normal': [0, friction_std_dev_back**2]},
			},
			'BR': {
				'foot_friction': {'normal': [0, friction_std_dev_back**2]},
			},
		}
	}

	variation_paths, _ = generate_model_variations(morphology, variation_params, num_variations)
	return variation_paths