Cannot save data Callback function
What I am really looking for is a way to save all value's message that a node receives (in a list, CSV file..) in a way that I can later do something with this values.
So this is data received :
I tried to put all these values in myData List:
def callback(data):
id = data.id
x = data.pose.x
y = data.pose.y
#print data
#list_x.append(x)
#print id ,x,y
goals={}
goals["x"]=x
goals["y"]=y
#print goals
myData=[goals]
print myData
but it's not what I want(Even with append) ! it put every value in a list like this :
Also, I tried to save this value in a CSV File :
with open('goals_point.csv', 'with') as csvFile:
writer = csv.writer(csvFile)
writer.writerows([myData])
csvFile.close()
it saves only the last value :
So how can I save collected messages (data)? Any idea?
Thanks for answering and for your time in advance,
Tayssir
Please don't use an image to display text. Images are not searchable and people cannot copy and paste the text from the image. Please see the support page