Example #1
0
def simulateKernel(swarmPlot, a, b):
    # move drones according to current velocity
    nSwarmPlot = sw.moveSwarm(swarmPlot, simAx, swarm)
    # find neighbours of target drone
    neighbours = est.nearestNeighbours(swarm, targDrone, 1.0)
    # use off the shelf gaussian kernel to estimate distribtuion
    distribution = est.GaussianKde(neighbours, X, Y, isSwarm=True)
    # show heatmap
    simAx.imshow(np.flipud(distribution),
                 cmap=plt.cm.gist_earth_r,
                 extent=[0, xMax, 0, yMax])

    return nSwarmPlot, a, b
Example #2
0
def simulateKernel(swarmPlot, velField,heatMap):
    heatMap.remove();
    nSwarmPlot = sw.moveSwarm(swarmPlot, simAx, swarm);
    nVelField = vf.updateVel(velField, simAx, X,Y,swarm);
    points = sw.extractPos(swarm);
    distribution = est.GaussianKde(points,X,Y)       
    nheatMap = simAx.imshow(np.fliplr(distribution), cmap=plt.cm.gist_earth_r, #np.flipud()
                           extent=[0, xMax, 0, yMax]);   

    return nSwarmPlot, nVelField, nheatMap;
Example #3
0
def showVel(swarm, simAx, X, Y, visualize):
    XX, XY = X.shape
    U = np.zeros((XX, XY))
    V = np.zeros((XX, XY))
    desiredRho = est.desiredDensity()
    for drone in swarm:
        localGauss = est.localGaussian(swarm, drone, 3.0)
        #last parameter is radius
        vel = df.velocity(localGauss, drone, 0.3, desiredRho)
        if drone.yInd() >= 32 or drone.xInd() >= 32:
            print "Stop"
        U[drone.yInd(), drone.xInd()] = vel[0]
        V[drone.yInd(), drone.xInd()] = vel[1]
        #        print vel;
        drone.vx = vel[0]
        drone.vy = vel[1]
    if visualize:
        M = np.hypot(U, V)
        Q = simAx.quiver(X,
                         Y,
                         U,
                         V,
                         M,
                         units='x',
                         pivot='mid',
                         width=0.022,
                         scale=0.75)
        qk = simAx.quiverkey(Q,
                             0.9,
                             0.9,
                             1,
                             r'$1 \frac{m}{s}$',
                             labelpos='E',
                             coordinates='figure')
        plt.show()
        return Q
    else:
        return None
Example #4
0
#U = np.cos(X)/speedFactor;
#V = np.sin(Y)/speedFactor;

#-------------- add drones ------------------#
swarm = sw.initSwarm(xMax, yMax, xIndMax, yIndMax, resolution, num=20)

#---------------------per scene logistics ----------------------------#
# Generate velocity visualization
fig, simAx = plt.subplots()
simAx.set_title("Velocity field visualization")

# initialize velocity and position
velField = vf.showVel(swarm, simAx, X, Y, False)
swarmPlot = sw.showSwarm(swarm, simAx)
points = sw.extractPos(swarm)
distribution = est.GaussianKde(points, X, Y)
heatMap = simAx.imshow(np.flipud(distribution),
                       cmap=plt.cm.gist_earth_r,
                       extent=[0, xMax, 0, yMax])
fig.colorbar(heatMap)
simAx.set_xlim([0, xMax])
simAx.set_ylim([0, yMax])


# simulateKernel is called per scene
def simulateKernel(swarmPlot, velField, heatMap):
    heatMap.remove()
    nSwarmPlot = sw.moveSwarm(swarmPlot, simAx, swarm)
    nVelField = vf.updateVel(velField, simAx, X, Y, swarm)
    points = sw.extractPos(swarm)
    distribution = est.GaussianKde(points, X, Y)
Example #5
0
U = np.cos(X) / speedFactor
V = np.sin(Y) / speedFactor
xIndMax, yIndMax = X.shape

#-------------- add drones ------------------#
swarm = sw.initSwarm(xMax,
                     yMax,
                     xIndMax,
                     yIndMax,
                     resolution,
                     num=40,
                     verbose=False)

#-------------- gaussian estimation ------------------#
targDrone = swarm[0]
neighbours = est.nearestNeighbours(swarm, targDrone, 1.0)
distribution = est.GaussianKde(neighbours, X, Y, isSwarm=True)

#---------------------per scene logistics ----------------------------#
fig, simAx = vf.showField(X, Y, U, V, returnHandle=True)
swarmPlot = sw.showSwarm(swarm, simAx)


def simulateKernel(swarmPlot, a, b):
    # move drones according to current velocity
    nSwarmPlot = sw.moveSwarm(swarmPlot, simAx, swarm)
    # find neighbours of target drone
    neighbours = est.nearestNeighbours(swarm, targDrone, 1.0)
    # use off the shelf gaussian kernel to estimate distribtuion
    distribution = est.GaussianKde(neighbours, X, Y, isSwarm=True)
    # show heatmap