def check_client_step_called(self, type): input_controls = UAVControls(self.recorder.numUAVs, type) for i in xrange(self.recorder.numUAVs): input_controls.U[i, :] = i dt = 0.1 self.recorder.step(dt, input_controls) self.client.step.assert_called_once_with(dt, input_controls)
def get_controls(self, noisy_states): controls = UAVControls(len(noisy_states), 'vel') if self.targets is None: controls.U.fill(0) else: assert len(noisy_states) == len(self.targets) for uav in xrange(len(noisy_states)): controls.U[uav, :] = self._get_velocities( uav, noisy_states, self.targets[uav]) return controls
def check_client_step_type_specific_called(self, type): input_controls = UAVControls(self.recorder.numUAVs, type) for i in xrange(self.recorder.numUAVs): input_controls.U[i, :] = i dt = 0.1 getattr(self.recorder, 'step_' + type)(dt, input_controls.U) class MatchInputControls(object): def __init__(self, obj): self.obj = obj def __eq__(self, other): if self.obj.type != other.type: return False assert_equal(self.obj.U, other.U) return True self.client.step.assert_called_once_with( dt, MatchInputControls(input_controls))
def check_control_recording_of_step(self, type): input_controls = UAVControls(self.recorder.numUAVs, type) for i in xrange(self.recorder.numUAVs): input_controls.U[i, :] = i dt = 0.1 steps = 3 for i in xrange(steps): self.recorder.step(dt, input_controls) self.fileh.flush() dim = ctrl_signal_dimensions[type] controls = self.recorder.controls assert_that(controls.cols.type, only_contains( getattr(ControlsRecorder.Controls.columns['type'].enum, type))) assert_that(controls.cols.dt[:], only_contains(0.1)) for i in xrange(self.recorder.numUAVs): assert_equal( [x['U'][:dim] for x in controls.where('uav == %i' % i)], np.tile(dim * [i], (steps, 1)))
def step_wp(self, dt, WPs): controls = UAVControls(len(WPs), 'wp') controls.U[:, :] = WPs self.step(dt, controls)
def step_vel(self, dt, vels): controls = UAVControls(len(vels), 'vel') controls.U[:, :] = vels self.step(dt, controls)
def step_ctrl(self, dt, ctrl): controls = UAVControls(len(ctrl), 'ctrl') controls.U[:, :] = ctrl self.step(dt, controls)