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. 32
      src/modules/amr/ptr/PtrObject.ts

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

@ -516,6 +516,7 @@ export {
AmrMsg10060, AmrMsg10060,
AmrMsg10110, AmrMsg10110,
AmrMsg10120, AmrMsg10120,
AmrMsg20000Base,
AmrMsg20010, AmrMsg20010,
AmrMsg20011, AmrMsg20011,
AmrMsg20012, 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 Cl23dObject from '@/modules/amr/ptr/cl2/Cl23dObject'
import Viewport from '@/core/engine/Viewport' import Viewport from '@/core/engine/Viewport'
@ -62,7 +62,18 @@ export default class AmrMessageManager {
} }
} }
handleStatusMessage(topic, amrMsg: AmrMsg<any>) { handleStatusMessage(topic, amrMsg: AmrMsg<AmrMsg20000Base>) {
// switch () 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 // props
const props = withDefaults(defineProps(), {}); const props = withDefaults(defineProps(), {});
function start() { function startMonitor() {
const viewport: Viewport = window['viewport'] const viewport: Viewport = window['viewport']
// viewport.envManager.client.publish('/agv_robot/status', '') // viewport.envManager.client.publish('/agv_robot/status', '')
const item = viewport.state.selectedItem const item = viewport.state.selectedItem
const ptrObject: PtrObject = viewport.state.selectedObject as PtrObject 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() { function stop() {
@ -35,7 +43,8 @@ function stop() {
<template> <template>
<div class="ptr-controller"> <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> <el-button @click="stop">关闭</el-button>
</div> </div>
</template> </template>

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

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

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

Loading…
Cancel
Save