|
|
@ -15,13 +15,13 @@ 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 { MeshWrap } from '@/core/manager/InstanceMeshManager' |
|
|
import {getRenderer} from "@/core/manager/ModuleManager"; |
|
|
import { getRenderer } from '@/core/manager/ModuleManager' |
|
|
import {MathUtils} from "three"; |
|
|
import { MathUtils } from 'three' |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
type CStepTaskType = 'MOVE' | 'MOVE_BACKWARD' | 'ROTATION' | 'LOAD' | 'UNLOAD' | 'CHARGE' |
|
|
type CStepTaskType = 'MOVE' | 'MOVE_BACKWARD' | 'ROTATION' | 'LOAD' | 'UNLOAD' | 'CHARGE' |
|
|
@ -88,7 +88,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 |
|
|
|
|
|
|
|
|
// 是否模拟设备
|
|
|
// 是否模拟设备
|
|
|
private isMonitoring: boolean = false |
|
|
private isMonitoring: boolean = false |
|
|
@ -172,9 +172,9 @@ export default class PtrObject extends THREE.Object3D { |
|
|
super() |
|
|
super() |
|
|
this.viewport = viewport |
|
|
this.viewport = viewport |
|
|
this.item = item |
|
|
this.item = item |
|
|
this.vehicleId = parseInt(item.id) |
|
|
this.vehicleId = parseInt(item.dt.vehicleId) |
|
|
|
|
|
|
|
|
this.viewport.addFrameTimerCallback(this.item.id, this.onFrameTimer.bind(this)) |
|
|
this.viewport.addFrameTimerCallback('' + this.vehicleId, this.onFrameTimer.bind(this)) |
|
|
window.agv3 = this |
|
|
window.agv3 = this |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@ -223,9 +223,8 @@ export default class PtrObject extends THREE.Object3D { |
|
|
bootForShow() { |
|
|
bootForShow() { |
|
|
this.isMonitoring = false |
|
|
this.isMonitoring = false |
|
|
this.boot() |
|
|
this.boot() |
|
|
this.subscribeMessage('/wcs_server/' + this.item.id) |
|
|
this.subscribeMessage('/wcs_server/' + this.vehicleId) |
|
|
this.subscribeMessage('/agv_robot/status') |
|
|
this.subscribeMessage('/agv_robot/status') |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
bootForMonitor() { |
|
|
bootForMonitor() { |
|
|
@ -378,7 +377,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>) { |
|
|
@ -401,7 +400,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)) |
|
|
} |
|
|
} |
|
|
@ -536,16 +535,16 @@ export default class PtrObject extends THREE.Object3D { |
|
|
const quat2 = new THREE.Quaternion().setFromEuler(euler) |
|
|
const quat2 = new THREE.Quaternion().setFromEuler(euler) |
|
|
const angleDiff = quat1.angleTo(quat2) |
|
|
const angleDiff = quat1.angleTo(quat2) |
|
|
|
|
|
|
|
|
if (p.distanceTo(this.position) < 0.5 && Math.abs(angleDiff) < Math.PI/4) { |
|
|
if (p.distanceTo(this.position) < 0.5 && Math.abs(angleDiff) < Math.PI / 4) { |
|
|
return |
|
|
return |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
this.position.set(p.x, 0, p.z) |
|
|
this.position.set(p.x, 0, p.z) |
|
|
|
|
|
|
|
|
const transform = new Ammo.btTransform(); |
|
|
const transform = new Ammo.btTransform() |
|
|
this.boxBody.getMotionState().getWorldTransform(transform); |
|
|
this.boxBody.getMotionState().getWorldTransform(transform) |
|
|
transform.setOrigin(new Ammo.btVector3(p.x, 0, p.z)); // 设置新位置
|
|
|
transform.setOrigin(new Ammo.btVector3(p.x, 0, p.z)) // 设置新位置
|
|
|
this.boxBody.getMotionState().setWorldTransform(transform); |
|
|
this.boxBody.getMotionState().setWorldTransform(transform) |
|
|
this.viewport.ammoModel.destroy(transform) |
|
|
this.viewport.ammoModel.destroy(transform) |
|
|
this.rotation.set(0, r, 0) |
|
|
this.rotation.set(0, r, 0) |
|
|
} |
|
|
} |
|
|
@ -578,7 +577,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) |
|
|
@ -877,6 +876,7 @@ export default class PtrObject extends THREE.Object3D { |
|
|
keepSpeed: any |
|
|
keepSpeed: any |
|
|
force: any |
|
|
force: any |
|
|
stopD: number = 0.01 |
|
|
stopD: number = 0.01 |
|
|
|
|
|
|
|
|
// 走
|
|
|
// 走
|
|
|
addTravel(logicX: number, logicY: number, direction: number, speed: number = 1): Promise<void> { |
|
|
addTravel(logicX: number, logicY: number, direction: number, speed: number = 1): Promise<void> { |
|
|
|
|
|
|
|
|
@ -912,13 +912,13 @@ export default class PtrObject extends THREE.Object3D { |
|
|
this.keepSpeed.setValue(0, 0, speed) |
|
|
this.keepSpeed.setValue(0, 0, speed) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if (this.viewport.registerPhysicsUpdateCallBack.has(this.item.id)) { |
|
|
if (this.viewport.registerPhysicsUpdateCallBack.has('' + this.vehicleId)) { |
|
|
return null |
|
|
return null |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
this.travelAnimation = 'asd' |
|
|
this.travelAnimation = 'asd' |
|
|
|
|
|
|
|
|
this.viewport.registerPhysicsUpdateCallBack.set(this.item.id, () => { |
|
|
this.viewport.registerPhysicsUpdateCallBack.set('' + this.vehicleId, () => { |
|
|
|
|
|
|
|
|
this.viewport.physicsWorld.stepSimulation(1 / 60, 10) |
|
|
this.viewport.physicsWorld.stepSimulation(1 / 60, 10) |
|
|
|
|
|
|
|
|
@ -943,7 +943,8 @@ export default class PtrObject extends THREE.Object3D { |
|
|
const stopVel = new this.viewport.ammoModel.btVector3(0, 0, 0) |
|
|
const stopVel = new this.viewport.ammoModel.btVector3(0, 0, 0) |
|
|
this.boxBody.setLinearVelocity(stopVel) |
|
|
this.boxBody.setLinearVelocity(stopVel) |
|
|
this.viewport.ammoModel.destroy(stopVel) |
|
|
this.viewport.ammoModel.destroy(stopVel) |
|
|
this.viewport.registerPhysicsUpdateCallBack.delete(this.item.id) |
|
|
|
|
|
|
|
|
this.viewport.registerPhysicsUpdateCallBack.delete('' + this.vehicleId) |
|
|
this.viewport.ammoModel.destroy(this.force) |
|
|
this.viewport.ammoModel.destroy(this.force) |
|
|
this.viewport.ammoModel.destroy(this.keepSpeed) |
|
|
this.viewport.ammoModel.destroy(this.keepSpeed) |
|
|
this.position.set(this.__toPos.x, this.__toPos.y, this.__toPos.z) |
|
|
this.position.set(this.__toPos.x, this.__toPos.y, this.__toPos.z) |
|
|
@ -977,17 +978,17 @@ export default class PtrObject extends THREE.Object3D { |
|
|
if (cSpeed >= Math.abs(speed) || distance <= stopDistance) { |
|
|
if (cSpeed >= Math.abs(speed) || distance <= stopDistance) { |
|
|
currentPhase = 'uniform' |
|
|
currentPhase = 'uniform' |
|
|
} |
|
|
} |
|
|
this.boxBody.setDamping(0, 0); |
|
|
this.boxBody.setDamping(0, 0) |
|
|
break |
|
|
break |
|
|
case 'uniform': |
|
|
case 'uniform': |
|
|
currentPhase = 'uniform' |
|
|
currentPhase = 'uniform' |
|
|
this.boxBody.setLinearVelocity(keepSpeed) |
|
|
this.boxBody.setLinearVelocity(keepSpeed) |
|
|
this.boxBody.setDamping(0, 0); |
|
|
this.boxBody.setDamping(0, 0) |
|
|
break |
|
|
break |
|
|
case 'decelerate': |
|
|
case 'decelerate': |
|
|
// 检测停止
|
|
|
// 检测停止
|
|
|
if (cSpeed > 0) { |
|
|
if (cSpeed > 0) { |
|
|
this.boxBody.setDamping(sa, 0); |
|
|
this.boxBody.setDamping(sa, 0) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
this.boxBody.activate() |
|
|
this.boxBody.activate() |
|
|
@ -1057,7 +1058,7 @@ export default class PtrObject extends THREE.Object3D { |
|
|
this.OperationType = 4 |
|
|
this.OperationType = 4 |
|
|
this.animationUpFork(height + 0.2).then( |
|
|
this.animationUpFork(height + 0.2).then( |
|
|
() => this.animationShowFork(1.35).then( |
|
|
() => this.animationShowFork(1.35).then( |
|
|
()=>this.animationUpFork(height).then( |
|
|
() => this.animationUpFork(height).then( |
|
|
() => { |
|
|
() => { |
|
|
try { |
|
|
try { |
|
|
const a = this.agvStatusVo.unloadBasLocationVo |
|
|
const a = this.agvStatusVo.unloadBasLocationVo |
|
|
@ -1124,7 +1125,7 @@ export default class PtrObject extends THREE.Object3D { |
|
|
throw new Error(`无法拾取物品 ${id},它不是一个有效的 MeshWrap`) |
|
|
throw new Error(`无法拾取物品 ${id},它不是一个有效的 MeshWrap`) |
|
|
} |
|
|
} |
|
|
item.dt.storeAt = { |
|
|
item.dt.storeAt = { |
|
|
item: this.id + "" |
|
|
item: this.id + '' |
|
|
} |
|
|
} |
|
|
const mesh = wrap.manager.wrapToObject3D(wrap) |
|
|
const mesh = wrap.manager.wrapToObject3D(wrap) |
|
|
this.viewport.entityManager.replaceObject(id, mesh) |
|
|
this.viewport.entityManager.replaceObject(id, mesh) |
|
|
|