当前位置:网站首页>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
边栏推荐
- FBS(fman build system)打包
- 微信小程序的订阅号开发(消息推送)
- Strange bug of cnpm
- Interesting talk about network protocol
- Crontab timing task output generates a large number of mail and runs out of file system inode problem processing
- Node接入支付宝开放平台的沙箱实现支付功能
- Spark入门基本操作
- Elmo (bilstm-crf + Elmo) (conll-2003 named entity recognition NER)
- linux安装mysql后修改密码
- Force deduction brush question 101 Symmetric binary tree
猜你喜欢

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

Un modèle universel pour la construction d'un modèle d'apprentissage scikit

The latest development of fed digital currency

33 million IOPs, 39 microsecond delay, carbon footprint certification, who is serious?

基础知识学习记录

Mock测试

Program compilation and debugging learning record

org.apache.parquet.schema.InvalidSchemaException: A group type can not be empty. Parquet does not su

基於CM管理的CDH集群集成Phoenix

Strange bug of cnpm
随机推荐
BUG_me
jacob打印word
基于ibeacons三点定位(微信小程序)
CentOS mysql多实例部署
变长参数__VA_ARGS__ 和 写日志的宏定义
Prediction of tomorrow's trading limit of Low Frequency Quantization
RobotFramework 之 项目框架
Universal template for scikit learn model construction
freeCodeCamp----arithmetic_ Arranger exercise
CDH cluster integration Phoenix based on CM management
生成随机高质量符合高斯分布的随机数
The latest development of fed digital currency
go 语言 数组,字符串,切片
Neuron and neural network
网站_收藏
使用Postman进行Mock测试
JS 力扣刷题 102. 二叉树的层序遍历
生产环境——
Interesting talk about network protocol
Chapter 15 new technologies of software engineering