Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

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 :

image description

I tried to put all these values in myData List:

image description

but it's not what I want(Even with append) ! it put every value in a list like this :

image description

Also, I tried to save this value in a CSV File :

image description

it saves only the last value :

image description

So how can I save collected messages (data)? Any idea?

Thanks for answering and for your time in advance,

Tayssir

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 :

image description

I tried to put all these values in myData List:

image description

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 :

image description

Also, I tried to save this value in a CSV File :

image description

with open('goals_point.csv', 'with') as csvFile:
       writer = csv.writer(csvFile)
       writer.writerows([myData])
       csvFile.close()

it saves only the last value :

image description

So how can I save collected messages (data)? Any idea?

Thanks for answering and for your time in advance,

Tayssir