日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

智慧矿山无人驾驶模块

發(fā)布時間:2023/12/14 编程问答 42 豆豆
生活随笔 收集整理的這篇文章主要介紹了 智慧矿山无人驾驶模块 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

先看效果圖

實現(xiàn)步驟

獲取點

在editHelper中獲取運動的路線


獲取的路線數(shù)據(jù)如下:

// 移動線路 const __gps_pos: any = [[[-810.738647, 717.010071, -59.492908],[-785.508789, 689.994446, -59.129532],[-766.73468, 663.347046, -59.234707],[-744.801147, 632.33783, -59.748535],[-719.56073, 610.327332, -59.312965],[-704.834167, 589.367798, -59.996193],[-712.187317, 567.8703, -59.428688],[-715.610535, 537.334045, -59.68029],[-694.750061, 510.01828, -59.334183],[-669.627441, 490.004364, -59.930313],[-654.678162, 463.250793, -59.852203],[-645.085815, 434.748444, -59.852203],[-643.587769, 405.069061, -59.92424],[-647.100525, 364.79718, -59.699371]],[[-665.346191, 472.635315, -60.507705688476563],[-689.566528, 504.515778, -60.507705688476563],[-718.146179, 537.280029, -60.507705688476563],[-715.852539, 558.111084, -60.507705688476563],[-702.994385, 584.205811, -60.507705688476563],[-683.715515, 581.828125, -60.507705688476563],[-653.635437, 565.906433, -60.507705688476563],[-578.884033, 515.64563, -60.507705688476563],[-520.529236, 479.109985, -60.507705688476563],[-476.53598, 450.44281, -60.507705688476563]] ]

獲取車輛圖層

// 獲取圖層樹 const res = await __g.infoTree.get() // 獲取礦車id mainCarId = res.infotree.filter((item: any) => item.name === '礦車')[0].iD // 獲取圖層 const objRes = await __g.tileLayer.getObjectIDs(mainCarId) // 獲取圖層內(nèi)對象id objId = objRes.data[0].objectIds[0]

隱藏多余圖層

