def compute_action(self, plan): if len(plan) == 0: shape = self.dds.actions[0].diffeo.get_shape() identity_cmd = np.array([0, 0]) return DiffeoAction.identity('id', shape, identity_cmd) # XXX last = self.dds.actions[plan[-1]] if len(plan) == 1: return last else: rest = self.compute_action(plan[:-1]) return DiffeoAction.compose(last, rest)
def plan2action(self, plan): if len(plan) == 0: shape = self.dds.actions[0].diffeo.get_shape() identity_cmd = np.array([0, 0]) return DiffeoAction.identity('id', shape, identity_cmd) # XXX last = self.dds.actions[plan[-1]] if len(plan) == 1: return last else: rest = self.plan2action(plan[:-1]) return DiffeoAction.compose(last, rest)
def display_products(self, report, nsteps): for a in self.dds_hard.actions: f = report.figure(a.label, cols=nsteps) A = a for k in range(nsteps): A = DiffeoAction.compose(A, a) rgb = A.get_diffeo2d_forward().get_rgb_info() f.data_rgb('%s_%s' % (a.label, k), rgb)
def show_compositions(self, report): # f_ba = report.figure() n = len(self.dds.actions) f_ab_norm = report.figure(cols=n, caption='Norm of AB') f_ab_phase = report.figure(cols=n, caption='Phase of AB') f_ab_info = report.figure(cols=n, caption='Certainty of AB') for a, b in iterate_indices((n, n)): A = self.dds.actions[a] B = self.dds.actions[b] AB = DiffeoAction.compose(A, B) norm_rgb = diffeo_to_rgb_norm(AB.diffeo.d) phase_rgb = diffeo_to_rgb_angle(AB.diffeo.d) info_rgb = scalaruncertainty2rgb(AB.diffeo.variance) label = '%s-%s' % (A.label, B.label) caption = '%s, %s' % (A.label, B.label) f_ab_norm.data_rgb('%s_norm' % label, norm_rgb, caption=caption) f_ab_phase.data_rgb('%s_phase' % label, phase_rgb, caption=caption) f_ab_info.data_rgb('%s_info' % label, info_rgb, caption=caption)
def make_hard_action(a): label = a.label diffeo = make_hard(a.get_diffeo2d_backward()) diffeo_inv = make_hard(a.get_diffeo2d_forward()) original_cmd = a.original_cmd return DiffeoAction(label, diffeo, diffeo_inv, original_cmd)