Exemple #1
0
def olr_r():
    n_colors = 36
    olr_map = [cm.gist_yarg(cc) for cc in range(5 * n_colors, 0, -5)]
    olr_coltbl = ListedColormap(olr_map, name='orl_coltbl', N=n_colors)
    #olr_coltbl.set_bad(color='gray')
    olr_coltbl.set_bad(color=olr_coltbl.colors[0])
    return olr_coltbl
Exemple #2
0
def olr_r():
	n_colors=36
	olr_map =[cm.gist_yarg(cc) for cc in range(5*n_colors,0,-5)]
	olr_coltbl = ListedColormap(olr_map,name = 'orl_coltbl',N=n_colors)
	#olr_coltbl.set_bad(color='gray')
	olr_coltbl.set_bad(color= olr_coltbl.colors[0])
	return olr_coltbl
Exemple #3
0
    def plotPerception(self):
        # Let plt do dynamic plots
        plt.ion()
        # Clear current frame
        plt.clf()

        # Put the title
        plt.title('Title: {}'.format(self.planner.mode))
        plt.ylabel('height (in m)')
        plt.xlabel('distance (in m)')

        # Set the axes limits
        axes = plt.gca()
        axes.set_xlim([-0.4, 4.0])
        axes.set_ylim([-0.1, 4.2])

        # For each obstacle, plot a gray scale of the voteArray.
        # The gap corresponds to the white, and the obstacle to the black
        for obstacle in [self.firstObstacle, self.secondObstacle]:
            xObstacle = obstacle.x.estimate * \
                np.ones(self.discretizationFactor)
            yObstacle = [(i + 0.5) * CEILING / self.discretizationFactor
                         for i in range(self.discretizationFactor)]
            mini, maxi = np.min(obstacle.gapHeightFilter.voteArray), np.max(
                obstacle.gapHeightFilter.voteArray)
            diff = maxi - mini
            new_array = obstacle.gapHeightFilter.voteArray - mini
            if diff != 0:
                new_array /= float(diff)

            plt.scatter(xObstacle,
                        yObstacle,
                        c=cm.gist_yarg(new_array),
                        edgecolor='none',
                        label="obstacle")

        # Plot in green the current best estimation of the gaps positions
        xGaps = [self.firstObstacle.x.estimate, self.secondObstacle.x.estimate]
        yGaps = [
            self.firstObstacle.gapHeightFilter.estimate,
            self.secondObstacle.gapHeightFilter.estimate
        ]
        plt.plot(xGaps, yGaps, "go", label="Gaps")

        # Plot the position of Flappy in blue
        xFlappy = [0.0]
        yFlappy = [self.state.y]
        plt.plot(xFlappy, yFlappy, "bo", label="Flappy")

        plt.show(block=False)
        plt.pause(0.01)
Exemple #4
0
def plot_shaded(arr_shaded,
                angle=320,
                exploded=True,
                lims=(0, 60),
                save_only=False,
                save_name=None):
    """
    arr_shaded : np.array
        3xN array
    angle : int
        view_init angle to plot at
    exploded : bool
        whether or not to explode the points to double their original bounds
        i.e. 30 cube -> 60 cube with spaces between everything
    save_only : bool
        whether to skip showing the output and just save
    save_name : str
        what name to save the plot as
    """
    facecolors = cm.gist_yarg(arr_shaded)
    facecolors[:, :, :, -1] = arr_shaded
    facecolors = explode(facecolors)

    filled = facecolors[:, :, :, -1] != 0
    if exploded:
        x, y, z = np.indices(np.array(filled.shape) + 1)
    else:
        x, y, z = expand_coordinates(np.indices(np.array(filled.shape) + 1))

    fig = plt.figure(figsize=(5, 5))
    ax = fig.gca(projection='3d')
    ax.view_init(30, angle)
    ax.set_xlim(lims)
    ax.set_ylim(lims)
    ax.set_zlim(lims)

    ax.voxels(x, y, z, filled, facecolors=facecolors)
    if save_name:
        plt.savefig(save_name)
    if not save_only:
        plt.show()
    plt.close()
Exemple #5
0
def plot_dots(arr_shaded,
              angle=320,
              lims=(0, 30),
              save_only=False,
              save_name=None,
              dotsize_scale=1,
              dotsize_offset=0,
              figsize=(4, 4)):
    coords = binvox.dense_to_sparse(arr_shaded)
    colors = cm.gist_yarg(arr_shaded.ravel())
    dot_sizes = arr_shaded.ravel() * dotsize_scale - dotsize_offset
    fig = plt.figure(figsize=figsize)
    ax = fig.gca(projection='3d')
    ax.view_init(30, 30)
    ax.scatter3D(coords[0],
                 coords[1],
                 coords[2],
                 c=colors,
                 s=dot_sizes,
                 depthshade=False,
                 marker='.')
    plt.show()
Exemple #6
0
def olr():
	olr_map =[cm.gist_yarg(cc) for cc in range(0,255,5)]
	olr_coltbl = ListedColormap(olr_map,name = 'orl_coltbl',N=36)
	olr_coltbl.set_bad(color= olr_coltbl.colors[-1])
	return olr_coltbl
Exemple #7
0
def olr():
    olr_map = [cm.gist_yarg(cc) for cc in range(0, 255, 5)]
    olr_coltbl = ListedColormap(olr_map, name='orl_coltbl', N=36)
    olr_coltbl.set_bad(color=olr_coltbl.colors[-1])
    return olr_coltbl