当前位置:网站首页>Three point positioning based on ibeacons (wechat applet)
Three point positioning based on ibeacons (wechat applet)
2022-04-23 14:04:00 【one billion twenty-nine million one hundred and seventy-nine th】
This article shares three core positioning codes , And the problems found in the process of writing
1: Three point positioning , No, there are three ibeacons You can connect them all , stay wx.getBeacons({}) You will find it easy and difficult to get three , So do the test and buy more ibeacons
2: The Pythagorean theorem is used to locate almost three points on the Internet , Therefore, calculating the distance from moving point to fixed point has become the key , Yes 2 Methods
(1) Here I use the official distance , The applet interface itself will return the distance , This should also be considered rssi Fluctuations and attenuation .
(2) There are also calculation formulas ( I feel that the accuracy is not as high as that given by wechat officials )
var pointBRSSi = res.devices[i].RSSI;
var iRssi = Math.abs(pointBRSSi);
var power = (iRssi-55)/(10*2.0);
var pointBDistance = Math.pow(10, power);
(3) Some code is also copied , Self improvement , Simplified code , The last part is to calculate x,y I don't understand the code of coordinates , So the final result is wrong . The following code has not been understood yet How to calculate the coordinates of . take 01,02,03 Respectively ,(2,0),(2,2),(0,2) Fixed coordinate point , Positioning
var pointDX='';var pointDY = '';
var p = Math.pow(pointADistance,2)/10-Math.pow(pointBDistance,2)/10;
pointDX = 2.5 - p;
var m = Math.pow(pointADistance,2)/10-Math.pow(pointCDistance,2)/10;
pointDY = 2.5 - m;
js Code You can calculate the result But the error is big
predict:function(){
var that=this
wx.startBeaconDiscovery({
// Set up ibeacons Parameters of
uuids: ['uuid'],
// Successful connection
success: function () {
console.log(" Start scanning devices ")
// monitor iBeacon Update event of the device
wx.onBeaconUpdate(function (res) {
// Get and connect Bluetooth devices
wx.getBeacons({
success: (result) => {
console.log("ibacon The number of "+res.beacons.length)
//rssi Strength
var arrayRSSI = new Array();
// distance
var arrayaccay = new Array();
//major
var arraymajor = new Array();
// The distance from the three fixed points to the moving point
var pointADistance = '';
var pointBDistance = '';
var pointCDistance = '';
for(var i = 0; i<res.beacons.length;i++){
// Put the distance and intensity into the array major
arrayRSSI.push(Math.abs(res.beacons[i].RSSI));
arrayaccay.push(res.beacons[i].accuracy)
arraymajor.push(res.beacons[i].major)
}
if(arrayaccay.length > 3 || arrayaccay.length==3){
// Distance ordering
for(var i = 0 ; i < arrayaccay.length ; i ++){
for(var j = i+1 ; j< arrayaccay.length ; j++){
if(arrayaccay[i]<arrayaccay[j]){
var select = arrayaccay[i];
arrayaccay[i] = arrayaccay[j];
arrayaccay[j] = select;
}
}
}
}
// Assign three values to
for(var i = 0 ; i < 3; i++){
if(i==0){
pointADistance=arrayaccay[i]
console.log("a distance :"+pointADistance);
}
if(i==1){
pointBDistance=arrayaccay[i]
console.log("b distance :"+pointBDistance);
}
if(i==2){
pointCDistance=arrayaccay[i]
console.log("c distance :"+pointCDistance);
}
}
if(!pointADistance==''&&!pointBDistance==''&&!pointCDistance==''){
var pointDX='';var pointDY = '';
var p = Math.pow(pointADistance,2)/10-Math.pow(pointBDistance,2)/10;
pointDX = 2.5 - p;
var left=pointDX*10+"%"
var m = Math.pow(pointADistance,2)/10-Math.pow(pointCDistance,2)/10;
pointDY = 2.5 - m;
var top=pointDY*10+"%"
console.log(' Target location X yes '+top);
console.log(' Target location Y yes '+left);
that.setData({
left:left,
top:top
})
}
},
})
})
},
fail:function(){
wx.showToast({
title: ' Not in the range of equipment ',
icon: 'fail',
duration: 500
})
}
}),
// The search timeout Stop scanning the device
setTimeout(function () {
wx.stopBeaconDiscovery({
success: function () {
console.log(" Stop scanning the device !");
}
});
}, 10000);
},
I hope you can help solve the problem , Or there is a better solution to leave a message or send a private message to me .
版权声明
本文为[one billion twenty-nine million one hundred and seventy-nine th]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204231401298017.html
边栏推荐
- 室内外地图切换(室内基于ibeacons三点定位)
- 微信小程序通过低功耗蓝牙设备进行定位及测距(二)
- Choreographer全解析
- Lin Lin, product manager of Lenovo: network failure of local network operator in Tianjin. The background server of Zui system can't work normally for the time being
- JS brain burning interview question reward
- VsCode-Go
- Go语言 RPC通讯
- leetcode--380. O (1) time insertion, deletion and acquisition of random elements
- Force deduction brush question 101 Symmetric binary tree
- Introduction to spark basic operation
猜你喜欢
1256:献给阿尔吉侬的花束
基于ibeacons三点定位(微信小程序)
JS brain burning interview question reward
微信小程序调用客服接口
DeepinV20安装Mariadb
Oracle alarm log alert Chinese trace and trace files
蓝绿发布、滚动发布、灰度发布,有什么区别?
nodejs通过require读取本地json文件出现Unexpected token / in JSON at position
基于ibeacons签到系统
The latest development of fed digital currency
随机推荐
SQL数据库
Intégration de Clusters CDH Phoenix basée sur la gestion cm
Basic knowledge learning record
New关键字的学习和总结
记录一个奇怪的bug:缓存组件跳转之后出现组件复制
Wechat applet
修改ddt生成的测试用例名称
Force deduction brush question 101 Symmetric binary tree
多重继承虚基类习题
leetcode--380. O (1) time insertion, deletion and acquisition of random elements
基础知识学习记录
微信小程序setInterval定时函数使用详细教程
微信小程序的订阅号开发(消息推送)
mysql通过binlog文件恢复数据
leetcode--357. Count the number of different figures
Chapter I review of e-commerce spike products
RobotFramework 之 项目框架
专题测试05·二重积分【李艳芳全程班】
Quartus Prime硬件实验开发(DE2-115板)实验一CPU指令运算器设计
Program compilation and debugging learning record