File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 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
Original file line number Diff line number Diff line change 1+ python3 producer.py 192.168.0.193:9092 leftarm13
Original file line number Diff line number Diff line change 22import numpy as np
33import json
44import sys
5+ import time
56
67def 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
1833if __name__ == '__main__' :
19- send_signal ()
34+ send_signal ()
35+
36+
37+
38+
39+
40+
41+
Original file line number Diff line number Diff line change 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
Original file line number Diff line number Diff line change 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
Original file line number Diff line number Diff line change 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
You can’t perform that action at this time.
0 commit comments