-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.py
71 lines (65 loc) · 2.64 KB
/
test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
from __future__ import print_function # WalabotAPI works on both Python 2 an 3.
from sys import platform
from os import system
from imp import load_source
from os.path import join
if platform == 'win32':
modulePath = join('C:/', 'Program Files', 'Walabot', 'WalabotSDK',
'python', 'WalabotAPI.py')
elif platform.startswith('linux'):
modulePath = join('/usr', 'share', 'walabot', 'python', 'WalabotAPI.py')
wlbt = load_source('WalabotAPI', modulePath)
wlbt.Init()
def PrintSensorTargets(targets):
system('cls' if platform == 'win32' else 'clear')
if targets:
for i, target in enumerate(targets):
print(('Target #{}:\ntype: {}\nangleDeg: {}\nx: {}\ny: {}\nz: {}'+
'\nwidth: {}\namplitude: {}\n').format(i + 1, target.type,
target.angleDeg, target.xPosCm, target.yPosCm, target.zPosCm,
target.widthCm, target.amplitude))
else:
print('No Target Detected')
def InWallApp():
# wlbt.SetArenaX - input parameters
xArenaMin, xArenaMax, xArenaRes = -3, 4, 0.5
# wlbt.SetArenaY - input parameters
yArenaMin, yArenaMax, yArenaRes = -6, 4, 0.5
# wlbt.SetArenaZ - input parameters
zArenaMin, zArenaMax, zArenaRes = 3, 8, 0.5
# Initializes walabot lib
wlbt.Initialize()
# 1) Connects: Establish communication with walabot.
wlbt.ConnectAny()
# 2) Configure: Set scan profile and arena
# Set Profile - to Short-range.
wlbt.SetProfile(wlbt.PROF_SHORT_RANGE_IMAGING)
# Set arena by Cartesian coordinates, with arena resolution
wlbt.SetArenaX(xArenaMin, xArenaMax, xArenaRes)
wlbt.SetArenaY(yArenaMin, yArenaMax, yArenaRes)
wlbt.SetArenaZ(zArenaMin, zArenaMax, zArenaRes)
# Walabot filtering disable
wlbt.SetDynamicImageFilter(wlbt.FILTER_TYPE_NONE)
# 3) Start: Start the system in preparation for scanning.
wlbt.Start()
# calibrates scanning to ignore or reduce the signals
wlbt.StartCalibration()
while wlbt.GetStatus()[0] == wlbt.STATUS_CALIBRATING:
wlbt.Trigger()
while True:
appStatus, calibrationProcess = wlbt.GetStatus()
# 5) Trigger: Scan (sense) according to profile and record signals
# to be available for processing and retrieval.
wlbt.Trigger()
# 6) Get action: retrieve the last completed triggered recording
targets = wlbt.GetImagingTargets()
rasterImage, _, _, sliceDepth, power = wlbt.GetRawImageSlice()
# PrintSensorTargets(targets)
PrintSensorTargets(targets)
# 7) Stop and Disconnect.
wlbt.Stop()
wlbt.Disconnect()
wlbt.Clean()
print('Terminate successfully')
if __name__ == '__main__':
InWallApp()