def __init__(self, decoding_rate=180): ''' Constructor for OFCEndpointAssister Parameters ---------- decoding_rate : int Rate that the decoder should operate, in Hz. Should be a multiple or divisor of 60 Hz Returns ------- OFCEndpointAssister instance ''' F_dict = pickle.load( open('/storage/assist_params/assist_20levels_ppf.pkl')) B = np.mat( np.vstack([ np.zeros([3, 3]), np.eye(3) * 1000 * 1. / decoding_rate, np.zeros(3) ])) fb_ctrl = feedback_controllers.MultiModalLFC(A=B, B=B, F_dict=F_dict) super(OFCEndpointAssister, self).__init__(fb_ctrl, style='additive_cov') self.n_assist_levels = len(F_dict)
def create_learner(self): self.learn_flag = True kwargs = dict() dt = kwargs.pop('dt', 1. / 180) use_tau_unNat = self.tau self.tau = use_tau_unNat print "learner cost fn param: %g" % use_tau_unNat tau_scale = 28 * use_tau_unNat / 1000 bin_num_ms = (dt / 0.001) w_r = 3 * tau_scale**2 / 2 * (bin_num_ms)**2 * 26.61 I = np.eye(3) zero_col = np.zeros([3, 1]) zero_row = np.zeros([1, 3]) zero = np.zeros([1, 1]) one = np.ones([1, 1]) A = np.bmat([[I, dt * I, zero_col], [0 * I, 0 * I, zero_col], [zero_row, zero_row, one]]) B = np.bmat([[0 * I], [dt / 1e-3 * I], [zero_row]]) Q = np.mat(np.diag([1., 1, 1, 0, 0, 0, 0])) R = np.mat(np.diag([w_r, w_r, w_r])) F = feedback_controllers.LQRController.dlqr(A, B, Q, R) F_dict = dict(target=F, hold=F) fb_ctrl = feedback_controllers.MultiModalLFC(A=A, B=B, F_dict=F_dict) batch_size = 1 self.learner = clda.OFCLearner(batch_size, A, B, F_dict) # Tell BMISystem that this learner wants the most recent output # of the decoder rather than the second most recent, to match MATLAB self.learner.input_state_index = 0