Hallo,
I successfully launched the teapot demo and loaded some sensor data into Matlab but now I want to use C++ to get the sensor data. Unfortunately, I am new to C++ programming, so all the code that is given with the MotionFit SDK looks totally confusing to me. Can anyone give a minimal C++-code example to receive the sensor data? Thanks a lot in advance!
- Log in to post comments
phpbb Topic ID
15291
Re: Re: Receiving data from MPU-9150 using C++
eMPL is written such that it will support various platforms and InvenSense devices from a single library. This can add a bit of complexity. Have you tried taking a look at the teapot C++ or python example application within the MotionFit download? That would give you an example of parsing code for that platform.
Re: Re: Receiving data from MPU-9150 using C++
As I'm also not familiar with python I took a look at the teapot example but I got confused because there was so much code which did not seem to be necessary for only reading the data. I thought for a first start it would be easier to just setup a virtual serial port, read the data and save it to a file. But I don't know how to do this. :(
Re: Re: Receiving data from MPU-9150 using C++
A good approach might be to start working from the python or C applications, and edit the processing as required for your application. You can find, search, or remove components of the application that aren't required.
Re: Re: Receiving data from MPU-9150 using C++
Now, I can stream the data, but I want to get only Euler angles. So I sent "inve" bite-wise. Then I received quaternions, Euler angles and something different with an unknown header. If I run the program again, only quaternions are sent. I think it's not such a good solution to first read some data and search for Euler angles in order to decide whether the "inve"-command should be sent or not. I thought I could reset the device with "invx" on every start-up but that didn't seem to work. What exactly does this reset-command do? Can I suppress the quaternion output at all? What would be the most elegant way to receive only Euler angles?
Re: Re: Receiving data from MPU-9150 using C++
You can look through the handle_input() function within the main file of the embedded project for details on what operations are performed on incoming serial data. The developer kit is meant to be reprogrammed with data per your application, in the case you'd like to change the Euler angle output (such as to force it to be the default always-on output of the device).
Re: Re: Receiving data from MPU-9150 using C++
As I didn't want to change the firmware, I decided to ignore quaternions and use only Euler angles for my application. For a first try I wanted to control a mouse cursor via head movements but then I recognized a slow but steady drift for the yaw angle. Looked as if the magnetometer data was not used. Is this the case (I am using the MPU-9150 MotionFit Wireless SDK)? If so, is there a possibility to enable 9-axis sensor fusion without changing the firmware? Actually, I am a little bit confused because the description of the MPU-9150 says
and which made me think 9-axis sensor fusion was the standard..? - And also the intention in using a 9-axis sensor module. I think these descriptions are misleading, especially for non-native speakers like me.Re: Re: Receiving data from MPU-9150 using C++
The MotionFit board uses a magnetic calibration algorithm that runs always in the background. IT collects magnetometer data while the device is in motion, and after approximately 10-30 seconds of moving the device, will estimate the hard iron present in your current location, then beging to output 9 axis sensor data. If you are operating in a clean environment, just turn on the board, then rotate it slowly for roughly 10 seconds, then the device should be able to calibrate and show the 9 axis orientation. If your magnetic environment is noisy, or the device is coming straight out of reset, then it will default to a 6 axis orientation.