Page 1 of 1

P2P Communication; how to send float Values?

Posted: Thu Dec 16, 2021 12:42 pm
by xStream
Hello Guys,
I have a problem regarding the Peer to Peer Communication of my Crazyflie Drones. I want the Drones to send P2P-Messages to eachother. The messages shall contain the x,y,z Positon estimated by the Kalman-Filter. I can obtain the Positions and print them to the console by useing DEBUG_PRINT(..). My Problem is that I cannot convert the float values to strings to send them via the P2P-Payload (common functions like sprintf, snprintf aren't working). Any suggestions?

Re: P2P Communication; how to send float Values?

Posted: Fri Dec 17, 2021 9:24 am
by kristoffer
Hi!

The P2PPacket contains a buffer you can write any data you like to, for instance something like this:

typedef struct {
float x;
float y;
float z;
} myType_t;

// Or use one of the types in stabilizer_types.h

// ...

myType_t myData;
myData.x = 17.0f;
myData.y = 47.0f;
myData.z = 11.0f;

memcpy(packet.data, &myData, sizeof(myData));
packet.size = sizeof(myData);

radiolinkSendP2PPacketBroadcast(&packet);