Logging more than 6 Parameters at once

Post here to get support
Post Reply
jjan3640
Beginner
Posts: 6
Joined: Tue Mar 30, 2021 4:18 am

Logging more than 6 Parameters at once

Post by jjan3640 »

I am currently trying to log the 7 parameters listed below using

Code: Select all

LogConfig(name='Parameters', period_in_ms=10)
however it seems as though it is unable to log more than 6 parameters at a time. I remember seeing an error message saying that there are too many parameters however now that I am trying to recreate the error message it is not coming up (the logging is still not working however).

- X position: (stateEstimate.x, float)
- Y position: (stateEstimate.y, float)
- Z position: (stateEstimate.z, float)
- Roll: (stabilizer.roll, float)
- Pitch: (stabilizer.pitch, float)
- Yaw: (stabilizer.yaw, float)
- Battery voltage: (pm.vbat, float)

Is there a way to effectively log more than 6 parameters at a time for the Crazyflie?
arnaud
Bitcraze
Posts: 2463
Joined: Tue Feb 06, 2007 12:36 pm

Re: Logging more than 6 Parameters at once

Post by arnaud »

This is a limitation of the log subsytem: one log block must be contained in one radio packet and the radio packets are 32bytes long, when removing timestamp and other required data there is about 27bytes available, so 6 float plus a 3 bytes.

That said, the Crazyflie has a functionality to convert variables before packing them in the packet. The most useful for you would be to convert one (or more) variable to FP16, for example be vattery, in Python this is setup with "add_variable('pm.vbat', 'FP16')". FP16 is half-precision floating points, it only uses 2 bytes and it has about 3 decimal digit of precision so it is good enough for vbat and it will still be OK for the attitude angles. It might become problematic for X-Y-Z in a big space though.

The problem was that until now, FP16 was not decoded by the lib. However, since Python 3.6, python is apparently able to decode fp16 numbers to I just pushed a fix to the lib and I modified the basiclog example to log your packet (it is a good example of why fp16 is useful): https://github.com/bitcraze/crazyflie-l ... py#L75-L84.
jjan3640
Beginner
Posts: 6
Joined: Tue Mar 30, 2021 4:18 am

Re: Logging more than 6 Parameters at once

Post by jjan3640 »

Ah that makes a lot of sense. Thank you very much for the reply.
arnaud
Bitcraze
Posts: 2463
Joined: Tue Feb 06, 2007 12:36 pm

Re: Logging more than 6 Parameters at once

Post by arnaud »

Sure! One added note: you can setup more than one log block, so the normal way to log more than 6 floats is to setup multiple log blocks. However, being able to log as much as possible in a single block is more efficient and can be more practical, so its nice FP16 finaly works all the way.
Post Reply