当前位置: 首页 > Web前端 > JavaScript

智能矿山无人驾驶模块

时间:2023-03-27 13:27:00 JavaScript

先看效果图实现步骤获取点。在editHelper中获取运动的路线。得到的路由数据如下://移动路由const__gps_pos:any=[[[-810.738647,717.010071,-59.492908],[-785.508789,689.994446,-59.129532],[-766.73468,663.347046,-57.7],[-766.73468,663.347046,-57.],23-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]]]获取车辆层//获取层树constres=await__g.infoTree.get()//获取矿车idmainCarId=res.infotree.filter((item:any)=>item.name==='minecar')[0].iD//获取图层constobjRes=await__g.tileLayer.getObjectIDs(mainCarId)//获取图层中的对象idobjId=objRes.data[0].objectIds[0]隐藏冗余层letinfoArr,hideArrconstneedHideArr:any=['矿车','矿山轮廓','矿热','隧道场景','智慧农业_底图','智慧农业_底部地图块','智慧农业地质层','智能环保地板特效']/***隐藏层*/consthideNeed=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)}添加矿车/***添加矿车*@paramlocation位置*@paramid车辆id*@paramrotation旋转角度*/constaddCar=async(location:number[],id:string,rotation=[0,0,0])=>{await__g.customObject.addByTileLayer({id,tileLayerId:mainCarId,//注意5.3中的新特性:数组参数objectId:[objId],location,rotation,smoothMotion:1//1:平滑插值,0:跳转})}添加标记标签/***添加标签*@paramid*@param坐标坐标*@paramtexttext*/constaddMark=async(id:string,coordinate:any,text='MineCart-Working')=>{//创建标签constmarkerObj={id,groupId:'markerAdd',coordinate,//坐标位置coordinateType:0,//默认0为投影坐标系,也可以设置经纬度空间坐标系的值为1range:[1,100000],//可见范围fixedSize:true,//固定图片大小,取值范围:false自适应,近大远小,true固定尺寸,默认值:falsetext,//显示文字useTextAnimation:true,//开启文字展开动画textRange:[1,100000],//文字可见范围[近切割距离,远切割距离]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,//失去焦点后是否自动关闭弹窗autoHeight:true,//自动判断下方是否有对象displayMode:4,//显示模式clusterByImage:true,//根据聚合图像路径分类,即当多个标记的imagePath路径参数相同时,按照路径优先级对标记进行分类聚合:1,//回避优先级occlusionCull:false//是否参与遮挡剔除}await__g.marker.add(markerObj)}vehiclemovement/***添加翻译*@paramcarNumber第几个cars*@paramcarIdvehicleid*/constaddMove=async(carNumber:number,carId:string)=>{//开始翻译constpathPointArr=[]for(leti=0;我<__gps_pos[carNumber].length;i++){//构造数组元素每2秒移动一次constelementPoint={time:i*2,coordinate:__gps_pos[carNumber][i]}pathPointArr.push(elementPoint)}//设置跟随摄像头__g.customObject.setRotation(carId,[0,-90,0])//车辆根据GPS轨迹移动__g.customObject.startMove(carId,0,pathPointArr)}setlabeltofollow//setlabeltofollow__g.marker.setAttachCustomObject({markerId:'car_mark_1',objectId:'car_move_1',offset:[0,0,0]})__g.标记。setAttachCustomObject({markerId:'car_mark_2',objectId:'car_move_2',offset:[0,0,0]})Event.ts中点击车辆旋转摄像头判断点击的物体constOnEvent=async(e:{eventtype:string;PropertyName?:string;UserData?:string;ObjectID?:string;Id?:string;GroupID?:string;MouseClickPoint?:number[];Type?:string})=>{console.log('Leftmouseclick',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)}}}启动自动驾驶模块/***无人驾驶drive*/exportconstunmanned=async()=>{setTheTime()clean()awaitaddCar([-813.645264,724.513428,-61.49287],'car_move_1',[0,-28,0])addMark('car_mark_1',[-882.71228,774.266724,0])awaitaddCar([-665.85467529296875,480.9832763671875,-64.897811889648438],'car_move_2',[0,-28,0])addMark('car_mark_2',[-665.85467529296875,480.9832763671875,0])//设置标签跟随__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')//添加静止车辆awaitaddCar([-609.2427978515625,376.18206787109375,-62139887]5,'car_move_3',[0,0,0])addMark('car_mark_3',[-823.35150146484375,666.82122802734375,0],'minecart-idle')__g.marker.setAttachCustomObject({markerId:'car_mark_3',objectId:'car_move_3',offset:[0,0,0]})最后离开页面清除所有操作(非常重要!!!)*constclean=()=>{__g.customObject.clear()}具体视频效果,可以查看

最新推荐
猜你喜欢