forked from KaanGure/Haptic_Shoes_Synthetic_Effects
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwatershoetrig.py
More file actions
44 lines (31 loc) · 959 Bytes
/
watershoetrig.py
File metadata and controls
44 lines (31 loc) · 959 Bytes
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
import numpy
import time
import zmq
import random
import sys
import struct
import READ_VL6180
import pub
from pythonosc import osc_message_builder
from pythonosc import udp_client
# Create TOF sensor
TOF = READ_VL6180.createTOF()
# Create ZMQ socket
[socket, publisher_id] = pub.connectSocket()
# Connect udp client to bach
client = udp_client.SimpleUDPClient("132.206.74.208", 14923)
# Create tiles array to be send to simulation
tiles = numpy.tile(0.0, 6*6*4)
client.send_message("/niw/shoe/l", tiles)
while True:
# Read distance value from TOF
dist = TOF.get_distance()
# Convert distance read to 1-10000 range (closer means bigger value)
newDist = numpy.interp(-1*dist, [-255,-1], [0,24000])
print(newDist)
# Send converted value
tiles[20:24] = newDist
client.send_message("/niw/shoe/l", [dist])
# Broadcast actual value read from TOF to ZMQ platform
#pub.sendTOFdata(socket, dist)
time.sleep(0.2)