I am using the XDK to prototype traking of orientation for a handheld device that we are developing. I have been using the VirtualSensor_GetRotationData() function to get a ROTATION_QUATERNION and that has worked really well. Now I would like to get the actual sensor data that is used to create the ROTATION_QUATERNION so that I can run it through filters of our own and I am trying to understand the best way to do that.

It appears to me that since I already have a VirtualSensor, I can just call the VirtualSensor_GetCalibratedAccel(), VirtualSensor_GetCalibratedGyro() and VirtualSensor_GetCalibratedMag() functions to return the scaled x,y,z data for each sensor to run through whatever filters (Madgwick, Complimentary, etc) that I desire. Is this correct?

Also where can I find out what the default sensor setup parameters are? In my initial code I just called VirtualSensor_Setup() with a setup structure of:

static Sensor_Setup_T SensorSetup =
        {
                .CmdProcessorHandle = NULL,
                .Enable =
                        {
                                .Accel = true,
                                .Mag = true,
                                .Gyro = true,
                                .Humidity = false,        //true,
                                .Temp = false,            //true,
                                .Pressure = false,        //true,
                                .Light = true,
                                .Noise = false,            //true,
                        },
                .Config =
                        {
                                .Accel =
                                        {
                                                .Type = SENSOR_ACCEL_BMA280,
                                                .IsRawData = false,
                                                .IsInteruptEnabled = true,
                                                .Callback = AccelAppCallback,
                                        },
                                .Gyro =
                                        {
                                                .Type = SENSOR_GYRO_BMG160,
                                                .IsRawData = false,
                                        },
                                .Mag =
                                        {
                                                .IsRawData = false,
                                        },
                                .Light =
                                        {
                                                .IsInteruptEnabled = true,
                                                .Callback = LightAppCallback,
                                        },
//                                .Temp =
//                                        {
//                                                .OffsetCorrection = APP_TEMPERATURE_OFFSET_CORRECTION,
//                                        },
                        },
        };/**< Sensor setup parameters */

 

but this doesn't tell me what data range, data rate, etc. is being used. Where can I find that information?

 

0 (0 Votes)
RE: How to get sensor data for Virtual sensor
Answer
1/9/19 4:56 PM as a reply to Larry Cook.
Dear Larry,

First, I would like to welcome you to the XDK community.

To answer your question, you can, of course, run the sensor data you receive from the functions VirtualSensor_GetCalibratedAccel() , VirtualSensor_GetCalibratedGyro() and VirtualSensor_GetCalibratedMag() through any filter you desire to make further analysis.

For setting up the sensor ranges and bandwidth you can reference the sensor article .
If you have not found what you need in the guides you can also search template proposal in the sensor by pressing
ctrl + space.
You can also follow declarations by highlighting the sensorsetup and pressing F3 or
rightclicking -> open declaration , this will show you the correspoding source code.

I hope this was helpful, if you have further questions do not hesitate to ask.

Kind regards,
Franjo
0 (0 Votes)
RE: How to get sensor data for Virtual sensor
Answer
1/9/19 6:24 PM as a reply to Franjo Stjepandic.

Franjo,

Thank you for the information and the quick response. I will give these fucntion a try and also take a look at the referenced article.

I would also like to say that I have been following this message board for several months and have found the information contained in it very useful. It is one of the better support forums I have ever seen.

Thank you for your efforts.

Larry

+1 (1 Vote)
RE: How to get sensor data for Virtual sensor
Answer
1/10/19 3:59 PM as a reply to Larry Cook.
Dear Larry,

I am always glad to help and thank you for the positive feedback. We are glad to hear that the information, we hope to provide in great detail, is very useful.

Please feel free to ask if you have any kind of further concern or question.

Kind regards,
Franjo
0 (0 Votes)
RE: How to get sensor data for Virtual sensor
Answer
1/23/19 7:22 PM as a reply to Franjo Stjepandic.

Franjo,

I just got back to this and what I thought was true is in fact true. According to the header file for VirtualSensor_Setup() "only one sensor should be enabled" and when I look at the source for the function only the first enabled sensor that it finds in the VirtualSensor_Setup_T structure is actually enabled and setup.

So I am back to how do I get the sensor information that the Rotation virtual sensor is using to calculate its ROTATION_QUATERNION? I want that sensor data so that I can compare the XDK output with a Madgwick filter that I am attempting to use.

So, is it possible to read the scaled sensor values from the XDK that the VirtualSensor is using? Or do I have to read the raw value, offset them and scale them myself?

Also, do you know how the Rotation virtual sensor is calculating the quaternion that it is returning? Does it use some form of Madgwick or Kalman or ...?

 

Thanks,

Larry

0 (0 Votes)
RE: How to get sensor data for Virtual sensor
Answer
1/24/19 3:22 PM as a reply to Larry Cook.
Dear Larry,

The calibrated sensors and the orientation sensor are features, which are based on the magnetometers BMM150 and BMI160.

The orientation sensor, in fact, uses the combined data from both sensors for acceleration, angular velocity and the magnitude of the magnetic field in combination with the sensor fusion algorithms, which are provided by the BSX library in the Libraries folder of the XDK-Workbench.

Furthermore, I can, unfortunately, not tell exactly which algorithms and filters come into account since the calibrated sensors, as well as the BSX library, are shipped as precompiled .a archive files.

From quick research about the BSX library, I assume that a Kalman filter is used to calculate the orientation values. Since the libraries are enclosed, you do not have the possibility to read out the data that is processed internally by the virtual sensor API.

But while the BMM150 and the BMI160 are used and already initialized, you can read their raw data, which is passed to the virtual sensor API, with the corresponding reading functions from the interfaces BCDS_Accelerometer.h , BCDS_Gyroscope.h and BCDS_Magnetometer.h .

In that regard, could you please go more into detail about the sensor you need for your calculations? Are you interested in the raw data provided by the sensors and passed to the virtual sensor API or are you interested in the partial processed internal data of the API?

Please let me know if this was helpful and feel free to ask if you have further questions.

Kind regards,
Franjo
0 (0 Votes)