FreePie IMU receive

Official forum for open source FreePIE discussion and development.
Post Reply
o1113199
One Eyed Hopeful
Posts: 5
Joined: Sat Apr 01, 2017 7:05 am

FreePie IMU receive

Post by o1113199 »

Hello everyone, I can't figure out which buffer to accept from the FreePie IMU application for Android. Does anyone know?

The application sends a UDP packet containing accel, gyro, magnetometr and rotation, but I can't find the right buffer to get this data.

Source code https://github.com/Xtreamer/FreePie-Diy ... #L147-L174

Another app with receive this packet https://github.com/opentrack/opentrack/ ... ie-udp.cpp

As far as I understand, the first 2 bytes are the device index and flags. This is followed by a float array, I tried 6, 9, 12 values, but the data cannot be obtained correctly (except for the first two bytes).


Code: Select all

	struct _freePieIMUAndroid {
		unsigned char deviceIndex;
		unsigned char flags; //raw data = 1, orient = 2, both = 3
		float data[12]; ///?????
	};
I tried using double instead of float, but that didn't help either. Please help me find the right structure for UDP packet, thanks.
o1113199
One Eyed Hopeful
Posts: 5
Joined: Sat Apr 01, 2017 7:05 am

Re: FreePie IMU receive

Post by o1113199 »

I realized that it turns out there need to read the
unsigned char buff buffer[50];
the first 2 bytes are responsible for the index and flags, and then 4 bytes per value to convert need to use this function

float bytesToFloat(unsigned char b0, unsigned char b1, unsigned char b2, unsigned char b3)
{
unsigned char byte_array[] = { b3, b2, b1, b0 };
float result;
std::copy(reinterpret_cast<const char*>(&byte_array[0]),
reinterpret_cast<const char*>(&byte_array[4]),
reinterpret_cast<char*>(&result));
return result;
}

float AccelX = bytesToFloat(buff[5], buff[4], buff[3], buff[2]);
Post Reply

Return to “FreePIE”