Exemplo n.º 1
0
    def update(self):
        y = array(self.input.readings_dot)
        from procgraph_mpl import pylab2rgb, pylab

        if max(abs(y)) > 1:
            raise BadInput('I expect an input normalized in the [-1,1] range;'
                           'min,max: %s,%s ' % (min(y), max(y)),
                           self, 'readings_dot')

        f = pylab.figure(frameon=False,
                        figsize=(self.config.width / 100.0,
                                 self.config.height / 100.0))

        R0 = self.config.R0
        amp = self.config.amp

        theta = linspace(0, 2 * math.pi, 300)
        pylab.plot(R0 * cos(theta), R0 * sin(theta), 'k--')

        for group in self.config.groups:
            indices = group['indices']
            indices = range(indices[0], indices[-1] + 1)
            theta_spec = group['theta']
            origin = group.get('origin', [0, 0, 0])
            color = group.get('color', 'b.')

            N = len(indices)

            theta = linspace(theta_spec[0], theta_spec[-1], N)

            group_y = y[indices]

            r = R0 + amp * group_y

            px = cos(theta + origin[2]) * r
            py = sin(theta + origin[2]) * r

            pylab.plot(-py, px, color)

        M = R0 + amp * 1.2
        pylab.axis([-M, M, -M, M])

        # turn off ticks labels, they don't have meaning
        pylab.setp(f.axes[0].get_xticklabels(), visible=False)
        pylab.setp(f.axes[0].get_yticklabels(), visible=False)

        if self.config.title is not None:
            if self.config.title != "":
                pylab.title(self.config.title, fontsize=10)
        else:
            # We don't have a title ---
            t = self.get_input_signals_names()[0]
            pylab.title(t, fontsize=10)

        self.output.image = pylab2rgb(transparent=self.config.transparent)

        pylab.close(f.number)
Exemplo n.º 2
0
    def update(self):        
        position = array(self.input.position)
                
        f = pylab.figure(frameon=False,
                        figsize=(self.config.width / 100.0,
                                 self.config.width / 100.0))
         
 
        plot_posts_xy(pylab, self.arena_info)
    
        x = position[:, 0]
        y = position[ :, 1]
        xc = x[-1]
        yc = y[-1]
        
         
        pylab.plot(x, y, 'b.')
        
        attitude = self.input.attitude
        
        fwd = numpy.dot(attitude, [1, 0, 0]) * self.config.arrow_length
        pylab.plot([xc, xc + fwd[0] ], [yc, yc + fwd[1]])
        
            
        Z = self.config.zoom_area
        
        R = self.arena_info['arena']['diameter'] / 2 
        cx = self.arena_info['arena']['origin'][0]
        cy = self.arena_info['arena']['origin'][1]
         
        # draw arena
        theta = numpy.linspace(0, numpy.pi * 2.01, 500)
        x = numpy.cos(theta) * R + cx
        y = numpy.sin(theta) * R + cy
        pylab.plot(x, y, 'k-')
         
        pylab.axis([-Z + xc , Z + xc, -Z + yc, Z + yc])

        # turn off ticks labels
        pylab.setp(f.axes[0].get_xticklabels(), visible=False)
        pylab.setp(f.axes[0].get_yticklabels(), visible=False)
   
        self.output.rgb = pylab2rgb(transparent=False, tight=True)

        pylab.close(f.number)
Exemplo n.º 3
0
    def update(self):        
        R = self.arena_info['arena']['diameter'] / 2 
        cx = self.arena_info['arena']['origin'][0]
        # cy = self.arena_info['arena']['origin'][1]
        h = self.arena_info['arena']['height']

        
        width = self.config.width
        ratio = h / (2 * R)
        height = ratio * width
                
        f = pylab.figure(frameon=False,
                        figsize=(width / 100.0,
                                 height / 100.0))
              
        plot_posts_xz(pylab, self.arena_info)
    
        position = array(self.input.position)
        
        x = position[:, 0]
        z = position[:, 2]
        xl = x[-1]
        zl = z[-1]
         
        pylab.plot(x, z, 'b.')
            
         
        # draw arena
        x = [cx - R, cx - R, cx + R, cx + R, cx - R]
        z = [0, h, h, 0, 0]
        pylab.plot(x, z, 'k-')
         
        aw = self.config.zoom_area
        ah = ratio * aw
    
        pylab.axis([ xl - aw , xl + aw, zl - ah, zl + ah])

        # turn off ticks labels
        pylab.setp(f.axes[0].get_xticklabels(), visible=False)
        pylab.setp(f.axes[0].get_yticklabels(), visible=False)
   
        self.output.rgb = pylab2rgb(transparent=False, tight=True)

        pylab.close(f.number)
