예제 #1
0
파일: gridworld.py 프로젝트: COLAB2/tagsim
 def loadTagList(self,fname="tags"):
     f=open(fname+".csv",'r')
     taglist=[]
     from AcousticTag import AcousticTag
     for line in f.readlines():
         last_ping,posx,posy,posz,delay,ID,bin=line.split(',')
         tag = AcousticTag(ID,last_ping=float(last_ping),ping_delay=float(delay))
         tag.pos=np.array([float(posx),float(posy),float(posz)])
         tag.bin=bin
         taglist.append(tag)
     f.close()
     self.taglist=taglist
     return taglist
예제 #2
0
    plt.xlim([0, grid.x_range])
    plt.ylim([0, grid.y_range])
    plt.xticks(np.arange(0, grid.x_range, grid.x_range / 5.0))
    plt.yticks(np.arange(0, grid.y_range, grid.y_range / 5.0))

    plt.draw()


taglist = []
N = 100  # number of tags to be generated in field
#generate N tags and append to taglist
for i in range(N):
    delay = max(1, 30 * np.random.rand())
    #each tag object has an ID, an offset (last_ping), and a delay between pings (ping_delay)
    taglist.append(
        AcousticTag(i, last_ping=-delay * np.random.rand(), ping_delay=delay))
# create grid world object
grid = Grid(taglist, x_range=100, y_range=100)
#make map of densities for each cell
density_map = np.array([
    0.1, 0.1, 0.4, 0.3, 0.2, 0.1, 0.3, 0.3, 0.1, 0.3, 0.2, 0.3, 0.3, 0.2, 0.1,
    0.3, 0.9, 0.3, 0.2, 0.1, 0.2, 0.3, 0.2, 0.1, 0.1
])
grid.setMap(density_map)  #set map with no arguement sets the default map
#saveTaglist to .csv file
grid.saveTagList(fname="testField")
############################################### Plotting ############################

#get all tag position to plot
tagx = np.zeros(N)
tagy = np.zeros(N)
예제 #3
0
t = 0
last_meas = t
run = False
running = False
searchComplete = False
updateGP = False
latestMeas = 0

taglist = []
agentList = []
tagx = np.zeros(N)
tagy = np.zeros(N)
for i in range(N):
    # taglist.append(AcousticTag(i,last_ping=np.random.randn()),ping_delay=max(2,30*np.random.randn())) # most realistic
    taglist.append(AcousticTag(
        i, last_ping=17 *
        np.random.randn()))  # more realistic (pings are not aligned in time)
    # taglist.append(AcousticTag(i)) #better for understanding because pings are aligned in time and  all have same ping interval
    x, y, _ = taglist[i].pos
    tagx[i] = x
    tagy[i] = y

E = Grid(taglist, x_range=x_range, y_range=y_range)
if field == fields[0]:
    taglist = E.loadTagList()  # E.setMap(density_map)
    # E.saveTagList()
for i in range(numAgents):
    s = AcousticReciever(np.array([0, 0, 0]), sensorRange)
    if method == searchMethods[2]:
        # agentList.append(Agent(np.array([np.random.rand()*x_range,np.random.rand()*y_range,0,0]),s,E,dim=2))
        agentList.append(
예제 #4
0
N = 1000  #how many tags present
simtime = 100  #max simulation time
numAgents = 1  #number of agents exploring
measurement_time = 1
time_step = .5

running = False
searchComplete = False
taglist = []
agentList = []
tagx = np.zeros(N)
tagy = np.zeros(N)
for i in range(N):
    #taglist.append(AcousticTag(i,last_ping=np.random.randn()),ping_delay=max(2,30*np.random.randn())) # most realistic
    taglist.append(AcousticTag(i, last_ping=np.random.randn())
                   )  # more realistic (pings are not aligned in time)
    #taglist.append(AcousticTag(i)) #better for understanding because pings are aligned in time and  all have same ping interval
    x, y, _ = taglist[i].pos
    tagx[i] = x
    tagy[i] = y

E = Grid(taglist)
E.setMap(density_map)

for i in range(numAgents):
    s = AcousticReciever(np.array([0, 0, 0]), 50)
    agentList.append(Agent(np.array([(i * 2 + 1) * 50.0, 605.0]), s, E, dim=2))
    agentList[i].dynamics = m1_step

for i in range(N):
예제 #5
0
def m1_step(x,u):
        return 1*np.array([np.cos(u), np.sin(u)])
	
	#settings
N = 1000
simtime=3
numAgents=1
time_step=.5
#np.random.seed(1)
     #setup
taglist=[]
agentList=[]
tagx=np.zeros(N)
tagy=np.zeros(N)
for i in range(N):
    taglist.append(AcousticTag(i,last_ping=15*np.random.randn())) # more realistic
    #taglist.append(AcousticTag(i)) #better for understanding
    x,y,_ = taglist[i].pos
    tagx[i]=x
    tagy[i]=y
	
E = Grid(taglist)
E.setMap()

for i in range(numAgents):
    s= AcousticReciever(np.array([0,0,0]),50)
    agentList.append(Agent(np.array([50.0,600.0]),s,E,dim=2))
    agentList[i].dynamics=m1_step
	
for i in range(N):
    x,y,_ = taglist[i].pos
예제 #6
0
                                self.y_range * 1.0 / len(self.y_bins))
                    self.taglist[count].pos = np.array([
                        xr + mpx * np.random.rand(),
                        yr + mpy * np.random.rand(), zr * np.random.rand()
                    ])
                    self.taglist[count].bin = i
                    self.tag_count[i] += 1
                    count += 1


if __name__ == '__main__':
    from AcousticTag import AcousticTag
    taglist = []
    N = 1000
    for i in range(N):
        taglist.append(AcousticTag(i))
    grid = Grid(taglist)
    grid.setMap()
    tau = .5
    # print('tau=',tau)
    # print(np.round(grid.groundTruth(tau),decimals=2))
    # print('method 2 tau=',tau)
    # print(np.round(grid.approximateField(tau,spacing=(200,200),sensorRange=110),decimals=2))
    # #print(np.round(grid.groundTruth(tau,fixed=True),decimals=2))
    # tau=2
    # print('tau=',tau)
    # print(np.round(grid.groundTruth(tau),decimals=2))
    # print('method 2 tau=',tau)
    # print(np.round(grid.approximateField(tau,spacing=(200,200),sensorRange=110),decimals=2))
    # #print(np.round(grid.groundTruth(tau,fixed=True),decimals=2))
    # tau=5