///c++ 写/
std::ofstream lane_postion_log(ROOT_DIR"/build/lane_position_log.txt");//创建文件
lane_postion_log <<p.x<<","<<p.y<<","<<p.z<<endl;//写位置
lane_postion_log.close();
//python显示///
#!/usr/bin/python
# -*- coding: UTF-8 -*-
from numpy import *
import operator
from os import listdir
import matplotlib
import matplotlib.pyplot as plt
from matplotlib.pyplot import MultipleLocator
import numpy as np
def file2matrix(filename):
fr = open(filename)
numberOfLines = len(fr.readlines()) #get the number of lines in the file
x = [] #prepare labels return
y = []
z = []
fr = open(filename)
index = 0
lineNum = 0
for line in fr.readlines():
line = line.strip()
listFromLine = line.split(',')
#print(listFromLine)
#returnMat[index,:] = listFromLine[0:1]
x.append(float(listFromLine[0])*-1)
y.append(float(listFromLine[1]))
z.append(float(listFromLine[2]))
#classLabelVector
index += 1
return x,y,z
x,y,z = file2matrix("../build/position.txt")
print( np.mean(x))
ax=plt.gca()
y_major_locator=MultipleLocator(10)
ax.yaxis.set_major_locator(y_major_locator)
plt.ylim(1250,1330)
plt.plot(x,'-')
plt.ylabel('x')
plt.show()