Esempio n. 1
0
#for pi 4 UART port
#port = serial.Serial("/dev/ttyS0",baudrate = 921600, timeout = 0.5)
#
#Drone Object Detect Radar initial
#port = serial.Serial("/dev/tty.usbmodemGY0052534",baudrate = 921600, timeout = 0.5)
#port = serial.Serial("/dev/tty.usbmodem14103",baudrate = 115200 , timeout = 0.5)
#port = serial.Serial("/dev/tty.usbmodemGY0050674",baudrate = 921600, timeout = 0.5)
#port = serial.Serial("/dev/tty.SLAB_USBtoUART3",baudrate = 921600, timeout = 0.5)
port = serial.Serial("/dev/tty.usbmodemGY0043864",
                     baudrate=921600,
                     timeout=0.5)

#for NUC ubuntu
#port = serial.Serial("/dev/ttyACM1",baudrate = 921600, timeout = 0.5)

radar = vehicleODR.VehicleODR(port)

v8len = 0
v9len = 0
v10len = 0


def colorMapping(inp):
    #print(inp)
    cx = (0, 0, 1, 1)
    if inp < 0.2:
        cx = (0, 0, 0.7, 0.8)  # blue
    elif inp >= 0.2 and inp < 0.6:
        cx = (0, 0, 1, 1)
    elif inp >= 0.6 and inp < 1.4:
        cx = (0, 0.13, 0.78, 1)
            port.flushInput()


##########################################################################################


##########################################################################################
def jb_animateCB(xdata, im):
    global heatA
    im.set_data(heatA)


##########################################################################################

##########################################################################################
pm = vehicleODR.VehicleODR(port)
heatA = np.zeros((JB_RANGE_GRID_64, JB_AZIMUTH_GRID_48))

thread1 = Thread(target=jb_uartThreadCB, args=("UART", ))
thread1.setDaemon(True)
thread1.start()

fig, ax = plt.subplots()
im = ax.imshow(np.random.rand(JB_RANGE_GRID_64, JB_AZIMUTH_GRID_48),
               interpolation='nearest')
ani = animation.FuncAnimation(fig,
                              jb_animateCB,
                              interval=200,
                              repeat=True,
                              fargs=(im, ))
plt.show()