Skip to content
Snippets Groups Projects
Commit 9a1614a5 authored by Zhiying Li's avatar Zhiying Li
Browse files

upgrade the distance and send it all together

parent cf5f85cc
Branches
No related merge requests found
......@@ -9,6 +9,8 @@ serial_port.open()
gbx = 0
gby = 0
dist = 0
gbc = 0
### Declare Varables and Constants
device = 'cuda'
......@@ -26,9 +28,10 @@ waitTime = 0.1
while True:
## Testing (using Live Streaming)
gbx, gby = live_feed.detectLive(model)
gbx, gby, dist = live_feed.detectLive(model)
intDist = int(dist) # cm
if gbx != -1 and gby != -1:
"""
value = 'gbx' + str(gbx) + '\n'
print( value , end = '')
serial_port.write(value.encode())
......@@ -38,6 +41,27 @@ while True:
print( value)
serial_port.write(value.encode())
time.sleep(waitTime)
"""
if gbx < 100:
strgbx = '0' + str(gbx)
else:
strgbx = str(gbx)
if gby < 100:
strgby = '0' + str(gby)
else:
strgby = str(gby)
if intDist < 100:
strdist = '0' + str(intDist)
else:
strdist = str(intDist)
value = 'gbc' + strgbx + strgby + strdist + '\n'
# value = 'gbc' + str(dist) + '\n'
print(value)
serial_port.write(value.encode())
time.sleep(waitTime)
else:
value = 'gbx-1\n'
serial_port.write(value.encode())
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment