Commit 9930df8b authored by Allvey's avatar Allvey

空车智能增加二次调度及穿越装载区功能

parent 3a116ab7
{
"para": {
"log_path": "/Users/guoao/Desktop/Log",
"log_path": "./Logs/dispatch.log",
"empty_speed": 18,
"heavy_speed": 18,
"dump_target_mass": 5000,
......@@ -26,6 +26,10 @@
"host": "172.16.0.53",
"password": "Huituo@123"
},
"gothrough": {
"closer_area_name": "哈装测试",
"further_area_name": "哈装2"
},
"geom": {
"redispatch_minimal_distance": 40
}
......
......@@ -514,39 +514,113 @@ class GroupDispatcher:
self.logger.info(f'调度结果 next_excavator_id: '
f'{next_excavator_id} next_unload_area_id: {next_unload_area_id}')
def semi_dynamic_mode(self, i, s, truck_dispatch, truck_info):
# TODO:和全智能调度很像,是否可以合并合;
def semi_dynamic_mode(self, truck_id, s, truck_dispatch, truck_info):
truck_trip = truck_info.get_trip()
truck_name = truck_info.get_name()
# 获取车辆任务信息
try:
truck_task = truck_info.get_task()
if truck_task is None:
raise Exception(f'车辆 {truck_name} 任务信息丢失')
except Exception as es:
self.logger.error(es)
return
truck_trip = truck_info.get_trip()
# 获取车辆位置信息
try:
truck_locate = self.group.truck.truck_lane_locate_dict[truck_id]
# 加入二次调度;
except Exception as es:
self.logger.warning(f'车辆 {truck_name} 位置信息丢失')
truck_locate = None
# 车辆当前 1)位于备停区; 2)位于卸载区; 3)车辆重载行驶, 调度车辆前往装载区
if truck_task in [-2, 3, 4, 5]:
if truck_task == 3:
self.logger.info("正常重载行驶, 执行重载周期调度, 调度车辆前往挖机")
elif truck_task == -2:
self.logger.info("备停区内, 执行重载周期调度, 调度车辆前往挖机")
else:
self.logger.info("卸载区内, 执行重载周期调度, 调度车辆前往挖机")
self.heavy_period_dispatch(s, truck_dispatch, truck_id, truck_info, truck_task, truck_trip)
# 车辆当前 1)位于装载区; 2)车辆空载行驶, 调度车辆前往卸载区
elif truck_task in [0, 1, 2]:
planned = False
self.logger.info(f'车辆 {truck_name}')
self.logger.info(f'车辆位置 {truck_locate}')
self.logger.info(f'车辆任务状态 {truck_info.get_sate()}')
if truck_task == 0:
# 判断是否开启穿越装载区调度
if self.gothrough_active and truck_locate is not None:
self.logger.info("穿越装载区调度开启")
# 更新判定路段区域
self.gothroghdispatcher.update_lanes_info()
try:
# 获取近端装载区入场点经纬度信息
excavator_prise_location = get_excavator_prise_location(self.gothroghdispatcher.closer_excavator_id)
# 获取车辆经纬度信息
truck_prise_location = self.group.truck.truck_current_prise_location[truck_id]
except Exception as es:
self.logger.error("挖机或车辆经纬信息未知")
self.logger.error(es)
excavator_prise_location = [-1, -1]
truck_prise_location = [-1, -1]
if i in self.group.truck.truck_excavator_bind:
next_excavator_id = self.group.truck.truck_excavator_bind[i]
else:
next_excavator_value = s.solve(truck_info)
# min_index = next_excavator_list.index(min(next_excavator_list))
self.logger.info(f'车辆排斥修正 {i}, {self.group.truck_excavator_exclude_modify[i]}')
min_index = np.argmin(next_excavator_value + self.group.truck_excavator_exclude_modify[i])
next_excavator_id = self.group.excavator_uuid_index_dict.inverse[min_index]
if truck_task == -2:
next_unload_area_id = "Park"
else:
# next_unload_area_id = self.unload_area_uuid_index_dict.inverse[truck_trip[-1]]
dump_id = get_value("dump_index_to_uuid_dict")[truck_trip[-1]]
next_unload_area_id = get_value("dump_uuid_to_unload_area_uuid_dict")[dump_id]
truck_dispatch[i] = [next_excavator_id, next_unload_area_id]
self.logger.info(f'挖机经纬度信息 {excavator_prise_location}')
self.logger.info(f'车辆经纬度信息 {truck_prise_location}')
from haversine import haversine
truck_to_entrance_point_dis = haversine(excavator_prise_location, truck_prise_location)
self.logger.info(f'车辆到近端装载区入场点距离 {truck_to_entrance_point_dis}')
# 若车辆到入场点距离大于指定阈值
if excavator_prise_location[0] != -1 and \
truck_prise_location[0] != -1 and \
haversine(excavator_prise_location, truck_prise_location) > 0.001 and \
truck_locate in self.gothroghdispatcher.closer_area_backtrack_lanes[0:2]:
try:
self.logger.info("触发穿越装载区调度")
planned = self.gothroghdispatcher.redispatch_request(request_truck_id=truck_id,
truck=self.group.truck, truck_dispatch=truck_dispatch, truck_info=truck_info)
self.logger.info(f'穿越装载区调度成功? {planned}')
except Exception as es:
self.logger.error("穿越调度失败")
self.logger.error(es)
# 未触发穿越装载区调度, 判断是否开启二次调度
if not planned and self.group.topo is not None and truck_locate is not None:
self.logger.info("二次调度开启")
# 车辆当前位于交叉路口前,且排队等待
self.logger.info("交叉口前路段id列表")
self.logger.info(self.group.topo.cross_bf_lanes)
self.logger.info(truck_info.get_sate())
if truck_locate in self.group.topo.cross_bf_lanes:
self.logger.info("触发二次调度")
try:
truck_info.redispatch =\
self.redispatcher.redispatch_to_excavator(truck_id, truck_dispatch, truck_locate,
truck_trip, truck_info)
planned = True
except Exception as es:
self.logger.error("重载车辆空车智能模式-计算异常")
self.logger.error("二次调度至装载点失败")
self.logger.error(es)
if truck_task in [0, 1, 2]:
planned = False
# 穿越调度和二次调度均不触发,正常空载调度
if not planned or truck_task != 0:
try:
truck_dispatch[i] = DispatchInfo.get_truck_match(i)
truck_dispatch[truck_id] = DispatchInfo.get_truck_match(truck_id)
except Exception as es:
self.logger.error("空载车辆空车智能模式-计算异常")
self.logger.error(es)
......
......@@ -3,6 +3,6 @@ ps -ef|grep realtime_dispatch.py|grep -v grep |awk {'print $2'} |xargs kill -9
sleep 2
python3 topo_update_server.py
sleep 2
nohup python3 realtime_dispatch.py >/dev/null 2>&1 &
sudo nohup python3 realtime_dispatch.py --active >/dev/null 2>&1 &
sleep 2
nohup flask run --host=0.0.0.0 >/dev/null 2>&1 &
\ No newline at end of file
#!E:\Pycharm Projects\Waytous
# -*- coding: utf-8 -*-
# @Time : 2025/6/24 15:43
# @Author : Opfer
# @Site :
# @File : versiontag.py.py
# @Software: PyCharm
VERSION_TAG = '78'
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment