Browse Source

cl2 基于设备状态和任务状态分步生成设备任务消息

master
yuliang 5 months ago
parent
commit
361f5bea6b
  1. 1
      src/core/manager/amr/AmrMessageDefine.ts
  2. 17
      src/core/manager/amr/AmrMessageManager.ts
  3. 15
      src/editor/propEditors/PtrController.vue
  4. 4
      src/editor/widgets/monitor/MonitorView.vue
  5. 64
      src/modules/amr/ptr/PtrObject.ts

1
src/core/manager/amr/AmrMessageDefine.ts

@ -516,6 +516,7 @@ export {
AmrMsg10060,
AmrMsg10110,
AmrMsg10120,
AmrMsg20000Base,
AmrMsg20010,
AmrMsg20011,
AmrMsg20012,

17
src/core/manager/amr/AmrMessageManager.ts

@ -1,4 +1,4 @@
import { AmrMsg, AmrMsg10010, AmrMsg10050, AmrMsg10060, AmrMsg10110, AmrMsg10120, AmrMsg20050 } from '@/core/manager/amr/AmrMessageDefine'
import {AmrMsg, AmrMsg10010, AmrMsg10050, AmrMsg10060, AmrMsg10110, AmrMsg10120, AmrMsg20000Base, AmrMsg20020, AmrMsg20060} from '@/core/manager/amr/AmrMessageDefine'
import Cl23dObject from '@/modules/amr/ptr/cl2/Cl23dObject'
import Viewport from '@/core/engine/Viewport'
@ -62,7 +62,18 @@ export default class AmrMessageManager {
}
}
handleStatusMessage(topic, amrMsg: AmrMsg<any>) {
// switch ()
handleStatusMessage(topic, amrMsg: AmrMsg<AmrMsg20000Base>) {
const vehicleId = amrMsg.content.VehicleId
const amrItem = this.viewport.entityManager.findObjectById(vehicleId + '') as Cl23dObject
switch (amrMsg.id) {
case 20020:
amrItem.handle20020Message(amrMsg.content as AmrMsg20020)
break
case 20060:
amrItem.handle20060Message(amrMsg.content as AmrMsg20060)
break
default:
break
}
}
}

15
src/editor/propEditors/PtrController.vue

@ -14,12 +14,20 @@ defineOptions({
// props
const props = withDefaults(defineProps(), {});
function start() {
function startMonitor() {
const viewport: Viewport = window['viewport']
// viewport.envManager.client.publish('/agv_robot/status', '')
const item = viewport.state.selectedItem
const ptrObject: PtrObject = viewport.state.selectedObject as PtrObject
ptrObject.boot()
ptrObject.bootForMonitor()
}
function startShow() {
const viewport: Viewport = window['viewport']
// viewport.envManager.client.publish('/agv_robot/status', '')
const item = viewport.state.selectedItem
const ptrObject: PtrObject = viewport.state.selectedObject as PtrObject
ptrObject.bootForShow()
}
function stop() {
@ -35,7 +43,8 @@ function stop() {
<template>
<div class="ptr-controller">
<el-button @click="start">启动</el-button>
<el-button @click="startMonitor">启动模拟</el-button>
<el-button @click="startShow">启动演示</el-button>
<el-button @click="stop">关闭</el-button>
</div>
</template>

4
src/editor/widgets/monitor/MonitorView.vue

@ -104,8 +104,8 @@ export default {
continue
}
const view3DObject = Model.find3D(deviceInfo.id)
if (typeof view3DObject.boot === 'function') {
view3DObject.boot()
if (typeof view3DObject.bootForMonitor === 'function') {
view3DObject.bootForMonitor()
}
}
},

64
src/modules/amr/ptr/PtrObject.ts

@ -172,9 +172,7 @@ export default class PtrObject extends THREE.Object3D {
this.viewport.addFrameTimerCallback(this.item.id, this.onFrameTimer.bind(this))
if (!worldModel.state.runState.isVirtual) {
this.subscribeMessage('/wcs_server/' + this.item.id)
this.subscribeMessage('/agv_robot/status')
this.boot()
this.bootForShow()
}
window.agv3 = this
}
@ -219,10 +217,19 @@ export default class PtrObject extends THREE.Object3D {
const rbInfo = new this.viewport.ammoModel.btRigidBodyConstructionInfo(mass, boxMotionState, boxShape, localInertia)
this.boxBody = new this.viewport.ammoModel.btRigidBody(rbInfo)
this.viewport.physicsWorld.addRigidBody(this.boxBody)
}
if (!worldModel.state.runState.isVirtual) {
return
}
bootForShow() {
this.boot()
this.subscribeMessage('/wcs_server/' + this.item.id)
this.subscribeMessage('/agv_robot/status')
}
bootForMonitor() {
this.boot()
this.subscribeMessage('/wcs_server/' + this.vehicleId)
this.send20147()
setTimeout(() => {
@ -565,22 +572,25 @@ export default class PtrObject extends THREE.Object3D {
}
if (endDirection != currentStepTask.EndDirection) {
const stepTask: StepTask = {
SeqNo: data.SeqNo,
StepTaskType: 'ROTATION',
OperationType: 0,
PickMode: 0,
X: prevLink.X,
Y: prevLink.Y,
Speed: prevLink.Speed,
EndDirection: endDirection,
ChargeLocation: data.ChargeLocation,
GoodsSlotHeight: data.GoodsSlotHeight,
position: Model.getPositionByLogicXY(prevLink.X, prevLink.Y) as THREE.Vector3,
isCompleted: false
const item = this.viewport.entityManager.findItemByLogicXY(prevLink.X, prevLink.Y)
if (item.dt?.agvRotation && item.dt?.agvRotation?.length > 0) {
const stepTask: StepTask = {
SeqNo: data.SeqNo,
StepTaskType: 'ROTATION',
OperationType: 0,
PickMode: 0,
X: prevLink.X,
Y: prevLink.Y,
Speed: prevLink.Speed,
EndDirection: endDirection,
ChargeLocation: data.ChargeLocation,
GoodsSlotHeight: data.GoodsSlotHeight,
position: Model.getPositionByLogicXY(prevLink.X, prevLink.Y) as THREE.Vector3,
isCompleted: false
}
currentStepTask = stepTask
this.currentStepTaskList.push(stepTask)
}
currentStepTask = stepTask
this.currentStepTaskList.push(stepTask)
}
const stepTask: StepTask = {
@ -704,7 +714,7 @@ export default class PtrObject extends THREE.Object3D {
this.runningStepTask = stepTask
this.currentStepTaskList.shift()
this.runningStepTaskList.push(stepTask)
console.log('移动')
this.addTravel(stepTask.X, stepTask.Y, stepTask.EndDirection, stepTask.Speed / 1000)
} else {
@ -715,12 +725,16 @@ export default class PtrObject extends THREE.Object3D {
this.currentStepTaskList.shift()
this.runningStepTaskList.push(stepTask)
if (stepTask.StepTaskType == 'MOVE' || stepTask.StepTaskType == 'MOVE_BACKWARD') {
console.log('移动')
this.addTravel(stepTask.X, stepTask.Y, stepTask.EndDirection, stepTask.Speed / 1000)
} else if (stepTask.StepTaskType == 'ROTATION') {
console.log('转动')
this.addRotation(stepTask.EndDirection)
} else if (stepTask.StepTaskType == 'LOAD') {
console.log('取货')
this.addLoad(stepTask.GoodsSlotHeight / 1000, this.agvStatusVo.bizLpn)
} else if (stepTask.StepTaskType == 'UNLOAD') {
console.log('放货')
this.addUnload(stepTask.GoodsSlotHeight / 1000, this.agvStatusVo.bizLpn)
}
}
@ -747,6 +761,9 @@ export default class PtrObject extends THREE.Object3D {
// 转
addRotation(direction: number): Promise<void> {
this.OperationType = 0
this.PickMode = 0
this.TaskMode = 2
let rad = 0
switch (direction) {
case 1:
@ -794,6 +811,7 @@ export default class PtrObject extends THREE.Object3D {
this.OperationType = 0
this.PickMode = 0
this.TaskMode = 2
const pos = Model.getPositionByLogicXY(logicX, logicY)
this.__toPos = pos as THREE.Vector3
//加速度
@ -923,6 +941,7 @@ export default class PtrObject extends THREE.Object3D {
addLoad(height: number, goodsId: string): void {
this.actionAnimation = 'wq'
console.log('取货')
this.TaskMode = 2
this.PickMode = 1
this.OperationType = 4
this.animationUpFork(height).then(
@ -951,6 +970,7 @@ export default class PtrObject extends THREE.Object3D {
addUnload(height: number, goodsId: string): void {
this.actionAnimation = 'wq'
console.log('卸货')
this.TaskMode = 2
this.PickMode = 2
this.OperationType = 4
this.animationUpFork(height + 0.2).then(

Loading…
Cancel
Save