Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
CPS_project_group13
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Hierck, J.J. (Jelle, Student M-BME,M-EMSYS)
CPS_project_group13
Commits
62d14396
Commit
62d14396
authored
4 years ago
by
SiccoColijn
Browse files
Options
Downloads
Patches
Plain Diff
prints if distance is increasing of decreasing
parent
35220a3d
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
mappingbot/bluetooth.py
+66
-2
66 additions, 2 deletions
mappingbot/bluetooth.py
with
66 additions
and
2 deletions
mappingbot/bluetooth.py
+
66
−
2
View file @
62d14396
from
bluepy.btle
import
Scanner
scanner
=
Scanner
()
i
=
0
d
=
0
#m = 0
#h = 0
values
=
[]
oldAverage
=
0
average
=
0
found
=
False
while
True
:
devices
=
scanner
.
scan
(
1.0
)
devices
=
scanner
.
scan
(
0.4
)
# low delay will result in a lot of iterations without RSSI
for
device
in
devices
:
if
device
.
addr
==
"
30:4b:07:ff:e0:3e
"
:
print
(
"
DEV = {} RSSI = {}
"
.
format
(
device
.
addr
,
device
.
rssi
))
#found = True
#h += 1
# Calculate rolling average
values
.
append
(
device
.
rssi
)
valSum
=
sum
(
values
)
if
len
(
values
)
>
20
:
values
.
pop
(
0
)
valSum
=
sum
(
values
)
oldAverage
=
average
average
=
valSum
/
(
len
(
values
))
# if oldAverage != 0:
# #print(average/oldAverage)
# if average/oldAverage > 1.01:
# i += 1
# d = 0
# elif average/oldAverage < 0.99:
# d += 1
# i = 0
# else:
# i = 0
# d = 0
#
# if d > 1:
# # Moving away
# print("decreasing")
# elif i > 1:
# # Coming closer
# print("increasing")
#
# print("D:" + str(d) + " I:" + str(i))
if
average
>
oldAverage
:
d
+=
1
i
=
0
elif
average
<
oldAverage
:
i
+=
1
d
=
0
if
d
>
3
:
# Coming closer
print
(
"
decreasing
"
)
elif
i
>
3
:
# Moving away
print
(
"
increasing
"
)
print
(
"
D:
"
+
str
(
d
)
+
"
I:
"
+
str
(
i
))
#print(values)
#print("Average: " + str(average))
# else:
# m += 1
# print(m)
# if not found:
# m += 1
# else:
# found = False
# print("Hit: " + str(h) + "Miss: " + str(m))
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment