def file_value(self): log = cali.read_ID() self.device_ID = log self.content.append('当前设备ID为' + log) log = cali.read_hmd_id() print(log) os.system('adb shell setprop debug.hmdinfo_backup.enable 1') self.content.append('当前设备头端ID为' + log) path = self.selected_path + '/' + log + '/' self.content.append('当前工作目录切换到:' + path) target_path = '/data/hmdinfo/' os.chdir(path) cali.write_cali_para() time.sleep(2) #os.system('adb shell rm '+target_path+'*') self.content.append('删除box端文件') time.sleep(1) os.system('adb shell input keyevent 135') self.content.append('读取头端到本地') time.sleep(8) os.system('adb pull ' + target_path) self.content.append('当前比对路径:' + self.save_path) log = cali.file_compare('cam0_G2-sdm845.yaml', 'hmdinfo/cam0_G2-sdm845.yaml') self.content.append('cam0_G2-sdm845文件比对结果:' + log) log = cali.file_compare('cam1_G2-sdm845.yaml', 'hmdinfo/cam1_G2-sdm845.yaml') self.content.append('cam1_G2-sdm845文件比对结果:' + log) log = cali.file_compare('AccelBias.txt', 'hmdinfo/AccelBias.txt') self.content.append('AccelBias.txt文件比对结果:' + log) log = cali.file_compare('rgb_fe.yaml', 'hmdinfo/rgb_fe.yaml') self.content.append('rgb_fe.yaml文件比对结果:' + log) log = cali.file_compare('rgb_tof.yaml', 'hmdinfo/rgb_tof.yaml') self.content.append('rgb_fe.yaml文件比对结果:' + log) log = cali.file_compare('glass_profile.json', 'hmdinfo/glass_profile.json') self.content.append('glass_profile.json文件比对结果:' + log) log = cali.file_compare('rgb_display_transform.json', 'hmdinfo/rgb_display_transform.json') self.content.append('rgb_display_transfo rm.json文件比对结果:' + log) log = cali.file_compare('g2_glass_config.txt', 'hmdinfo/g2_glass_config.txt') self.content.append('g2_glass_config.txt文件比对结果:' + log) self.content.append('文件比对完成') os.chdir(self.selected_path)
def read_ID(self): log = cali.read_ID() self.content.append('当前设备ID为' + log) log = cali.read_hmd_id() self.device_ID = log self.content.append('当前设备头端ID为' + log)
def cv_data_capture(self): phase = 1 phase2 = 0 log = cali.read_ID() self.content.append('当前设备ID为' + log) log = cali.read_hmd_id() self.content.append('当前设备头端ID为' + log) path = self.selected_path + '/' + log + '/' path2 = self.selected_path + '/' + log cali.data_file_creat(path) os.chdir(path) self.content.append('当前工作目录切换到:' + path) self.save_path = path print(self.save_path) print(datetime.datetime.now()) time.sleep(0.1) state = 'error' while (state != 'ok'): #获取标定数据-初始化socket套接字 sk = socket.socket() sk.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) sk.bind(("192.168.0.1", 7080)) sk.listen(5) conn, address = sk.accept() ret = str(conn.recv(1024), encoding="utf-8") print("接收到设备数据" + ret) time.sleep(0.1) conn.sendall(bytes("cstwo", encoding="utf-8")) print("已发送锁存校验数据") time.sleep(0.1) ret = str(conn.recv(1024), encoding="utf-8") print(ret) print("Socket通讯建立") #获取标定数据-P2S1S-IMU-FE内外参标定准备 conn.sendall(bytes("P3S1S", encoding="utf-8")) print("准备移动到机械臂IMU-FE内外参标定点") time.sleep(1) ret = str(conn.recv(1024), encoding="utf-8") print(ret) cali.error_dct(ret, 'P3S1E') print("已移动到机械臂IMU-FE内外参标定点,开始采集") time.sleep(1) log = cali.imu_fe_capture_start() self.content.append(log) conn.sendall(bytes("P2S1S", encoding="utf-8")) print("准备移动机械臂") #获取标定数据-P2S1S-IMU-FE内外参标定 ret = str(conn.recv(1024), encoding="utf-8") print(ret) if ret != 'P2S1E': exit() print(self.save_path) log = cali.imu_fe_capture_end(self.save_path) self.content.append(log) print('数据已保存') if phase == 1: #获取标定数据-P3-静态内外参标定 conn.sendall(bytes("P3S1S", encoding="utf-8")) print("准备移动到下一个点") time.sleep(1) ''' os.system('mkdir TOF') path_TOF = path+'TOF/' os.chdir(path_TOF) os.system('cp '+self.kalibr_path+'irconvert irconvert') ''' os.chdir(path) x = 1 while (x < 16): ret = str(conn.recv(1024), encoding="utf-8") print(ret) print("已移动到机械臂静态内外参标定点,开始标定") print('P3位置' + str(x) + '数据开始采集') cali.FE_capture(self.save_path, self.no[x]) cali.RGB_capture(self.save_path, self.no[x]) ''' os.chdir(path_TOF) cali.TOF_IR_capture(path_TOF,self.no[x]) os.system('./irconvert '+self.no[x]+'.bin'+' '+self.no[x]+'.jpg 0.2') os.system('rm '+self.no[x]+'.bin') os.chdir(path) ''' print('P3位置' + str(x) + '数据已保存') if x < 10: senddata = "P3S" + str(x) + "S" if x > 9: senddata = "3S" + str(x) + "S" conn.sendall(bytes(senddata, encoding="utf-8")) print("准备移动到下一个点") time.sleep(0.5) x = x + 1 ret = str(conn.recv(1024), encoding="utf-8") print(ret) #os.system('rm TOF/irconvert') #结束标定,回到初始位置 time.sleep(1) conn.sendall(bytes("P3S1S", encoding="utf-8")) print("准备移动到装配点") time.sleep(1) ret = str(conn.recv(1024), encoding="utf-8") print(ret) cali.error_dct(ret, 'P3S1E') time.sleep(2) print(datetime.datetime.now()) print('数据已保存') print('标定获取数据结束') self.content.append('开始计算标定数据') #标定数据计算开始 if phase2 == 1: os.chdir(self.save_path) ''' os.system('adb pull /data/hmdinfo/rgb_display_transform.json') os.system('adb pull /data/hmdinfo/glass_profile.json') os.system('adb pull /data/hmdinfo/g2_glass_config.txt') ''' print('开始执行参数计算') cali.calculate_IMU_FE(self.kalibr_path) state = cali.yaml_process() time.sleep(1) cali.kalibr_RGB_FE(self.kalibr_path) time.sleep(1) os.system('mv cam-imu cam-imu-2') os.system('mkdir cam-imu') os.system('cp -r CVIMG cam-imu/cam1') #os.system('mv TOF cam-imu/cam0') os.system('cp ' + self.kalibr_path + 'cameraindex.csv cam-imu/cameraindex.csv') #os.system('./kal_rgb.sh') #os.system('mv camchain-glasses.yaml rgb_tof.yaml') cali.write_cv_para() os.chdir(self.selected_path) os.system('cp -r ' + path2 + ' ' + self.back_path) conn.close() print('CV标定已完成') self.content.append('CV系统标定已完成')
def cali_imu(self): log = cali.read_ID() self.device_ID = log self.content.append('当前设备ID为' + log) log = cali.read_hmd_id() print(log) self.content.append('当前设备头端ID为' + log) path = self.selected_path + '/' + log + '/' os.chdir(path) self.content.append('当前工作目录切换到:' + path) self.content.append('开始进行IMU标定') #获取标定数据-初始化socket套接字 sk = socket.socket() sk.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) sk.bind(("192.168.0.1", 7080)) sk.listen(5) conn, address = sk.accept() ret = str(conn.recv(1024), encoding="utf-8") print("接收到设备数据" + ret) time.sleep(0.1) conn.sendall(bytes("cstwo", encoding="utf-8")) print("已发送锁存校验数据") time.sleep(0.1) ret = str(conn.recv(1024), encoding="utf-8") print(ret) print("Socket通讯建立") #获取标定数据-P1S1S-IMU标定步骤1 step = 1 while (step < 7): conn.sendall(bytes("P4S" + str(step) + "S", encoding="utf-8")) print("已发送下一点位置数据") time.sleep(0.1) ret = str(conn.recv(1024), encoding="utf-8") print(ret) print("已移动到机械臂IMU标定" + str(step) + "号点,开始" + str(step) + "位置标定") time.sleep(14) f = os.popen(r"adb shell testimucal " + str(step), "r") shuchu = f.read() f.close() n = 2 while (shuchu[0] != '0'): print('标定失败,进行第[' + str(n) + ']次尝试') f = os.popen(r"adb shell testimucal " + str(step), "r") shuchu = f.read() f.close() n = n + 1 if n > 6: print('6次标定都失败,请注意是不是夜深人静,再进行重试') conn.sendall(bytes("GHOME", encoding="utf-8")) print("准备移动到装配点") time.sleep(1) ret = str(conn.recv(1024), encoding="utf-8") print(ret) cali.error_dct(ret, 'HOMED') conn.close() exit() print("IMU标定" + str(step) + "结果" + shuchu) step = step + 1 print("准备移动到下一个点") conn.sendall(bytes("GHOME", encoding="utf-8")) print("准备移动到装配点") time.sleep(1) #等待设备到装配点,安装设备 ret = str(conn.recv(1024), encoding="utf-8") print(ret) cali.error_dct(ret, 'HOMED') print('IMU标定完成') os.system('adb pull /data/hmdinfo/AccelBias.txt') os.chdir(self.selected_path) self.content.append('IMU标定完成') conn.close()
def push_app(self): log = cali.read_hmd_id() os.system('adb install ' + self.config["Enviroment"]["RGB_capture_app"]) self.content.append('当前设备ID为' + log)