item display row
This commit is contained in:
parent
23950ba5b5
commit
b37847b304
@ -141,8 +141,8 @@ class ForkliftAgent(AgentBase):
|
|||||||
[Action(ActionType.DROP_ITEM)]
|
[Action(ActionType.DROP_ITEM)]
|
||||||
)
|
)
|
||||||
|
|
||||||
self.current_item = None
|
|
||||||
self.current_order_delivered_items.append(self.current_item)
|
self.current_order_delivered_items.append(self.current_item)
|
||||||
|
self.current_item = None
|
||||||
self.item_station_completed = False
|
self.item_station_completed = False
|
||||||
|
|
||||||
def step(self) -> None:
|
def step(self) -> None:
|
||||||
|
15
GameModel.py
15
GameModel.py
@ -71,12 +71,12 @@ class GameModel(Model):
|
|||||||
|
|
||||||
self.schedule.add(self.forklift_agent)
|
self.schedule.add(self.forklift_agent)
|
||||||
self.agents.append(self.forklift_agent)
|
self.agents.append(self.forklift_agent)
|
||||||
self.display_agents: List[ItemDisplayAgent] = []
|
self.item_display_agents: List[ItemDisplayAgent] = []
|
||||||
|
|
||||||
# INITIALIZATION #
|
# INITIALIZATION #
|
||||||
print("############## INITIALIZATION ##############")
|
print("############## INITIALIZATION ##############")
|
||||||
self.phase = Phase.INIT
|
self.phase = Phase.INIT
|
||||||
self.initialize_grid(graph)
|
self.initialize_grid(graph, item_display_pos)
|
||||||
self.orderList: List[Order] = InitialStateFactory.generate_order_list(orders)
|
self.orderList: List[Order] = InitialStateFactory.generate_order_list(orders)
|
||||||
self.fulfilled_orders: List[Order] = []
|
self.fulfilled_orders: List[Order] = []
|
||||||
self.forklift_agent.orderList = self.orderList
|
self.forklift_agent.orderList = self.orderList
|
||||||
@ -105,7 +105,7 @@ class GameModel(Model):
|
|||||||
print(actions)
|
print(actions)
|
||||||
self.forklift_agent.queue_movement_actions(actions)
|
self.forklift_agent.queue_movement_actions(actions)
|
||||||
|
|
||||||
def initialize_grid(self, graph: GridWithWeights):
|
def initialize_grid(self, graph: GridWithWeights, item_display_pos):
|
||||||
print("INITIALIZING GRID")
|
print("INITIALIZING GRID")
|
||||||
# Add the agent to a random grid cell
|
# Add the agent to a random grid cell
|
||||||
x = 5
|
x = 5
|
||||||
@ -126,6 +126,7 @@ class GameModel(Model):
|
|||||||
self.place_walls_agents(graph.walls)
|
self.place_walls_agents(graph.walls)
|
||||||
self.place_puddles(graph.puddles)
|
self.place_puddles(graph.puddles)
|
||||||
self.place_packing_stations(graph.packingStations)
|
self.place_packing_stations(graph.packingStations)
|
||||||
|
self.place_order_items_display(item_display_pos)
|
||||||
|
|
||||||
def place_dividers(self):
|
def place_dividers(self):
|
||||||
for i in range(0, 10):
|
for i in range(0, 10):
|
||||||
@ -169,13 +170,19 @@ class GameModel(Model):
|
|||||||
def place_order_items_display(self, item_positions: List[GridLocation]):
|
def place_order_items_display(self, item_positions: List[GridLocation]):
|
||||||
for p in item_positions:
|
for p in item_positions:
|
||||||
agent = ItemDisplayAgent(self, p)
|
agent = ItemDisplayAgent(self, p)
|
||||||
self.display_agents.append(agent)
|
self.item_display_agents.append(agent)
|
||||||
self.grid.place_agent(agent, p)
|
self.grid.place_agent(agent, p)
|
||||||
|
|
||||||
|
def update_item_display(self):
|
||||||
|
for index, item in enumerate(self.forklift_agent.current_order_delivered_items):
|
||||||
|
if item is not None:
|
||||||
|
self.item_display_agents[index].image = item.image
|
||||||
|
|
||||||
def step(self):
|
def step(self):
|
||||||
self.schedule.step()
|
self.schedule.step()
|
||||||
self.grid.remove_agent(self.forklift_agent)
|
self.grid.remove_agent(self.forklift_agent)
|
||||||
self.grid.place_agent(self.forklift_agent, self.forklift_agent.current_position)
|
self.grid.place_agent(self.forklift_agent, self.forklift_agent.current_position)
|
||||||
|
self.update_item_display()
|
||||||
|
|
||||||
if self.phase == Phase.ITEM_RECOGNITION:
|
if self.phase == Phase.ITEM_RECOGNITION:
|
||||||
if not self.item_recognised and self.forklift_agent.current_position == self.drop_off.location:
|
if not self.item_recognised and self.forklift_agent.current_position == self.drop_off.location:
|
||||||
|
@ -5,13 +5,14 @@ from data.Order import Order
|
|||||||
from data.enum.ItemType import ItemType
|
from data.enum.ItemType import ItemType
|
||||||
from data.enum.Priority import Priority
|
from data.enum.Priority import Priority
|
||||||
from util.ClientParamsFactory import ClientParamsFactory
|
from util.ClientParamsFactory import ClientParamsFactory
|
||||||
|
from util.PathByEnum import PathByEnum
|
||||||
|
|
||||||
|
|
||||||
class InitialStateFactory:
|
class InitialStateFactory:
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def generate_item_list(output_list_size: int):
|
def generate_item_list(output_list_size: int):
|
||||||
item_list : [Item] = []
|
item_list: [Item] = []
|
||||||
for i in range(output_list_size):
|
for i in range(output_list_size):
|
||||||
item_list.append(InitialStateFactory.__generate_item())
|
item_list.append(InitialStateFactory.__generate_item())
|
||||||
|
|
||||||
@ -74,7 +75,7 @@ class InitialStateFactory:
|
|||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def generate_input_sequence(self, input_sequence_size):
|
def generate_input_sequence(self, input_sequence_size):
|
||||||
sequence : [Item] = []
|
sequence: [Item] = []
|
||||||
for i in range(0, input_sequence_size):
|
for i in range(0, input_sequence_size):
|
||||||
sequence.append(self.__generate_item())
|
sequence.append(self.__generate_item())
|
||||||
|
|
||||||
@ -83,4 +84,4 @@ class InitialStateFactory:
|
|||||||
@staticmethod
|
@staticmethod
|
||||||
def __generate_item() -> Item:
|
def __generate_item() -> Item:
|
||||||
randomly_picked_type = random.choice(list(ItemType))
|
randomly_picked_type = random.choice(list(ItemType))
|
||||||
return Item(randomly_picked_type)
|
return Item(randomly_picked_type, PathByEnum.get_random_path(randomly_picked_type))
|
||||||
|
@ -6,9 +6,10 @@ from data.enum.ItemType import ItemType
|
|||||||
class Item:
|
class Item:
|
||||||
id_counter = count(start=0)
|
id_counter = count(start=0)
|
||||||
|
|
||||||
def __init__(self, item_type: ItemType):
|
def __init__(self, item_type: ItemType, image):
|
||||||
self.id = next(self.id_counter)
|
self.id = next(self.id_counter)
|
||||||
self.real_type = item_type
|
self.real_type = item_type
|
||||||
|
self.image = image
|
||||||
self.guessed_type = None
|
self.guessed_type = None
|
||||||
|
|
||||||
def __repr__(self) -> str:
|
def __repr__(self) -> str:
|
||||||
|
15
main.py
15
main.py
@ -8,6 +8,7 @@ from tensorflow import keras
|
|||||||
from ForkliftAgent import ForkliftAgent
|
from ForkliftAgent import ForkliftAgent
|
||||||
from GameModel import GameModel
|
from GameModel import GameModel
|
||||||
from InitialStateFactory import InitialStateFactory
|
from InitialStateFactory import InitialStateFactory
|
||||||
|
from ItemDisplayAgent import ItemDisplayAgent
|
||||||
from PatchAgent import PatchAgent
|
from PatchAgent import PatchAgent
|
||||||
from PatchType import PatchType
|
from PatchType import PatchType
|
||||||
from PictureVisualizationAgent import PictureVisualizationAgent
|
from PictureVisualizationAgent import PictureVisualizationAgent
|
||||||
@ -79,6 +80,18 @@ def agent_portrayal(agent):
|
|||||||
if isinstance(agent, PictureVisualizationAgent):
|
if isinstance(agent, PictureVisualizationAgent):
|
||||||
portrayal = {"Shape": f"{agent.img}", "scale": 3.0, "Layer": 0}
|
portrayal = {"Shape": f"{agent.img}", "scale": 3.0, "Layer": 0}
|
||||||
|
|
||||||
|
if isinstance(agent, ItemDisplayAgent):
|
||||||
|
if agent is not None and agent.image is not None:
|
||||||
|
portrayal = {"Shape": f"{agent.image}", "scale": 1.0, "Layer": 0}
|
||||||
|
else:
|
||||||
|
portrayal = \
|
||||||
|
{"Shape": "rect",
|
||||||
|
"Filled": "true",
|
||||||
|
"Layer": 0,
|
||||||
|
"Color": "black",
|
||||||
|
"w": 1,
|
||||||
|
"h": 1}
|
||||||
|
|
||||||
return portrayal
|
return portrayal
|
||||||
|
|
||||||
|
|
||||||
@ -111,7 +124,7 @@ if __name__ == '__main__':
|
|||||||
fulfilled_orders],
|
fulfilled_orders],
|
||||||
"Automatyczny Wózek Widłowy",
|
"Automatyczny Wózek Widłowy",
|
||||||
dict(width=gridHeight, height=gridWidth, graph=diagram, items=50, orders=3,
|
dict(width=gridHeight, height=gridWidth, graph=diagram, items=50, orders=3,
|
||||||
classificator=model,item_display_pos=display_items))
|
classificator=model, item_display_pos=display_items))
|
||||||
|
|
||||||
server.port = 8888
|
server.port = 8888
|
||||||
server.launch()
|
server.launch()
|
||||||
|
Loading…
Reference in New Issue
Block a user