Timestamp log entries?

Firmware/software/electronics/mechanics
Post Reply
andykee
Beginner
Posts: 8
Joined: Tue Oct 08, 2013 1:43 am
Location: San Diego, CA
Contact:

Timestamp log entries?

Post 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!
Crazyflie system identification (Master's thesis): https://github.com/andykee/uclathesis
tobias
Bitcraze
Posts: 2339
Joined: Mon Jan 28, 2013 7:17 pm
Location: Sweden

Re: Timestamp log entries?

Post 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.
andykee
Beginner
Posts: 8
Joined: Tue Oct 08, 2013 1:43 am
Location: San Diego, CA
Contact:

Re: Timestamp log entries?

Post 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.
Crazyflie system identification (Master's thesis): https://github.com/andykee/uclathesis
marcus
Bitcraze
Posts: 659
Joined: Mon Jan 28, 2013 7:02 pm
Location: Sweden
Contact:

Re: Timestamp log entries?

Post 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.
andykee
Beginner
Posts: 8
Joined: Tue Oct 08, 2013 1:43 am
Location: San Diego, CA
Contact:

Re: Timestamp log entries?

Post 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?
Crazyflie system identification (Master's thesis): https://github.com/andykee/uclathesis
marcus
Bitcraze
Posts: 659
Joined: Mon Jan 28, 2013 7:02 pm
Location: Sweden
Contact:

Re: Timestamp log entries?

Post by marcus »

You will also need the latest version of the cflib/cfclient that can be downloaded here otherwise the timestamp might be ignored.
Post Reply