rostopic echo /xx >> xx.txt
import numpy as np
import os, sys,re
name="room_dark_06"
basedir="/media/yinjie/2498AF1F98AEEF0C/adataset/gtmid/"+name+'.txt'
txtdir="/media/yinjie/2498AF1F98AEEF0C/adataset/aftgt/"+name+'.txt'
f1=open(basedir,'r')
f2=open(txtdir,"w")
line=f1.readline()
pflag=0
oflag=0
while line:
if 'secs' in line and 'nsecs' not in line:
sec=int(re.findall(r"\-?\d+\.?\d*" ,line)[0])
if 'nsecs' in line:
nsec=int(re.findall(r"\-?\d+\.?\d*" ,line)[0])
f2.write(str('%.9f' %(sec+nsec*0.000000001))+' ')
if 'position:' in line:
pflag=1
oflag=0
if 'orientation:' in line:
pflag=0
oflag=1
if 'x:' in line and pflag:
px=float(re.findall(r"\-?\d+\.?\d*" ,line)[0])
if 'y:' in line and pflag:
py=float(re.findall(r"\-?\d+\.?\d*" ,line)[0])
if 'z:' in line and pflag:
pz=float(re.findall(r"\-?\d+\.?\d*" ,line)[0])
if 'w:' in line and oflag:
ww=float(re.findall(r"\-?\d+\.?\d*" ,line)[0])
f2.write(str(px)+' '+str(py)+' '+str(pz)+' '+str(ww)+' '+str(wx)+' '+str(wy)+' '+str(wz)+'\n')
if 'x:' in line and oflag:
wx=float(re.findall(r"\-?\d+\.?\d*" ,line)[0])
if 'y:' in line and oflag:
wy=float(re.findall(r"\-?\d+\.?\d*" ,line)[0])
if 'z:' in line and oflag:
wz=float(re.findall(r"\-?\d+\.?\d*" ,line)[0])
line=f1.readline()
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)