|
|
|
@ -5,6 +5,7 @@ import {mergeGeometries} from 'three/addons/utils/BufferGeometryUtils.js' |
|
|
|
import gsap from "gsap"; |
|
|
|
import mqtt from 'mqtt'; |
|
|
|
import {Euler} from "three/src/math/Euler"; |
|
|
|
import Cl2Entity from "@/modules/cl2/Cl2Entity"; |
|
|
|
|
|
|
|
export interface Cl2Task { |
|
|
|
// 0:运输 1:接货 2:卸货 3:充电 4:提升移栽取货或卸货 5:滚筒取货或卸货(双向作业) 135:旋转货架 136:旋转车身
|
|
|
|
@ -355,28 +356,31 @@ export default class Cl23dObject extends THREE.Object3D { |
|
|
|
groupPillar.add(ptrForkMesh) |
|
|
|
this.add(groupPillar) |
|
|
|
|
|
|
|
try { |
|
|
|
// 安全连接配置
|
|
|
|
const client = mqtt.connect('mqtt://127.0.0.1:9001', { |
|
|
|
path: '/mqtt', |
|
|
|
clientId: 'virtual-' + item.id, |
|
|
|
clean: true, |
|
|
|
connectTimeout: 10000, |
|
|
|
username: 'user', |
|
|
|
password: 'user', |
|
|
|
unixSocket: true, |
|
|
|
keepalive: 60, |
|
|
|
}); |
|
|
|
// try {
|
|
|
|
// // 安全连接配置
|
|
|
|
// const client = mqtt.connect('mqtt://127.0.0.1:9001', {
|
|
|
|
// path: '/mqtt',
|
|
|
|
// clientId: 'virtual-' + item.id,
|
|
|
|
// clean: true,
|
|
|
|
// connectTimeout: 10000,
|
|
|
|
// username: 'user',
|
|
|
|
// password: 'user',
|
|
|
|
// unixSocket: true,
|
|
|
|
// keepalive: 60,
|
|
|
|
// });
|
|
|
|
|
|
|
|
// 事件绑定
|
|
|
|
client.on('connect', () => { |
|
|
|
console.log('Connected'); |
|
|
|
client.subscribe(['sensor/#', 'alerts'], { qos: 0 }); |
|
|
|
client.publish('status', 'online', { retain: true }); |
|
|
|
client.subscribe(['/wcs_server/' + item.id], { qos: 0 }); |
|
|
|
client.publish('/agv_robot/status', 'online', { retain: true }); |
|
|
|
}); |
|
|
|
|
|
|
|
client.on('message', (topic, msg) => { |
|
|
|
console.log(`[${topic}] ${msg}`); |
|
|
|
const a = JSON.parse(msg.toString()); |
|
|
|
this.handleMessage(a); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
client.on('error', (error) => { |
|
|
|
@ -488,23 +492,12 @@ export default class Cl23dObject extends THREE.Object3D { |
|
|
|
}) |
|
|
|
} |
|
|
|
|
|
|
|
getDirection(object: THREE.Object3D): 0 | 1 | 2 | 3 | 15 { |
|
|
|
let ry = this.rotation.y |
|
|
|
|
|
|
|
while (ry > Math.PI * 2) { |
|
|
|
ry = ry - Math.PI * 2 |
|
|
|
} |
|
|
|
while (ry < - Math.PI * 2) { |
|
|
|
ry = ry + Math.PI * 2 |
|
|
|
handleMessage(data) { |
|
|
|
if (data.id === 10010) { |
|
|
|
const cl2: Cl2Entity = Model.getCl2("10") as Cl2Entity |
|
|
|
cl2.addRobotTask(data) |
|
|
|
cl2.taskStartRun() |
|
|
|
} |
|
|
|
if (ry < 0) { |
|
|
|
ry = Math.PI * 2 + ry |
|
|
|
} |
|
|
|
if (ry >= 0 && ry < Math.PI / 2) { |
|
|
|
return 0 |
|
|
|
} |
|
|
|
|
|
|
|
return 0; |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|