123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149 |
- # -*- coding:utf-8 -*-
- import matplotlib.pyplot as plt
- import ctypes
- import numpy.ctypeslib as npct
- import time
- import threading
- import numpy as np
- import time
- listen_status = 1
- right_acc_z_data = [0] * 500
- left_acc_z_data = [0] * 500
- left_zupt_data = [0] * 500
- right_zupt_data = [0] * 500
- x = list(range(500))
- left_x_data = []
- left_y_data = []
- right_x_data = []
- right_y_data = []
- CAL_STATUS = 1
- SHOW_TATUS = 2
- cal_or_read = CAL_STATUS
- shoes_down = []
- phone_down = []
- left_front_mag_buff = []
- right_front_mag_buff = []
- left_back_mag_buff = []
- right_back_mag_buff = []
- def calGameData():
- path = 'F:\work\matlab\手机数据显示\\'
- dir_name = 'android_com.ouj.paoku_1644993592935.txt'
- #dir_name = 'android_com.ouj.paoku_1642494915250.txt'
- ctypes.cdll.LoadLibrary(
- r"C:\Users\Administrator\source\repos\CMakeTestProject\CMakeTestProject\bin\SDK_LIB.dll")
- lib = ctypes.cdll.LoadLibrary(
- r"C:\Users\Administrator\source\repos\CMakeTestProject\CMakeTestProject\bin\python_interface.dll")
- lib.getShoesDown.restype = ctypes.c_int
- lib.DanceObject(1) # 初始化静态变量为跳舞毯游戏
- lib.getShoesDown.argtypes = [ctypes.c_int, npct.ndpointer(dtype=np.int, ndim=1, flags="C_CONTIGUOUS"),
- npct.ndpointer(dtype=np.int, ndim=1, flags="C_CONTIGUOUS"),
- npct.ndpointer(dtype=np.int, ndim=1, flags="C_CONTIGUOUS"),
- ctypes.c_int, ctypes.c_int,
- npct.ndpointer(dtype=np.int, ndim=1, flags="C_CONTIGUOUS"),
- npct.ndpointer(dtype=np.int, ndim=1, flags="C_CONTIGUOUS"),
- npct.ndpointer(dtype=np.int, ndim=1, flags="C_CONTIGUOUS"),
- ctypes.c_int, ctypes.c_int,
- ctypes.c_int, ctypes.c_int, ctypes.c_int, ctypes.c_int
- ]
- with open(path + dir_name, "r") as f:
- for line in f.readlines():
- data = line.strip('\n')
- data = data.split(',')
- data = list(map(int, data))
- # print(data)
- right_pos_data = np.array(data[0:3], dtype=np.int)
- right_att_data = np.array(data[3:6], dtype=np.int)
- right_acc_data = np.array(data[6:9], dtype=np.int)
- right_front_mag = int(data[9])
- right_back_mag = int(data[10])
- right_zupt = int(data[11])
- left_pos_data = np.array(data[12:15], dtype=np.int)
- left_att_data = np.array(data[15:18], dtype=np.int)
- left_acc_data = np.array(data[18:21], dtype=np.int)
- left_front_mag = int(data[21])
- left_back_mag = int(data[22])
- left_zupt = int(data[23])
- down = int(data[24])
- jump = int(data[25])
- rssi = int(data[26])
- posTimeStamp = int(data[27])
- right_step = int(data[28])
- left_step = int(data[29])
- '''
- lib.gameProcess(posTimeStamp, right_pos_data, right_att_data, right_acc_data, right_zupt, right_front_mag,
- left_pos_data, left_att_data, left_acc_data, left_zupt, left_front_mag,
- jump, down, rssi, 0)
- '''
- down_tag = lib.getShoesDown(posTimeStamp, right_pos_data, right_att_data, right_acc_data, right_zupt, right_front_mag,
- left_pos_data, left_att_data, left_acc_data, left_zupt, left_front_mag,
- right_front_mag, left_front_mag, right_back_mag, left_back_mag)
- shoes_down.append(down_tag * 30000)
- phone_down.append(down * 18000)
- left_front_mag_buff.append(left_front_mag)
- right_front_mag_buff.append(right_front_mag)
- left_back_mag_buff.append(left_back_mag)
- right_back_mag_buff.append(right_back_mag)
- if __name__ == '__main__':
- calGameData()
- fig, ax = plt.subplots()
- ax.plot(right_front_mag_buff, label = 'right_front_mag')
- ax.plot(left_front_mag_buff, label = 'left_front_mag')
- ax.plot(right_back_mag_buff, label = 'right_back_mag')
- ax.plot(left_back_mag_buff, label = 'left_back_mag')
- ax.plot(shoes_down, label = 'shoes_down')
- ax.plot(phone_down, label='phone_down')
- ax.legend()
- plt.grid()
- plt.show()
- plt.pause(0)
|