KAIST Mobile Software Project - Drone Heliport Platform

본 토픽은 현재 준비중입니다. 공동공부에 참여하시면 완성 되었을 때 알려드립니다.

6. Measurement test of distance between Heliport and Drone using BLE

* Measuring distance between raspberrypi and beacon using bluetooth dongle

To test applied beacon for inducing Drone to the position on the Heliport more precisely,

we experimented some test code for checking distance between Bluetooth dongle on

the raspberrypi and Beacon. The test code was written by python and calculates the distance between

the blutooth dongle and Beacons(including circumiacent Beacon) by scanning. 

After sometimes, we are going to modify the test code for searching beacon only on the Heliport.

To measure precise distance, we need to work with software more often.

 

The below picture are Beacon and Blutooth dongle.

 

  

Below picture is the result of BLE scanning by Blutooth dongle on raspberrypi.

We can measure the distance between the dongle and Beacon using RSSI and TxPower.

 

Setup BLE on the RaspberryPi

1. Install bluetooth stack called blueZ

sudo apt-get update && sudo apt-get upgrade
sudo apt-get install libusb-dev
sudo apt-get install libdbus-1-dev
sudo apt-get install libglib2.0-dev --fix-missing
sudo apt-get install libudev-dev
sudo apt-get install libical-dev
sudo apt-get install libreadline-dev
sudo apt-get install libdbus-glib-1-dev

sudo mkdir bluez
cd bluez
sudo wget www.kernel.org/pub/linux/bluetooth/bluez-5.19.tar.gz
sudo gunzip bluez-5.19.tar.gz
sudo tar xvf bluez-5.19.tar
cd bluez-5.19
sudo ./configure --disable-systemd
sudo make
sudo make install

[It will take 15~20 min for compile]

sudo apt-get install python-bluez

[rebooting]

sudo shutdown -r now


2. Install blutooth on the raspberrypi

[Checking bluetooth recognition using lsusb command]

root@raspberrypi:~# lsusb
Bus 001 Device 006: ID 0a12:0001 Cambridge Silicon Radio, Ltd Bluetooth Dongle (HCI mode)<--- blutooth dongle is recongnized.
Bus 001 Device 005: ID 413c:2106 Dell Computer Corp. Dell QuietKey Keyboard
Bus 001 Device 004: ID 045e:0737 Microsoft Corp. Compact Optical Mouse 500
Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp. SMSC9512/9514 Fast Ethernet Adapter
Bus 001 Device 002: ID 0424:9514 Standard Microsystems Corp.
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
root@raspberrypi:~#

 

3. Checking detail information of bluetooth dongle

root@raspberrypi:~# hciconfig
hci0:   Type: BR/EDR  Bus: USB
        BD Address: 00:1A:7D:DA:71:13  ACL MTU: 310:10  SCO MTU: 64:8
        UP RUNNING                                                       <-- blutooth dongle is working now
        RX bytes:15806096 acl:0 sco:0 events:389229 errors:0
        TX bytes:1552 acl:0 sco:0 commands:55 errors:0

root@raspberrypi:~#


When the blutooth dongle is turned off
We can turn it on using 'sudo hciconfig hci0 up' command.

root@raspberrypi:~# sudo hciconfig hci0 up

We can check if the dongle is turned on using 'hciconfig' command.

[We added some code for turn the dongle on when BLE Scan SW is initialized. Therefore,

We can turn it on for test at firt time, after that we don't need to do that again.]


4. Execution of BLE Scan Test SW

[Changing directory to the copy position of BLE Scan Test SW]
root@raspberrypi:~# cd /work/ble/iBeacon-Scanner-/

root@raspberrypi:/work/ble/iBeacon-Scanner-# ls
blescan.py  blescan.pyc  README.md  test-BLE_Scan_Task.py

[Execution of test-BLE_Scan_Task.py]
root@raspberrypi:/work/ble/iBeacon-Scanner-# python test-BLE_Scan_Task.py


5. Log after execution of test-BLE_Scan_Task.py

Turn On Bluetooth Dongle!    <-- Turn the blutooth dongle on
ble thread started           <-- Start BLE Scan Thread  
[BLE]Start BLE-MAIN_TASK !   <-- Scan start!
[0]-------------
        SUM TxPower: -59.0
        SUM RSSI: -64.0
        TxPower: -59
        RSSI: -64
[1]-------------
        SUM TxPower: -118.0
        SUM RSSI: -128.0
        TxPower: -59
        RSSI: -64
[2]-------------
        SUM TxPower: -177.0
        SUM RSSI: -187.0
        TxPower: -59
        RSSI: -59
[3]-------------
        SUM TxPower: -236.0
        SUM RSSI: -246.0
        TxPower: -59
        RSSI: -59
[4]-------------
        SUM TxPower: -295.0
        SUM RSSI: -310.0
        TxPower: -59
        RSSI: -64
[5]-------------
        SUM TxPower: -354.0
        SUM RSSI: -374.0
        TxPower: -59
        RSSI: -64
[6]-------------
        SUM TxPower: -413.0
        SUM RSSI: -438.0
        TxPower: -59
        RSSI: -64
[7]-------------
        SUM TxPower: -472.0
        SUM RSSI: -502.0
        TxPower: -59
        RSSI: -64
[8]-------------
        SUM TxPower: -531.0
        SUM RSSI: -560.0
        TxPower: -59
        RSSI: -58
[9]-------------
        SUM TxPower: -590.0
        SUM RSSI: -619.0
        TxPower: -59
        RSSI: -59
ratio:  1.04915254237
        VALID Count: 10
        AVE TxPower: -59.0
        AVE RSSI: -61.9
        Distance: 1.41351327124
        Proximity: 2
----------
Proximity: PROXIMITY_NEAR    <-- After measurement of10 times checking, we can know that Beacon is closed using the average value.
Accuracy:  1.41351327124     <-- Mesured distance is about 1.4M.

 

The metric for distance calculation is RSSI value. Although the TxPower value is used  to improve accurarcy  but the RSSI value is really not stable so the result of distance calculation is not stable. We should take care of this issue by SW work.

 

6. Reference for SW coding

As we can know when we look test-BLE_Scan_Task.py 

'blescan' is imported and then, 

After calling BLE_Create_Scan_Task(), BLE Scan Thread is generated, Scan is started.

Two information is supported.

We can call the below function to know the approximate distance between Current Beacon and

Blutooth dongle.

BLE_Get_Proximity()

Return value is like below.

PROXIMITY_UNKNOWN = 0 	#Unknow position
PROXIMITY_IMMEDIATE = 1 #Very closed less than 50cm
PROXIMITY_NEAR = 2      #Closed less than 4m 
PROXIMITY_FAR = 3	#Far more than 4m

 

If we want to know the current measurement distance between Beacon and Bluetooth dongle, we can call the below function.

BLE_Get_Distance()

The return value is decimal point value for representing distance in metor(m)

 

 

 

 

댓글

댓글 본문
  1. Can I ask something..?

    Where can I buy the beacon and blutooth dongle?
버전 관리
우충기
현재 버전
선택 버전
graphittie 자세히 보기