|
|
@ -15,10 +15,12 @@ import { |
|
|
TaskStatusChangeData, |
|
|
TaskStatusChangeData, |
|
|
TaskTypeChangeData |
|
|
TaskTypeChangeData |
|
|
} from '@/core/manager/amr/AmrMessageDefine' |
|
|
} from '@/core/manager/amr/AmrMessageDefine' |
|
|
import { worldModel } from '@/core/manager/WorldModel' |
|
|
import {worldModel} from '@/core/manager/WorldModel' |
|
|
import Viewport from '@/core/engine/Viewport' |
|
|
import Viewport from '@/core/engine/Viewport' |
|
|
import { Euler } from 'three/src/math/Euler' |
|
|
import {Euler} from 'three/src/math/Euler' |
|
|
import gsap from 'gsap' |
|
|
import gsap from 'gsap' |
|
|
|
|
|
import {MeshWrap} from "@/core/manager/InstanceMeshManager"; |
|
|
|
|
|
import {getRenderer} from "@/core/manager/ModuleManager"; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
type CStepTaskType = 'MOVE' | 'MOVE_BACKWARD' | 'ROTATION' | 'LOAD' | 'UNLOAD' | 'CHARGE' |
|
|
type CStepTaskType = 'MOVE' | 'MOVE_BACKWARD' | 'ROTATION' | 'LOAD' | 'UNLOAD' | 'CHARGE' |
|
|
@ -85,7 +87,7 @@ export default class PtrObject extends THREE.Object3D { |
|
|
private __TaskStatus: CEventId = 0 |
|
|
private __TaskStatus: CEventId = 0 |
|
|
private __PickMode: CPickMode = 0 |
|
|
private __PickMode: CPickMode = 0 |
|
|
|
|
|
|
|
|
private agvStatusVo : AgvStatusVo; |
|
|
private agvStatusVo: AgvStatusVo; |
|
|
|
|
|
|
|
|
get TaskMode(): CTaskMode { |
|
|
get TaskMode(): CTaskMode { |
|
|
return this.__TaskMode |
|
|
return this.__TaskMode |
|
|
@ -172,6 +174,7 @@ export default class PtrObject extends THREE.Object3D { |
|
|
if (!worldModel.state.runState.isVirtual) { |
|
|
if (!worldModel.state.runState.isVirtual) { |
|
|
this.subscribeMessage('/wcs_server/' + this.item.id) |
|
|
this.subscribeMessage('/wcs_server/' + this.item.id) |
|
|
this.subscribeMessage('/agv_robot/status') |
|
|
this.subscribeMessage('/agv_robot/status') |
|
|
|
|
|
this.boot() |
|
|
} |
|
|
} |
|
|
window.agv3 = this |
|
|
window.agv3 = this |
|
|
} |
|
|
} |
|
|
@ -367,7 +370,7 @@ export default class PtrObject extends THREE.Object3D { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
subscribeMessage(topic: string) { |
|
|
subscribeMessage(topic: string) { |
|
|
worldModel.envManager.client.subscribe(topic, { qos: 0 }) |
|
|
worldModel.envManager.client.subscribe(topic, {qos: 0}) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
sendMessage(msg: AmrMsg<any>) { |
|
|
sendMessage(msg: AmrMsg<any>) { |
|
|
@ -390,7 +393,7 @@ export default class PtrObject extends THREE.Object3D { |
|
|
return |
|
|
return |
|
|
} |
|
|
} |
|
|
const content = new AmrMsg20100(this.vehicleId) |
|
|
const content = new AmrMsg20100(this.vehicleId) |
|
|
content.Temperature = { Battery: this.Battery } |
|
|
content.Temperature = {Battery: this.Battery} |
|
|
const m20100 = new AmrMsg<AmrMsg20100>(content) |
|
|
const m20100 = new AmrMsg<AmrMsg20100>(content) |
|
|
worldModel.envManager.client.publish('/agv_robot/status', JSON.stringify(m20100)) |
|
|
worldModel.envManager.client.publish('/agv_robot/status', JSON.stringify(m20100)) |
|
|
} |
|
|
} |
|
|
@ -452,6 +455,16 @@ export default class PtrObject extends THREE.Object3D { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
handle20020Message(data: AmrMsg20020) { |
|
|
|
|
|
const p = Model.getPositionByLogicXY(data.CurLogicX, data.CurLogicY) as THREE.Vector3 |
|
|
|
|
|
this.position.set(p.x, 0, p.z) |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
handle20060Message(data: AmrMsg20060) { |
|
|
|
|
|
const p = Model.getPositionByLogicXY(data.CurLogicX, data.CurLogicY) as THREE.Vector3 |
|
|
|
|
|
this.position.set(p.x, 0, p.z) |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
/*==========真车消息处理============*/ |
|
|
/*==========真车消息处理============*/ |
|
|
|
|
|
|
|
|
// 计算逻辑方向
|
|
|
// 计算逻辑方向
|
|
|
@ -518,7 +531,7 @@ export default class PtrObject extends THREE.Object3D { |
|
|
|
|
|
|
|
|
const linkCount = data.Link?.length || 0 |
|
|
const linkCount = data.Link?.length || 0 |
|
|
if (linkCount > 0) { |
|
|
if (linkCount > 0) { |
|
|
let prevLink = { X: data.StartX, Y: data.StartY, Speed: 1000 } |
|
|
let prevLink = {X: data.StartX, Y: data.StartY, Speed: 1000} |
|
|
for (let i = 0; i < data.Link.length; i++) { |
|
|
for (let i = 0; i < data.Link.length; i++) { |
|
|
const link = data.Link[i] |
|
|
const link = data.Link[i] |
|
|
if ((currentStepTask.X == link.X && currentStepTask.Y == link.Y) |
|
|
if ((currentStepTask.X == link.X && currentStepTask.Y == link.Y) |
|
|
@ -599,10 +612,10 @@ export default class PtrObject extends THREE.Object3D { |
|
|
} else if (data.OperationType == 3 && data.ChargeDirection >= 0 && data.ChargeDirection <= 3) { |
|
|
} else if (data.OperationType == 3 && data.ChargeDirection >= 0 && data.ChargeDirection <= 3) { |
|
|
endDirection = data.ChargeDirection |
|
|
endDirection = data.ChargeDirection |
|
|
} else if (data.OperationType == 4 && data.GoodsSlotDirection >= 0 && data.GoodsSlotDirection <= 3) { |
|
|
} else if (data.OperationType == 4 && data.GoodsSlotDirection >= 0 && data.GoodsSlotDirection <= 3) { |
|
|
if (data.GoodsSlotDirection == 0) { |
|
|
if (data.GoodsSlotDirection == 3) { |
|
|
endDirection = 3 |
|
|
endDirection = 0 |
|
|
} else { |
|
|
} else { |
|
|
endDirection = (data.GoodsSlotDirection - 1) as LogicDirection |
|
|
endDirection = (data.GoodsSlotDirection + 1) as LogicDirection |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@ -611,6 +624,7 @@ export default class PtrObject extends THREE.Object3D { |
|
|
if (endDirection != currentStepTask.EndDirection) { |
|
|
if (endDirection != currentStepTask.EndDirection) { |
|
|
// 如果此处不能转弯,忽略结束方向 等待后续任务
|
|
|
// 如果此处不能转弯,忽略结束方向 等待后续任务
|
|
|
if (!item.dt?.agvRotation || item.dt?.agvRotation?.length <= 0) { |
|
|
if (!item.dt?.agvRotation || item.dt?.agvRotation?.length <= 0) { |
|
|
|
|
|
debugger |
|
|
return |
|
|
return |
|
|
} |
|
|
} |
|
|
const stepTask: StepTask = { |
|
|
const stepTask: StepTask = { |
|
|
@ -677,7 +691,9 @@ export default class PtrObject extends THREE.Object3D { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
executeTask() { |
|
|
executeTask() { |
|
|
|
|
|
if (this.runningStepTaskList.length > 0) { |
|
|
this.TaskMode = 2 |
|
|
this.TaskMode = 2 |
|
|
|
|
|
} |
|
|
while (this.currentStepTaskList.length > 0) { |
|
|
while (this.currentStepTaskList.length > 0) { |
|
|
const stepTask = this.currentStepTaskList[0] |
|
|
const stepTask = this.currentStepTaskList[0] |
|
|
if (this.runningStepTask) { |
|
|
if (this.runningStepTask) { |
|
|
@ -699,20 +715,20 @@ export default class PtrObject extends THREE.Object3D { |
|
|
this.currentStepTaskList.shift() |
|
|
this.currentStepTaskList.shift() |
|
|
this.runningStepTaskList.push(stepTask) |
|
|
this.runningStepTaskList.push(stepTask) |
|
|
if (stepTask.StepTaskType == 'MOVE' || stepTask.StepTaskType == 'MOVE_BACKWARD') { |
|
|
if (stepTask.StepTaskType == 'MOVE' || stepTask.StepTaskType == 'MOVE_BACKWARD') { |
|
|
this.addTravel(stepTask.X, stepTask.Y, stepTask.EndDirection,stepTask.Speed / 1000) |
|
|
this.addTravel(stepTask.X, stepTask.Y, stepTask.EndDirection, stepTask.Speed / 1000) |
|
|
} else if (stepTask.StepTaskType == 'ROTATION') { |
|
|
} else if (stepTask.StepTaskType == 'ROTATION') { |
|
|
this.addRotation(stepTask.EndDirection) |
|
|
this.addRotation(stepTask.EndDirection) |
|
|
} else if (stepTask.StepTaskType == 'LOAD') { |
|
|
} else if (stepTask.StepTaskType == 'LOAD') { |
|
|
this.addLoad(stepTask.GoodsSlotHeight / 1000) |
|
|
this.addLoad(stepTask.GoodsSlotHeight / 1000, this.agvStatusVo.bizLpn) |
|
|
} else if (stepTask.StepTaskType == 'UNLOAD') { |
|
|
} else if (stepTask.StepTaskType == 'UNLOAD') { |
|
|
this.addUnload(stepTask.GoodsSlotHeight / 1000) |
|
|
this.addUnload(stepTask.GoodsSlotHeight / 1000, this.agvStatusVo.bizLpn) |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
onActionCompleted() { |
|
|
onActionCompleted() { |
|
|
setTimeout(()=> { |
|
|
setTimeout(() => { |
|
|
this.runningStepTaskList = [] |
|
|
this.runningStepTaskList = [] |
|
|
this.runningStepTask = null |
|
|
this.runningStepTask = null |
|
|
this.computeLogicXYAndDirection() |
|
|
this.computeLogicXYAndDirection() |
|
|
@ -904,12 +920,21 @@ export default class PtrObject extends THREE.Object3D { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// 取货
|
|
|
// 取货
|
|
|
addLoad(height: number): void { |
|
|
addLoad(height: number, goodsId: string): void { |
|
|
|
|
|
this.actionAnimation = 'wq' |
|
|
|
|
|
console.log('取货') |
|
|
this.PickMode = 1 |
|
|
this.PickMode = 1 |
|
|
this.OperationType = 4 |
|
|
this.OperationType = 4 |
|
|
this.animationUpFork(height).then( |
|
|
this.animationUpFork(height).then( |
|
|
() => this.animationShowFork(1.4).then( |
|
|
() => this.animationShowFork(1.35).then( |
|
|
() => this.animationUpFork(height + 0.2).then( |
|
|
() => { |
|
|
|
|
|
// 将物品拾取到机械臂上
|
|
|
|
|
|
const mesh = this.pickupItem(goodsId) |
|
|
|
|
|
mesh.position.set(0, 0, -0.15) |
|
|
|
|
|
mesh.rotation.set(0, THREE.MathUtils.degToRad(90), 0) |
|
|
|
|
|
this.getArmObject().add(mesh) |
|
|
|
|
|
|
|
|
|
|
|
this.animationUpFork(height + 0.2).then( |
|
|
() => this.animationHideFork().then( |
|
|
() => this.animationHideFork().then( |
|
|
() => this.animationDownFork().then(() => { |
|
|
() => this.animationDownFork().then(() => { |
|
|
this.actionAnimation = null |
|
|
this.actionAnimation = null |
|
|
@ -917,23 +942,32 @@ export default class PtrObject extends THREE.Object3D { |
|
|
}) |
|
|
}) |
|
|
) |
|
|
) |
|
|
) |
|
|
) |
|
|
|
|
|
} |
|
|
) |
|
|
) |
|
|
) |
|
|
) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// 卸货
|
|
|
// 卸货
|
|
|
addUnload(height: number): void { |
|
|
addUnload(height: number, goodsId: string): void { |
|
|
|
|
|
this.actionAnimation = 'wq' |
|
|
|
|
|
console.log('卸货') |
|
|
this.PickMode = 2 |
|
|
this.PickMode = 2 |
|
|
this.OperationType = 4 |
|
|
this.OperationType = 4 |
|
|
this.animationUpFork(height + 0.2).then( |
|
|
this.animationUpFork(height + 0.2).then( |
|
|
() => this.animationShowFork(1.4).then( |
|
|
() => this.animationShowFork(1.35).then( |
|
|
() => this.animationUpFork(height).then( |
|
|
()=>this.animationUpFork(height).then( |
|
|
() => this.animationHideFork().then( |
|
|
() => { |
|
|
|
|
|
const a = this.agvStatusVo.unloadBasLocationVo |
|
|
|
|
|
// 将物品从机械臂上卸下
|
|
|
|
|
|
this.dropItem(goodsId, a.rack, a.bay, a.level, a.cell) |
|
|
|
|
|
|
|
|
|
|
|
this.animationHideFork().then( |
|
|
() => this.animationDownFork().then(() => { |
|
|
() => this.animationDownFork().then(() => { |
|
|
this.actionAnimation = null |
|
|
this.actionAnimation = null |
|
|
this.onActionCompleted() |
|
|
this.onActionCompleted() |
|
|
}) |
|
|
}) |
|
|
) |
|
|
) |
|
|
|
|
|
} |
|
|
) |
|
|
) |
|
|
) |
|
|
) |
|
|
) |
|
|
) |
|
|
@ -955,6 +989,10 @@ export default class PtrObject extends THREE.Object3D { |
|
|
return null |
|
|
return null |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
override getArmObject(): THREE.Object3D | undefined { |
|
|
|
|
|
return null |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
//获取ptr的角度朝向
|
|
|
//获取ptr的角度朝向
|
|
|
getAmrOrientation(radY: number) { |
|
|
getAmrOrientation(radY: number) { |
|
|
while (radY < 0) { |
|
|
while (radY < 0) { |
|
|
@ -967,4 +1005,49 @@ export default class PtrObject extends THREE.Object3D { |
|
|
return THREE.MathUtils.radToDeg(radY) |
|
|
return THREE.MathUtils.radToDeg(radY) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 拾取物品 |
|
|
|
|
|
*/ |
|
|
|
|
|
pickupItem(id: string): THREE.Object3D { |
|
|
|
|
|
// 找到物品所在的地方, 删除他
|
|
|
|
|
|
const item = this.viewport.entityManager.findItemById(id) |
|
|
|
|
|
const wrap = this.viewport.entityManager.findObjectById(id) as MeshWrap |
|
|
|
|
|
|
|
|
|
|
|
if (wrap.type !== 'MeshWrap') { |
|
|
|
|
|
throw new Error(`无法拾取物品 ${id},它不是一个有效的 MeshWrap`) |
|
|
|
|
|
} |
|
|
|
|
|
item.dt.storeAt = { |
|
|
|
|
|
item: this.id + "" |
|
|
|
|
|
} |
|
|
|
|
|
const mesh = wrap.manager.wrapToObject3D(wrap) |
|
|
|
|
|
this.viewport.entityManager.replaceObject(id, mesh) |
|
|
|
|
|
return mesh |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 卸下物品 |
|
|
|
|
|
*/ |
|
|
|
|
|
dropItem(itemId: string, storeItemId: string, bay?: number, level?: number, cell?: number): void { |
|
|
|
|
|
|
|
|
|
|
|
const item = this.viewport.entityManager.findItemById(itemId) |
|
|
|
|
|
|
|
|
|
|
|
item.dt.storeAt = { |
|
|
|
|
|
item: storeItemId, |
|
|
|
|
|
bay: bay, |
|
|
|
|
|
level: level, |
|
|
|
|
|
cell: cell |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const itemRenderer = getRenderer(item.t) |
|
|
|
|
|
if (!itemRenderer) { |
|
|
|
|
|
throw new Error(`Renderer for type ${item.t} not found`) |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
this.getArmObject().clear() |
|
|
|
|
|
|
|
|
|
|
|
itemRenderer.tempViewport = this.viewport |
|
|
|
|
|
itemRenderer.createOrUpdatePointForRuntime(item) |
|
|
|
|
|
itemRenderer.tempViewport = null |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|