一种使用 python 分别在每个 BLE 设备上应用卡尔曼滤波的方法

Posted

技术标签:

【中文标题】一种使用 python 分别在每个 BLE 设备上应用卡尔曼滤波的方法【英文标题】:A way to apply Kalman filtering on each BLE device separately using python 【发布时间】:2021-12-04 11:13:48 【问题描述】:

我正在尝试使用卡尔曼滤波获取每个 BLE 信标的滤波 RSSI 值。我不能在所有 BLE 设备上使用单个卡尔曼滤波实例,如何为每个 BLE 设备映射或分配卡尔曼滤波实例。我知道它与地图有关,但无法弄清楚如何实现它。 任何帮助将不胜感激。

from bluepy.btle import Scanner
from kalman import KalmanFilter
scanner = Scanner().withDelegate(ScanDelegate())
blemacid = ["d7:b1:41:09:ca:c2","ed:9d:41:19:4c:43","fe:98:f1:d3:85:4f","de:0d:34:4d:66:5e"]

kalmanfilter=map(KalmanFilter(0.008,0.1),blemacid)

while(True):
   devices=scanner.scan(3.0)
   for device in devices:
      if device.addr in blemacid:
         print ("DEV= RSSI =".format(device.addr,kalmanfilter.filter(device.rssi)))

卡尔曼滤波器实现在这里kalman filer

【问题讨论】:

【参考方案1】:

我不认为map 是解决此问题的正确方法。存储在字典中并由设备地址键入的过滤器实例似乎是一个更好的解决方案。例如:

from bluepy.btle import Scanner
from kalman import KalmanFilter
scanner = Scanner().withDelegate(ScanDelegate())
blemacid ="d7:b1:41:09:ca:c2": KalmanFilter(0.008,0.1),
           "ed:9d:41:19:4c:43": KalmanFilter(0.008,0.1),
           "fe:98:f1:d3:85:4f": KalmanFilter(0.008,0.1),
           "de:0d:34:4d:66:5e": KalmanFilter(0.008,0.1)

while(True):
   devices=scanner.scan(3.0)
   for device in devices:
      if device.addr in blemacid.keys():
         print("DEV= RSSI =".format(device.addr,blemacid[device.addr].filter(device.rssi)))

我还要注意device.addr 以小写形式返回地址,与blemacid 键中的地址相同,因此地址比较可以正常工作。

【讨论】:

感谢您的解决方案。我们以同样的方式结束了。

以上是关于一种使用 python 分别在每个 BLE 设备上应用卡尔曼滤波的方法的主要内容,如果未能解决你的问题,请参考以下文章

杂记:解决Android扫描BLE设备名称不刷新问题

无法使用 python 从 BLE 设备读取特定特征

使用 MAC ios 连接到 BLE 设备

我无法列出 Raspberry Pi 附近的 BLE 设备(python、btmgmt)

BLE在不同设备上的不同外设名称

BLE设备之间的通信方式