def plot(self, pylab):
        y = data_from_msg(self.input.y)
        y_goal = data_from_msg(self.input.y_goal)
        sensels = np.array(range(y.size))
        
        self.plot_anim.set_pylab(pylab)
        
        M = 0.1
        y_min = 0
        y_max = 1

        if self.config.style == 0:
            y_style = 'k-'
            y_goal_style = 'g-' 
        elif self.config.style == 1:
            y_style = 'ko'
            y_goal_style = 'go' 
        else:
            raise ValueError(self.config.style)
        
        self.plot_anim.plot('y_goal', sensels, y_goal, y_goal_style)
        self.plot_anim.plot('y', sensels, y, y_style)
        
        n = y.size
        border = n / 100.0
        pylab.axis((-border, n - 1 + border, y_min - M, y_max + M))
        turn_off_all_axes(pylab)
    
        # state = self.input.state.data
        # self.plot_anim.text('state', 1, 0.7, state)
        self.plot_anim.text('clock', 0, 1, '%5.2f' % self.time_since_start)
Exemple #2
0
    def plot(self, pylab):
        res = self.input.res
        S = res['S']
        self.info(S.shape)
        
        Sx = S[0, :]
        Sy = S[1, :]
#         Sz = S[2, :]
        self.plot_anim.set_pylab(pylab)
        
        self.plot_anim.plot('Sxy', Sx, Sy, 'ko')
        pylab.axis((-1, +1, -1, +1))
        turn_off_all_axes(pylab)
Exemple #3
0
    def plot(self, pylab):
        res = self.input.res
        y0 = self.input.y0
        self.info(y0.shape)
        
        y0 = y0 / 255.0
        R = y0[..., 0].flatten()
        G = y0[..., 1].flatten()
        B = y0[..., 2].flatten()
        

        rgbs = zip(R, G, B)
#         rgbs = np.vstack((R, G, B)).T
#         print rgbs.shape
        
         
        
        if res is None or y0 is None: 
            return
        S = res['S']

        Sx = S[0, :]
        Sy = S[1, :]

#         _, N = S.shape 
#         assert rgbs.shape == (N, 3)

        fig = pylab.gcf()
        fig.patch.set_facecolor('black')

        if self.s is None:
            self.info('scatter')
            verts = [
                (-1., -1.),  # left, bottom
                (-1., 1.),  # left, top
                (1., 1.),  # right, top
                (1., -1.),  # right, bottom
                (-1., -1.),  # ignored
                ]

            codes = [Path.MOVETO,
                     Path.LINETO,
                     Path.LINETO,
                     Path.LINETO,
                     Path.CLOSEPOLY,
                     ]
            
            path = Path(verts, codes)            
            patch = patches.PathPatch(path, facecolor='black', lw=0)
            pylab.gca().add_patch(patch)

            self.s = pylab.scatter(x=Sx, y=Sy, c=rgbs, zorder=1000)


        else:
            offs = np.array((Sx, Sy)).T
            self.s.set_offsets(offs)
            self.s.set_color(rgbs)
            
            
        pylab.axis((-1, +1, -1, +1))
        turn_off_all_axes(pylab)