-
Notifications
You must be signed in to change notification settings - Fork 0
/
zmq_client_sensorfusion.py
51 lines (27 loc) · 1.01 KB
/
zmq_client_sensorfusion.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
import zmq
import numpy as np
import matplotlib.pyplot as plt
import cv2
import Msg
import flatbuffers
import math
context = zmq.Context()
socket = context.socket(zmq.SUB)
socket.connect("tcp://localhost:1111")
while True:
socket.subscribe(b'd\x02\x00\x03')
topic = socket.recv()
array_buffer = socket.recv()
data_bytearray = bytearray(array_buffer)
msg = Msg.Msg.GetRootAsMsg(array_buffer,0)
msg_as_np = msg.ValueVectorAsNumpy()
x_sensorfusion = msg_as_np[0]
y_sensorfusion = msg_as_np[1]
phi_sensorfusion = msg_as_np[2]
v_sensorfusion = msg_as_np[3]
omega_sensorfusion = msg_as_np[4]
v_vehicle_0 = math.cos(phi_sensorfusion)*v_sensorfusion
v_vehicle_1 = math.sin(phi_sensorfusion)*v_sensorfusion
v_vehicle_sensorfusion = np.matrix([[v_vehicle_0], [v_vehicle_1] , [0]])
omega_vehicle_sensorfusion = np.matrix([[0], [0] , [omega_sensorfusion]])
print(omega_vehicle_sensorfusion)