def get(self): ## retrieving GET request parameters ## dimensions nb_col = int(self.request.get("width")) nb_line = int(self.request.get("height")) ## robot parameters robot_start = self.request.get("start").split(',') robot_startx = int(robot_start[0]) robot_starty = int(robot_start[1]) robot_dest = self.request.get("dest").split(',') robot_destx = int(robot_dest[0]) robot_desty = int(robot_dest[1]) robot_direction = self.request.get("direction") def selectDirection(direct): if direct == 'NORTH' : return 'nord' if direct == 'SOUTH': return 'sud' if direct == 'EAST' : return 'est' if direct == 'WEST' : return 'ouest' grid_obstacles = self.request.get("obs").split(' ')[:-1] # the last item is would be a blank so we remove it arr_obs = [] for i in range(len(grid_obstacles)): cur_tuple = grid_obstacles[i][1:-1].split(',') arr_obs.append((int(cur_tuple[0]), int(cur_tuple[1]))) # had to switch the dimensions parameters again so nb_line comes before nb_col warehouse = Warehouse(None, nb_line, nb_col, (robot_startx, robot_starty), (robot_destx, robot_desty), selectDirection(robot_direction), arr_obs) path, dist = warehouse.ShortestPath() if path is False: self.response.out.write('no path found') else: self.response.out.write(warehouse.getShortestPathString())
def get_warehouses(): liste_warehouse = [] id = 0 for i in parse_and_format.read_file()["warehouses"]: position = { "x": int(i["row"]), "y": int(i["column"]) } liste_warehouse.append(Warehouse.Warehouse(position, i["items"], id)) id += 1 return liste_warehouse
delivered = n else: self.currentPayloadWeight -= self.payload[objet] delivered = self.payload[objet] self.payload[objet] = 0 return self.command([1].deliver(objet, n)) def __str__(self): return "Drone , maxPayload : " + str(self.payloadWeight) + "\n" + "payload [" + str(self.payload) + "]\n" + "current weight " + str(self.currentPayloadWeight) if __name__ == "__main__": D = Drone((10, 10), 30, [1, 1, 1, 1]) W = Warehouse.Warehouse((2, 5), {0: 5, 2: 6, 4: 7}) print D print D.goto((24, 34)) print D.gotoWH(W) print D.load(0, 4, W) print D.unload(0, 1, W) D.takeCommand('W', [4]) print D.busy D.step() D.step() D.step() D.step() print D.busy print "BONGEOURRE"
import Product as Pr import Warehouse as Wh import funcs as fn from datetime import datetime as dt storage = Wh.Warehouse() fn.update_log( action= f'----{dt.today().strftime("%d.%m.%Y")}----Database launched.--------') while True: print('\n\t\t********** MAIN MENU **********') com = input('Press 1 to SHOW\n' 'Press 2 to CREATE\n' 'Press 3 to ADD new product\n' 'Press 4 to MOVE\n' 'Press 5 to DO\n' 'Press 6 to EXIT DataBase\n' 'COMMAND: ') try: isinstance(com, int) except ValueError: print('Choose something by pressing similar button!') else: if int(com) == 1: storage.show() elif int(com) == 2: storage.create() elif int(com) == 3: while True: ask = input( 'Press 0 to go back\nPress 1 to go next\nCOMMAND: ')
import matplotlib.pyplot as plt import matplotlib.patches as patches import Warehouse from time import sleep fig,ax = plt.subplots(1) [M,fig,ax] = Warehouse.Warehouse(fig,ax) plt.ion() plt.show() #plt.plot(1,1) for y in range(0,7): #Draw Robot robot = patches.Rectangle((6,y),4,6,linewidth=1,edgecolor='black',facecolor='red') ax.add_patch(robot) plt.pause(0.05) #Clear Robot robot.remove() #Turn Right Row = 12 for x in range(6,50): #Draw Robot robot = patches.Rectangle((x,6),6,4,linewidth=1,edgecolor='black',facecolor='red') ax.add_patch(robot) #Check Matrix M[Row][x] for Box - if Box, scan Bar Code #If no box, continue to move plt.pause(0.05) #Clear Robot robot.remove()
self.canvas.move(self.shelf, (point.x - self.point.x) * self.unit_size, 0) self.canvas.move(self.shelf_id, (point.x - self.point.x) * self.unit_size, 0) next_point = Point(self.point.x + 1, self.point.y) self.point = next_point # Move Up if self.point.x == point.x and self.point.y > point.y: self.canvas.move(self.shelf, 0, (point.y - self.point.y) * self.unit_size) self.canvas.move(self.shelf_id, 0, (point.y - self.point.y) * self.unit_size) next_point = Point(self.point.x, self.point.y - 1) self.point = next_point # Move Down if self.point.x == point.x and self.point.y < point.y: self.canvas.move(self.shelf, 0, (point.y - self.point.y) * self.unit_size) self.canvas.move(self.shelf_id, 0, (point.y - self.point.y) * self.unit_size) next_point = Point(self.point.x, self.point.y + 1) self.point = next_point self.canvas.update() # If the show_animation boolean is True in Warehouse.py, # we will create the Tkinter application and run the Warehouse simulation from here if Warehouse.show_animation: root = tk.Tk() App = Application(master=root) Warehouse.run() App.mainloop()
def readFile(fileName): f = "" with open(fileName) as file: f = file.read() f = f.split("\n") firstLine = f[0] firstLine = firstLine.split(" ") gridx = int(firstLine[0]) gridy = int(firstLine[1]) droneCount = int(firstLine[2]) maxCommands = int(firstLine[3]) maxPayload = int(firstLine[4]) secLine = f[1] productCount = int(secLine) thLine = f[2] thLine = thLine.split(" ") for i in thLine: i = int(i) productWeights = thLine warehouseCount = int(f[3]) newF = f[4:] listofwarehouseobjects = [] for i in xrange(0, warehouseCount): print "loading warehouse: " + str(i) flin = newF[0] flin = flin.split(" ") location = [int(flin[0]), int(flin[1])] flin2 = newF[1] flin2 = flin2.split(" ") wobj = Warehouse.warehouse(location, flin2) listofwarehouseobjects.append(wobj) newF = newF[2:] """print productWeights print "Gridx " + str(gridx) print "Gridy " + str(gridy) print "dronecount " + str(droneCount) print "maxcommands " + str(maxCommands) print "maxpayload " + str(maxPayload) print "product count " + str(productCount) print "warehouseCount " + str(warehouseCount)""" nOrders = newF[0] newF = newF[1:] orderList = [] for i in xrange(0, len(nOrders)): line = newF[0] line = line.split(" ") line[0] = int(line[0]) line[1] = int(line[1]) olocation = line oquan = int(newF[1]) line = newF[2] line = line.split(" ") for j in xrange(0, len(line)): line[j] = int(line[j]) oids = line obj = order.order(i, olocation, oquan, oids) newF = newF[3:] return gridx, gridy, listofwarehouseobjects, droneCount, maxCommands, maxPayload, orderList, productWeights