2 Star 0 Fork 0

沃沃/机器人调度

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
order9.py 5.74 KB
一键复制 编辑 原始数据 按行查看 历史
沃沃 提交于 2023-04-04 16:08 . first commit
import sys
import math
from data import whichmap
import order9
sell1=[]
sell2=[]
sell3=[]
sell4=['1', '2']
sell5=['1', '3']
sell6=['2', '3']
sell7=['4', '5', '6']
sell8=['7']
sell9=['1', '2', '3', '4', '5', '6', '7']
# only9机器人指令类
class Order9():
def __init__(self, frame_id, WB, WB_indexnumber, robot, stat, WBlist, needlist, distance_dic, distance_roboteachother, \
distance_9to456, distance_7to456, free_set, WB_lock, WB_distribution_stat, dic_countneed, exist):
self.frame_id = frame_id
self.stat = stat
self.WBlist = WBlist
self.WB = WB
self.WB_indexnumber = WB_indexnumber
self.robot = robot
self.needlist = needlist
self.distance_dic = distance_dic
self.distance_roboteachother = distance_roboteachother
self.distance_9to456 = distance_9to456
self.distance_7to456 = distance_7to456
self.robot_stat = free_set
self.WB_lock = WB_lock
self.WB_distribution_stat = WB_distribution_stat
self.dic_countneed = dic_countneed
self.exist = exist
self.exist456 = self.exist[3:6]
self.exist123 = self.exist[0:3]
def changeNeedlist_only9(self):
for i in range(4):
if self.robot[str(i)][1] == '0':
if self.robot[str(i)][1] == '1' or self.robot[str(i)][1] == '2' or self.robot[str(i)][1] == '3':
for k, v in self.WB.items():
if k == self.robot_stat[i]:
self.needlist[int(v[0])-1] -= 1
# if stat == only9
def goto9_goods4(self, robot_id):
for i in range(self.WBlist[8]): # 所有9号工作台无脑送
if '9_'+str(i) not in self.ls_alive:
continue
self.robot_start[robot_id] = self.laststat[robot_id]
self.robot_stat[robot_id] = '9_'+str(i)
self.laststat[robot_id] = self.robot_stat[robot_id]
break
def goto9_goods5(self, robot_id):
for i in range(self.WBlist[8]): # 所有9号工作台无脑送
if '9_'+str(i) not in self.ls_alive:
continue
self.robot_start[robot_id] = self.laststat[robot_id]
self.robot_stat[robot_id] = '9_'+str(i)
self.laststat[robot_id] = self.robot_stat[robot_id]
break
def goto9_goods6(self, robot_id):
for i in range(self.WBlist[8]): # 所有9号工作台无脑送
if '9_'+str(i) not in self.ls_alive:
continue
self.robot_start[robot_id] = self.laststat[robot_id]
self.robot_stat[robot_id] = '9_'+str(i)
self.laststat[robot_id] = self.robot_stat[robot_id]
break
#############################################################################
################# if stat == only9 分配规则和9的距离优先 #####################
#############################################################################
# 如果只有1个9,默认是self.distance_9to456[0]
# 456无脑送给9
def goto9_goods4_last(self, robot_id):
for i in range(self.WBlist[8]):
aim = '9_'+str(i)
break
return aim
def goto9_goods5_last(self, robot_id):
for i in range(self.WBlist[8]):
aim = '9_'+str(i)
break
return aim
def goto9_goods6_last(self, robot_id):
for i in range(self.WBlist[8]):
aim = '9_'+str(i)
break
return aim
def test6_only9(self):
# 若有任一6号生产完,派一个空闲机器人过去
for i in range(self.WBlist[5]):
if self.WB['6_'+str(i)][5] == '1' and self.WB['6_'+str(i)][4] == '12' and self.WB['6_'+str(i)][3] == '0' and self.WB_lock['6_'+str(i)][2] == 'OK':
for j in range(4):
if self.robot_stat[j] == 'free' and self.robot[str(j)][1] == '0':
self.robot_stat[j] = '6_'+str(i)
self.WB_lock['6_'+str(i)][2] = 'NO'
break
for i in range(self.WBlist[5]):
if self.frame_id > 8500 and self.frame_id < 8700 and (self.WB['6_'+str(i)][5] == '1' or (int(self.WB['6_'+str(i)][3]) < 200 and int(self.WB['6_'+str(i)][3]) > 0)) and self.WB_lock['6_'+str(i)][2] == 'OK':
for j in range(4):
if self.robot_stat[j] == 'free' and self.needlist[5] > 0 and self.robot[str(j)][1] == '0':
self.robot_stat[j] = '6_'+str(i)
self.WB_lock['6_'+str(i)][2] = 'NO'
self.needlist[5] -= 1
break
def test5_only9(self):
# 若有任一5号生产完,派一个机器人过去
for i in range(self.WBlist[4]):
if self.WB['5_'+str(i)][5] == '1' and self.WB['5_'+str(i)][4] == '10' and self.WB['5_'+str(i)][3] == '0' and self.WB_lock['5_'+str(i)][2] == 'OK':
for j in range(4):
if self.robot_stat[j] == 'free' and self.robot[str(j)][1] == '0':
self.robot_stat[j] = '5_'+str(i)
self.WB_lock['5_'+str(i)][2] = 'NO'
break
def test4_only9(self):
# 若有任一4号生产完,派一个机器人过去
for i in range(self.WBlist[3]):
if self.WB['4_'+str(i)][5] == '1' and self.WB['4_'+str(i)][4] == '6' and self.WB['4_'+str(i)][3] == '0' and self.WB_lock['4_'+str(i)][2] == 'OK':
for j in range(4):
if self.robot_stat[j] == 'free' and self.robot[str(j)][1] == '0':
self.robot_stat[j] = '4_'+str(i)
self.WB_lock['4_'+str(i)][2] = 'NO'
break
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/pengyi_lin07/robot-scheduling.git
git@gitee.com:pengyi_lin07/robot-scheduling.git
pengyi_lin07
robot-scheduling
机器人调度
master

搜索帮助