Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
Super Contributor
lyon819
Posts: 253
Registered: ‎08-19-2010
My Device: BB10, Playbook, 9900, 9800, 9700, 9550, 9530, 9500, 8700.

The sensor_event_get is not synchronized.

Purpose: Get raw acceleration, orientatioon, linear acceleration sensor in the same time.

 

Problem: Raw acceleration is always ahead of other sensors data about 157 milliseconds.

                  Linear acceleration time are synchronized with orientation data time, these data time are the same. Only 1milliseconds difference or less. However, these data have 157 milliseconds difference from the time of raw acceleration.

 

Question: Is the situation normal for raw acceleration or how could I make synchronization for the time of raw acceleration and other data time (e.g. sleep or others)??

 

The minimum coding is at below.

static const int ACCELEROMETER_RATE, AZIMUTH_PITCH_ROLL_RATE,  GRAVITY_RATE= 25000;

 

sensor_set_rate(SENSOR_TYPE_ACCELEROMETER, ACCELEROMETER_RATE);
sensor_set_skip_duplicates(SENSOR_TYPE_ACCELEROMETER, true);

sensor_set_rate(SENSOR_TYPE_AZIMUTH_PITCH_ROLL, AZIMUTH_PITCH_ROLL_RATE);
sensor_set_skip_duplicates(SENSOR_TYPE_AZIMUTH_PITCH_ROLL, true);

sensor_set_rate(SENSOR_TYPE_GRAVITY, GRAVITY_RATE);
sensor_set_skip_duplicates(SENSOR_TYPE_GRAVITY, true);

 

sensor_request_events(SENSOR_TYPE_ACCELEROMETER);
sensor_request_events(SENSOR_TYPE_AZIMUTH_PITCH_ROLL);
sensor_request_events(SENSOR_TYPE_GRAVITY);

 

if (bps_event_get_code(event) == SENSOR_ACCELEROMETER_READING) {
    sensor_event_get_xyz(event, &force_x, &force_y, &force_z);
    pthread_create(&t1, NULL, (void*) &rawacceleration, NULL);

if (bps_event_get_code(event) == SENSOR_AZIMUTH_PITCH_ROLL_READING) {
    sensor_event_get_apr(event, &azimuth, &pitch, &roll);

    pthread_create(&t3, NULL, (void*) &rawothersen, NULL);
}
if (bps_event_get_code(event) == SENSOR_GRAVITY_READING) {
    sensor_event_get_xyz(event, &x_gravity, &y_gravity, &z_gravity);
    pthread_create(&t4, NULL, (void*) &gravrawacceleration,
}

 

Thanks yor attention.

 

 

 

-Fight with BB10
Please use plain text.
Retired
psapra
Posts: 74
Registered: ‎07-22-2008
My Device: BlackBerry Z10

Re: The sensor_event_get is not synchronized.

I have passed on your question to our sensors team and they will respond back here.

 

Thanks,
Pratik Sapra
Gaming & Apps Consultant
Developer Relations
@pratiksapra
Please use plain text.
Retired
aparco
Posts: 15
Registered: ‎10-11-2012
My Device: BlackBerry Z10

Re: The sensor_event_get is not synchronized.

Hi lyon819,

 

What you are seeing is expected. The SENSOR_TYPE_ACCELEROMETER is an unfused type, meaning that the data is generated by 1 sensor and sent to clients directly. The SENSOR_TYPE_AZIMUTH_PITCH_ROLL and SENSOR_TYPE_GRAVITY are fused types, meaning that the data is generated from 2 or more sensors. The sensor data is sent through motion processing libraries and then sent to the client. All fused types should be synchronized together, while all unfused (raw) types are synchronized to themselves only.

 

Can I ask what you are working on?  There might be an easier alternative then using these 3 types, as they contain a lot of redundant information.

 

Also, on a side note:  I see that you are making a thread to handle each sensor type.  This would cause synchronization issues on its own.  It is also un-needed and resource intensive.  I would suggest having a single event loop.

 

Thanks,

Adma.

 

Please use plain text.
Super Contributor
lyon819
Posts: 253
Registered: ‎08-19-2010
My Device: BB10, Playbook, 9900, 9800, 9700, 9550, 9530, 9500, 8700.

Re: The sensor_event_get is not synchronized.

Thanks aparco.

 

I already met sychninzation issue 2 days ago, so I make single thread to collect all raw sensor data.

 

I am working on to get all sensor_type data in one log.

If the BB10 has two kinds of sensor generation models, I will create two log to seperate them.

 

Fused:smileyfrustrated:ENSOR_TYPE_AZIMUTH_PITCH_ROLL, SENSOR_TYPE_GRAVITY

 

Unfused: SENSOR_TYPE_ACCELEROMETER

 

Could you tell me what kind of sensor_type is fused, and unfused?

 

SENSOR_TYPE_GYROSCOPE, SENSOR_TYPE_LIGHT, SENSOR_TYPE_LINEAR_ACCEL, SENSOR_TYPE_MAGNETOMETER, SENSOR_TYPE_ORIENTATION, SENSOR_TYPE_PROXIMITY,

SENSOR_TYPE_ROTATION_MATRIX.

 

Thanks again,

 

-Fight with BB10
Please use plain text.
Retired
aparco
Posts: 15
Registered: ‎10-11-2012
My Device: BlackBerry Z10

Re: The sensor_event_get is not synchronized.

As motion processing algorithms are always evolving and changing, this information might not be correct in the future.

 

Unfused raw motion sensors:

SENSOR_TYPE_ACCELEROMETER = 0
SENSOR_TYPE_MAGNETOMETER = 1
SENSOR_TYPE_GYROSCOPE = 2

 

fused motion sensors:
SENSOR_TYPE_AZIMUTH_PITCH_ROLL = 3
SENSOR_TYPE_GRAVITY = 8
SENSOR_TYPE_LINEAR_ACCEL = 9
SENSOR_TYPE_ROTATION_VECTOR = 10
SENSOR_TYPE_ROTATION_MATRIX = 11
SENSOR_TYPE_ORIENTATION = 12

 

ambient sensors (contains some form of pre-processing):

SENSOR_TYPE_ALTIMETER = 4 
SENSOR_TYPE_TEMPERATURE = 5 
SENSOR_TYPE_PROXIMITY = 6 
SENSOR_TYPE_LIGHT = 7 

SENSOR_TYPE_FACE_DETECT = 13

Please use plain text.