Page 1 of 1

Timestamp log entries?

Posted: Fri Oct 18, 2013 2:14 am
by andykee
I'm trying to figure out a way to timestamp log entries. I'm able to generate a client-side timestamp when each row in the log is written, but would much prefer to have the time when the sensor measurements were made. Is this something that I might be able to accomplish?

Thanks!

Re: Timestamp log entries?

Posted: Mon Oct 21, 2013 7:44 am
by tobias
The log packets are time-stamped in the FW in milliseconds but currently this is not used in the cfclient so it shouldn't be to difficult to implement it.

Re: Timestamp log entries?

Posted: Mon Nov 11, 2013 11:32 pm
by andykee
Do I need to add timestamp to the TOC? It seems like since it's always being written into the packet in the FW, I shouldn't need to, but when I print the contents of pk.data on the client, the timestamp isn't there.

Re: Timestamp log entries?

Posted: Fri Nov 15, 2013 9:36 am
by marcus
In the later version of the cflib and the crazyflie firmware the timestamp (in ms) is sent together with each logging packet. The callbacks for all the logging has changed so now you get the data and a timestamp for each log packet.

Re: Timestamp log entries?

Posted: Fri Nov 22, 2013 3:11 am
by andykee
I still can't get this working. As far as I can tell, I should be able to access the timestamp as follows (see the gyroData method):

Code: Select all

    # Callback called when the connection is established to the Crazyflie
    def connected(linkURI):
        gyroconf = LogConfig("Gyro", 10)
        gyroconf.addVariable(LogVariable("gyro.x", "float"))
        gyroconf.addVariable(LogVariable("gyro.y", "float"))
        gyroconf.addVariable(LogVariable("gyro.z", "float"))
 
        # crazyflie is an instance of the Crazyflie class that has been instantiated and connected
        gyrolog = crazyflie.log.newLogPacket(gyroconf)
 
        if (gyrolog != None):
            gyrolog.data_received.addCallback(gyroData)
            gyrolog.startLogging()
        else:
            print "gyro.x/y/z not found in log TOC"
 
    def gyroData(data, timestamp):
        print "Gyrodata: timestamp=%d  x=%.2f, y=%.2f, z=%.2f" % (timestamp, data["gyro.x"], data["gyro.y"], data["gyro.z"])
but the callback only seems to be sending 'data' and not 'timestamp' as well. I built and flashed the new FW. Where am I going wrong?

Re: Timestamp log entries?

Posted: Mon Nov 25, 2013 8:09 am
by marcus
You will also need the latest version of the cflib/cfclient that can be downloaded here otherwise the timestamp might be ignored.