Page 1 of 1

commander values for the crazyflie problem

Posted: Tue Jan 27, 2015 2:18 pm
by zeerou
Hello,

I'm working on crazyflie controlled by hand gestures using Kinect developing under c#, and i ran into a big problem.

For setting thrust there is no problem, but if i want to set any of the others 4byte values, the crazycopter wents literally crazy. It reacts to different values, different ways and i havent found any link between them.

My question is, what values is crazyflie meant to receive? is it ok to be floating point data type (float) or integer datatype (like ushort at thrust)? Are there any bounds for the values?

Or am I missing some knowledge? Are the sent values considered as incremental or absolute for the copter?

Thank you for time, iam adding a c# code of my value serialization to packet.

Code: Select all

 MemoryStream buffer = new MemoryStream();
            BinaryWriter bw = new BinaryWriter(buffer);
          
            byte[] roll = floatToByteArray(Roll);
            byte[] pitch = floatToByteArray(-Pitch);
            byte[] yaw = floatToByteArray(Yaw);
            byte[] thrust = BitConverter.GetBytes(Thrust).Reverse().ToArray();

            bw.Write(roll);
            bw.Write(pitch);
            bw.Write(yaw);
            bw.Write(thrust);

            bw.Flush();
            bw.Close();
            buffer.Flush();
            byte[] result = buffer.ToArray();

Re: commander values for the crazyflie problem

Posted: Tue Jan 27, 2015 2:57 pm
by arnaud
Hi,

The commander packet structure is documented here: http://wiki.bitcraze.se/projects:crazyf ... :commander

Pitch and roll are absolute setpoint for the platform orientation in degrees. Yaw is the rotation rate in degree per second. All float are IEEE single precision float sent in little endian format.

The description of your problem sounds like a wrong floating point encoding.

Your code look correct, though you can double-check the endianness. I link the python implementation of the packing, it could help: https://github.com/bitcraze/crazyflie-c ... der.py#L73

On the other side this structure is unpacking the values in Crazyflie: https://github.com/bitcraze/crazyflie-f ... nder.c#L37

Hope this helps