let infoArr, hideArr const needHideArr: any = ['礦車', '礦坑輪廓線', '礦坑熱力', '隧道場景', '智慧農(nóng)業(yè)_底圖', '智慧農(nóng)業(yè)_底圖分塊', '智慧農(nóng)業(yè)地質(zhì)層', '智慧環(huán)保底板特效'] /*** 隱藏圖層*/ const hideNeed = async () => {// 獲取圖層樹infoArr = await __g.infoTree.get()// 過濾需要顯示的圖層hideArr = infoArr.infotree.filter((item: any) => needHideArr.includes(item.name)).map((item: any) => item.iD)// 隱藏圖層await __g.infoTree.hide(hideArr) }

添加礦車

/*** 添加礦車* @param location 位置* @param id 車輛id* @param rotation 旋轉(zhuǎn)角度*/ const addCar = async (location: number[], id: string, rotation = [0, 0, 0]) => {await __g.customObject.addByTileLayer({id,tileLayerId: mainCarId,//注意5.3新增特性:數(shù)組參數(shù)objectId: [objId],location,rotation,smoothMotion: 1 //1: 平滑插值,0: 跳躍}) }

添加mark標(biāo)簽

/*** 添加標(biāo)簽* @param id* @param coordinate 坐標(biāo)* @param text 文本*/ const addMark = async (id: string, coordinate: any, text = '礦車-正在工作') => {// 創(chuàng)建標(biāo)簽const markerObj = {id,groupId: 'markerAdd',coordinate, //坐標(biāo)位置coordinateType: 0, //默認(rèn)0是投影坐標(biāo)系,也可以設(shè)置為經(jīng)緯度空間坐標(biāo)系值為1range: [1, 100000], //可視范圍fixedSize: true, //圖片固定尺寸,取值范圍:false 自適應(yīng),近大遠(yuǎn)小,true 固定尺寸,默認(rèn)值:falsetext, //顯示的文字useTextAnimation: true, //打開文字展開動畫效果textRange: [1, 100000], //文本可視范圍[近裁距離, 遠(yuǎn)裁距離]textOffset: [0, 0], // 文本偏移textBackgroundColor: [1.0, 1.0, 1.0, 0.5], //文本背景顏色fontSize: 12, //字體大小fontColor: Color.White, //字體顏色popupURL: `${window.origin}/tag/showWorkState.html?`, //彈窗HTML鏈接popupBackgroundColor: [1.0, 1.0, 1.0, 1.0], //彈窗背景顏色popupSize: [500, 350], //彈窗大小popupOffset: [0, 0], //彈窗偏移autoHidePopupWindow: true, //失去焦點后是否自動關(guān)閉彈出窗口autoHeight: true, // 自動判斷下方是否有物體displayMode: 4, //顯示模式clusterByImage: true, // 聚合時是否根據(jù)圖片路徑分類,即當(dāng)多個marker的imagePath路徑參數(shù)相同時按路徑對marker分類聚合priority: 1, //避讓優(yōu)先級occlusionCull: false //是否參與遮擋剔除}await __g.marker.add(markerObj) }

車輛移動

/*** 添加平移* @param carNumber 第幾輛車* @param carId 車輛id*/ const addMove = async (carNumber: number, carId: string) => {// 開始平移const pathPointArr = []for (let i = 0; i < __gps_pos[carNumber].length; i++) {//構(gòu)造數(shù)組元素 每2秒移動一次const elementPoint = { time: i * 2, coordinate: __gps_pos[carNumber][i] }pathPointArr.push(elementPoint)}//設(shè)置跟隨相機(jī)__g.customObject.setRotation(carId, [0, -90, 0])//車輛按GPS軌跡移動__g.customObject.startMove(carId, 0, pathPointArr) }

設(shè)置標(biāo)簽跟隨

// 設(shè)置標(biāo)簽跟隨__g.marker.setAttachCustomObject({markerId: 'car_mark_1',objectId: 'car_move_1',offset: [0, 0, 0]})__g.marker.setAttachCustomObject({markerId: 'car_mark_2',objectId: 'car_move_2',offset: [0, 0, 0]})

點擊車輛旋轉(zhuǎn)相機(jī)

在Event.ts判斷點擊物體

const OnEvent = async (e: { eventtype: string; PropertyName?: string; UserData?: string; ObjectID?: string; Id?: string; GroupID?: string; MouseClickPoint?: number[]; Type?: string }) => {console.log('鼠標(biāo)左鍵單擊', e)// 判斷是否為左鍵點擊的交互if (e.eventtype === 'LeftMouseButtonClick') {if (e.Type == 'marker' && e.Id == 'car_mark_3') {__g.camera.set(-601.601094, 361.158125, -60.57855, 0.393528, -118.390999, 1)}} }

開始自動駕駛模塊

/*** 無人駕駛*/ export const unmanned = async () => {setTheTime()clean()await addCar([-813.645264, 724.513428, -61.49287], 'car_move_1', [0, -28, 0])addMark('car_mark_1', [-882.71228, 774.266724, 0])await addCar([-665.85467529296875, 480.9832763671875, -64.897811889648438], 'car_move_2', [0, -28, 0])addMark('car_mark_2', [-665.85467529296875, 480.9832763671875, 0])// 設(shè)置標(biāo)簽跟隨__g.marker.setAttachCustomObject({markerId: 'car_mark_1',objectId: 'car_move_1',offset: [0, 0, 0]})__g.marker.setAttachCustomObject({markerId: 'car_mark_2',objectId: 'car_move_2',offset: [0, 0, 0]})addMove(0, 'car_move_1')addMove(1, 'car_move_2')// 添加靜止車輛await addCar([-609.2427978515625, 376.18206787109375, -61.138870239257813], 'car_move_3', [0, 0, 0])addMark('car_mark_3', [-823.35150146484375, 666.82122802734375, 0], '礦車-空閑')__g.marker.setAttachCustomObject({markerId: 'car_mark_3',objectId: 'car_move_3',offset: [0, 0, 0]})

最后 離開頁面清除所有操作(很重要!!!)*

const clean = () => {__g.customObject.clear() }

具體視頻效果,可以查看

總結(jié)

以上是生活随笔為你收集整理的智慧矿山无人驾驶模块的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。