def test_initialization(self, reference_value, reference_state): rg = ConstReferenceGenerator(reference_value=reference_value, reference_state=reference_state) assert rg.reference_space == Box(np.array([reference_value]), np.array([reference_value])) assert rg._reference_value == reference_value assert rg._reference_state == reference_state
def test_set_modules(self, physical_system): rg = ConstReferenceGenerator(reference_state=physical_system.state_names[1]) rg.set_modules(physical_system) assert all(rg._referenced_states == np.array([False, True]))
def reference_generator(self, physical_system): rg = ConstReferenceGenerator(reference_state=physical_system.state_names[1], reference_value=1) rg.set_modules(physical_system) return rg
return (state, ref), rew, term, info def reset(self, **kwargs): state, ref = self.env.reset() state = np.concatenate((state, np.zeros(self.env.action_space.shape))) return state, ref if __name__ == '__main__': tf.compat.v1.disable_eager_execution() window_length = 1 # Changing i_q reference and constant 0 i_d reference. q_generator = WienerProcessReferenceGenerator(reference_state='i_sq') d_generator = ConstReferenceGenerator('i_sd', 0) rg = MultipleReferenceGenerator([d_generator, q_generator]) # Change of the default motor parameters. motor_parameter = dict(r_s=15e-3, l_d=0.37e-3, l_q=1.2e-3, psi_p=65.6e-3, p=3, j_rotor=0.06) limit_values = dict(i=160 * 1.41, omega=12000 * np.pi / 30, u=450) nominal_values = {key: 0.7 * limit for key, limit in limit_values.items()} # Create the environment env = gem.make( 'emotor-pmsm-cont-v1',