Exemplo n.º 4
0
    def update(self):
        position = array(self.input.position)
        
        R = self.arena_info['arena']['diameter'] / 2 
        cx = self.arena_info['arena']['origin'][0]
        # cy = self.arena_info['arena']['origin'][1]
        h = self.arena_info['arena']['height']
        
        width = self.config.width
        height = h / (2 * R) * width
                
        f = pylab.figure(frameon=False,
                        figsize=(width / 100.0,
                                 height / 100.0)) 
    
        
        plot_posts_xz(pylab, self.arena_info)
        
            
        x = position[:, 0]
        z = position[:, 2]
         
        pylab.plot(x, z, 'b-')
        
         
        # draw arena
        x = [cx - R, cx - R, cx + R, cx + R, cx - R]
        z = [0, h, h, 0, 0]
        pylab.plot(x, z, 'k-')
         
        R *= 1.1
        pylab.axis([-R + cx , R + cx, -0.05, h + 0.05])

        # turn off ticks labels
        pylab.setp(f.axes[0].get_xticklabels(), visible=False)
        pylab.setp(f.axes[0].get_yticklabels(), visible=False)
   
        self.output.rgb = pylab2rgb(transparent=False, tight=True)

        pylab.close(f.number)
Exemplo n.º 5
0
    def update(self):        
        position = array(self.input.position)
        
        f = pylab.figure(frameon=False,
                        figsize=(self.config.width / 100.0,
                                 self.config.width / 100.0))
    
        if self.arena_info:
            plot_posts_xy(pylab, self.arena_info)
    
    
        x = position[:, 0]
        y = position[ :, 1]
         
        pylab.plot(x, y, 'b-')
            
        R = self.arena_info['arena']['diameter'] / 2 
        cx = self.arena_info['arena']['origin'][0]
        cy = self.arena_info['arena']['origin'][1]
         
        # draw arena
        theta = numpy.linspace(0, numpy.pi * 2.01, 500)
        x = numpy.cos(theta) * R + cx
        y = numpy.sin(theta) * R + cy
        pylab.plot(x, y, 'k-')
         
        R *= 1.1
        pylab.axis([-R + cx , R + cx, -R + cy, R + cy])

        # turn off ticks labels
        pylab.setp(f.axes[0].get_xticklabels(), visible=False)
        pylab.setp(f.axes[0].get_yticklabels(), visible=False)

 
        self.output.rgb = pylab2rgb(transparent=False, tight=True)

        pylab.close(f.number)
Exemplo n.º 6
0
    def update(self):

        readings = array(self.input.readings)

        if len(readings.shape) > 1:
            msg = 'Expected flat array, got shape %s' % str(readings.shape)
            raise BadInput(msg, self, 0)

        from procgraph_mpl import pylab, pylab2rgb


        f = pylab.figure(frameon=False,
                        figsize=(self.config.width / 100.0,
                                 self.config.height / 100.0))

        # limit the readings

        bounds = array([0, 0, 0, 0])

        for group in self.config.groups:
            indices = group['indices']
            indices = range(indices[0], indices[-1] + 1)
            theta_spec = group['theta']
            origin = group.get('origin', [0, 0, 0])
            color = group.get('color', 'b.')

            max_readings = group.get('max_readings', self.config.max_readings)
            group_readings = minimum(readings[indices], max_readings)

            N = len(indices)

            theta = linspace(theta_spec[0], theta_spec[-1], N)

            assert len(theta) == len(group_readings)

            x = cos(theta + origin[2]) * group_readings + origin[0]
            y = sin(theta + origin[2]) * group_readings + origin[1]

            valid_flag = group_readings < max_readings
            valid, = nonzero(valid_flag)
            invalid, = nonzero(logical_not(valid_flag))

            pylab.plot(-y[valid], x[valid], color)
            pylab.plot(-y[invalid], x[invalid], 'r.')

            R = max_readings * 1.1
            x_R = R * cos(theta)
            y_R = R * sin(theta)
            group_bounds = array([min(x_R), max(x_R), min(y_R), max(y_R)])
            for i in [1, 3]:
                bounds[i] = maximum(bounds[i], group_bounds[i])
            for i in [0, 2]:
                bounds[i] = minimum(bounds[i], group_bounds[i])

        pylab.axis(bounds)

        if self.config.title is not None:
            if self.config.title != "":
                pylab.title(self.config.title, fontsize=10)
        else:
            # We don't have a title ---
            t = self.get_input_signals_names()[0]
            pylab.title(t, fontsize=10)

        self.output.image = pylab2rgb(transparent=self.config.transparent)
        #tight=True)

        pylab.close(f.number)