本文整理汇总了Python中location.Location.setXY方法的典型用法代码示例。如果您正苦于以下问题:Python Location.setXY方法的具体用法?Python Location.setXY怎么用?Python Location.setXY使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类location.Location
的用法示例。
在下文中一共展示了Location.setXY方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: updateGrids
# 需要导入模块: from location import Location [as 别名]
# 或者: from location.Location import setXY [as 别名]
def updateGrids(self, ca1grids, ca1hd, b_odom, N_mazeSize, dictGrids):
loc=Location()
loc.setGrids(ca1grids, dictGrids)
(x_hat_prev, y_hat_prev) = loc.getXY()
## Hard coded again here North negative.....
dxys = [[1,0],[0,1],[-1,0],[0,-1]] #by hd cell
ihd = argmax(ca1hd)
odom_dir = dxys[ihd]
odom = [0,0]
if b_odom:
odom=odom_dir
x_hat_now = x_hat_prev + odom[0]
y_hat_now = y_hat_prev + odom[1]
##SMART UPDATE -- if odom took us outside the maze, then ignore it
#pdb.set_trace()
##if this takes me to somewhere not having a '3'(=N_mazeSize) in the coordinate, then the move was illegal?
if sum( (x_hat_now==N_mazeSize) + (y_hat_now==N_mazeSize))==0:
print "OFFMAZE FIX: OLD:" ,x_hat_now, y_hat_now
x_hat_now = x_hat_prev
y_hat_now = y_hat_prev
print "NEW:",x_hat_now, y_hat_now
x_hat_now = crop(x_hat_now, 0, 2*N_mazeSize)
y_hat_now = crop(y_hat_now, 0, 2*N_mazeSize) #restrict to locations in the maze
loc=Location()
loc.setXY(x_hat_now, y_hat_now)
#self.placeCells=zeros(ca1placeCells.shape)
#self.placeCells[loc.placeId] = 1
self.grids = loc.getGrids().copy()
示例2: __init__
# 需要导入模块: from location import Location [as 别名]
# 或者: from location.Location import setXY [as 别名]
def __init__(self,N_mazeSize, x,y, ith, SURFdict):
#self.placeCells = np.zeros((1+4*N_mazeSize))
loc=Location()
loc.setXY(x,y)
#placeId = loc.placeId
#self.placeCells[placeId] = 1
self.grids = loc.getGrids().copy()
self.hd = np.array([0,0,0,0])
self.hd[ith]=1
self.rgb=np.array([0,0,0]) #assume a red poster in the east and a green poster in the north
if ith==0: #NB these differ from head direction cells, as HD odometry can go wrong!
self.rgb[0]=1
if ith==1:
self.rgb[1]=1
if SURFdict is not None:
#HOOK ALAN - include SURF features in the senses of the dictionary
#Problem with merging here is you can only have one image per direction?
self.surfs=findSurfs(x,y,ith,SURFdict)
else:
self.surfs=np.array([])
#print("Surf feature for %d,%d,%d:\n%s" % (x,y,ith,self.surfs))
#x,y relate to surf features in SURFdict
self.whiskers=np.array([0,0,0]) #to be filled in outside
示例3: makeMaze
# 需要导入模块: from location import Location [as 别名]
# 或者: from location.Location import setXY [as 别名]
def makeMaze(b_useNewDG=False, prefixFolder = None):
# Set up maze data loader
maze_data=maze_from_data(prefixFolder)
# Load data from folder
maze_data.index_image_files()
# Display maze - TESTING
#maze_data.display_maps_images()
#maze_data.maze_interactive()
# maze_data.maze_walk()
# Run SURF features....
surfDict=None
surfDict = makeSURFRepresentation(prefixFolder,False)
print('SURF Completed')
## Store all sensory inputs in here, head direction, image surfs, whiskers
dictSenses=dict()
dictAvailableActions=dict()
dictNext=dict()
# Calculate NMax as grid cell encoding...
# Setup as a 2xn grid, therfore need to encode for complete grid sapce, ie if x=4,y=5 grid x*y=20
# Max size of peak2peak of x and y, log2 and maximum size.....
Nmax=int(np.ceil(np.log2(np.amax([maze_data.place_cell_id[1].ptp(),maze_data.place_cell_id[2].ptp()]))))
# Setup location class with nMax
loc=Location(Nmax)
# Step for each move around Maze
maze_step_size=1
# Calc step depending on direction...... PROBELMS HERE WITH LUKE AND CF MAZES!!!!
# Luke x = East is Positive, y = North = positive
# 'N' x=0, y=+ /'E' x=+, y=0 / 'S' x=0, y=- / 'W' x=-, y=0
# step_index=np.array([[0,maze_step_size],[maze_step_size,0],[0,-maze_step_size],[-maze_step_size,0]])
# print 'WARNING RUNNING IN Luke MODE..... North positive!'
# CF x = East is Positive y = South = Positive
# 'N' x=0, y=- / 'E' x=-, y=0 / 'S' x=0, y=+ / 'W' x=+, y=0
print 'WARNING RUNNING IN CHARLES FOX MODE..... North negative!'
step_index=np.array([[0,-maze_step_size],[maze_step_size,0],[0,maze_step_size],[-maze_step_size,0]])
# Loop through all locations.... N,E,S,W
for current_id in range(0,maze_data.place_cell_id[0,:].size):
# maze_data.find_next_set_images(0,26,1)
current_x=maze_data.place_cell_id[1,current_id]
current_y=maze_data.place_cell_id[2,current_id]
print('Place cell ID:',str(current_id),' x:',str(current_x),' y:',str(current_y))
## Fn find_next_set_images
## returns: (images_to_combine,image_found,heading,direction_vector,picture_name,available_direction_vector)
## available_direction_vector = [forwards, backwards, left, right]
# Get only those headings available....
included_headings=np.where(maze_data.locations_unique[(current_x,current_y)]['Image_count']>0)
for current_direction in included_headings[0]: # N=0,E=1,S=2,W=3
#direction = directionDict[current_direction]
# SURF HAS A DIFFERENT BLOODY DICTIONARY Key!!!!
#current_surf_location=((current_x,current_y),direction)
current_location=(current_x,current_y,current_direction)
_,image_found,_,_,_,available_direction_vector=maze_data.find_next_set_images(current_x,current_y,current_direction)
if image_found:
# Sense dictionary
dictSenses[current_location]=Senses()
dictSenses[current_location].hd[current_direction]=1 # REVERSE and REMOVE BACKWARDS
dictSenses[current_location].whiskers=np.square(available_direction_vector[[2,0,3]]-1) # LEFT / FORWARDS / RIGHT
dictSenses[current_location].rgb=np.array([0,0,0]) # Not set at the moment
try:
dictSenses[current_location].surfs=findSurfs(current_x,current_y,current_direction,surfDict)
except:
pass
##dictSenses[current_location].grids=1#SORT GRIDS
loc.setXY(current_x,current_y)
dictSenses[current_location].grids = loc.getGrids().copy()
# Which ways can you go....
# Take from available action vector [FWD=1, REVERSE(UTURN)=4, LEFT=2, RIGHT=3]
#TODO: MAY need to spin this round - Charles fox different systems
dictAvailableActions[current_location] = np.concatenate(([0],np.array([1,4,2,3])[np.where(available_direction_vector>0)]))#[STAY,FWD,LEFT,RIGHT]
# What is available next
#WTF!!!! dictNext[current_location] = [(x,y,direction), (x+step_xs[direction],y+step_ys[direction],direction), (x,y,direction_l), (x,y,direction_r)]
# Stay in the same place!!!!
# = 0
#dictNext[current_location] = [current_location]
next_locations=(current_x,current_y,current_direction)
# Calc step depending on direction...... x, y
current_stepping=step_index[current_direction]
# Forward
if 1 in dictAvailableActions[current_location]:
#dictNext[current_location].append([(current_x+current_stepping[0],current_y+current_stepping[1]),current_direction])
next_locations=next_locations+(current_x+current_stepping[0],current_y+current_stepping[1],current_direction)
# Left
if 2 in dictAvailableActions[current_location]:
new_heading,_=maze_data.phase_wrap_heading(current_direction-1)
#dictNext[current_location].append([(current_x,current_y),directionDict[new_heading]])
#.........这里部分代码省略.........