Skip to content

Commit ca14d13

Browse files
Ogban UgotOgban Ugot
authored andcommitted
WIP from mac
2 parents 36d8440 + 9b997fe commit ca14d13

6 files changed

Lines changed: 68 additions & 8 deletions

File tree

latcam

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
210.0, 300.0
2+
400.0, 600.0
3+
104.0, 324.0
4+
204.0, 841.0
5+
173.0, 526.0
6+
227.0, 362.0
7+
119.0, 606.0
8+
914.0, 423.0
9+
634.0, 601.0
10+
743.0, 922.0

notes.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
python3 producer.py 192.168.0.193:9092 leftarm13

producer.py

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,40 @@
22
import numpy as np
33
import json
44
import sys
5+
import time
56

67
def send_signal():
78
print(sys.argv[1])
89
print(sys.argv[2])
910
producer = KafkaProducer(bootstrap_servers=sys.argv[1])
10-
arr = np.random.rand(800)
11-
a = arr.tolist()
12-
json_object = json.dumps(a)
13-
# print(json_object)
14-
res = producer.send(sys.argv[2], bytes(json_object, 'utf-8'))
15-
print(res)
16-
print("sucess")
11+
ess_list = []
12+
with open(sys.argv[3]) as f:
13+
lines = [line.rstrip('\n') for line in f]
14+
for line in lines:
15+
ess = []
16+
values = line.split(',')
17+
ess.append(float(values[0]))
18+
ess.append(float(values[1]))
19+
ess_list.append(ess)
20+
21+
for ess in ess_list:
22+
json_state = json.dumps(ess)
23+
data = {
24+
"valence":None,
25+
"score": None,
26+
"state": json_state
27+
}
28+
print(json_state)
29+
json_object = json.dumps(data).encode("utf-8")
30+
res = producer.send(sys.argv[2], json_object)
31+
time.sleep(1)
1732

1833
if __name__ == '__main__':
19-
send_signal()
34+
send_signal()
35+
36+
37+
38+
39+
40+
41+

pub.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
python3 producer.py 192.168.0.193:9092 wheel1 wheel1 &
2+
3+
python3 producer.py 192.168.0.193:9092 wheel2 wheel2 &
4+
5+
python3 producer.py 192.168.0.193:9092 lateral_camera latcam &
6+
7+
wait

wheel1

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
0.212, 0.65
2+
0.121, 0.3242
3+
0.4245, 0.89
4+
0.55, 0.566
5+
0.775, 0.67
6+
0.99, 0.39
7+
0.423, 0.4298
8+
0.11, 0.87
9+
0.893, 0.38
10+
0.3294, 0.940

wheel2

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
9.320, 2.1920
2+
10.23, 11.602
3+
90.42, 32.432
4+
1.392, 3.923
5+
100.33, 20.2
6+
129.12, 39.2
7+
9.312, 8.9
8+
2.312, 3.18
9+
49.31, 49.21
10+
17.42, 16.66

0 commit comments

Comments
 (0)