miniben-90 / mpu9250

A node.js library for communicating with the MPU9250.
22 stars 16 forks source link

Few questions #11

Closed Guttata closed 6 years ago

Guttata commented 6 years ago

Hi,

First of all thanks a lot for the library.

There is an akward behaviour: mpu.initialize() seems to return false so this code won't print value.

if (myCar.Accelerometer.initialize()) {
    console.log("MPU INIT SUCCESS");

setInterval(function(){
    var values = myCar.Accelerometer.getMotion9();
    var pitch = myCar.Accelerometer.getPitch(values);
    var roll = myCar.Accelerometer.getRoll(values);
    var yaw = myCar.Accelerometer.getYaw(values);
    console.log('pitch value : ', pitch);
    console.log('roll value : ', roll);
    console.log('yaw value : ', yaw);
}, 200);    
}

But this is working:

if (myCar.Accelerometer.initialize()) {
    console.log("MPU INIT SUCCESS");    
}

setInterval(function(){
    var values = myCar.Accelerometer.getMotion9();
    var pitch = myCar.Accelerometer.getPitch(values);
    var roll = myCar.Accelerometer.getRoll(values);
    var yaw = myCar.Accelerometer.getYaw(values);
    console.log('pitch value : ', pitch);
    console.log('roll value : ', roll);
    console.log('yaw value : ', yaw);
}, 200);

Here is the debug display:

BEFORE MPU INIT
[INFO][15:9 11/3/2018]:Initialization MPU9250 ....
[INFO][15:9 11/3/2018]:Reset configuration MPU9250.
[INFO][15:9 11/3/2018]:Enabled magnetometer. Starting initialization ....
[INFO][15:9 11/3/2018]:END of magnetometer initialization.
[INFO][15:9 11/3/2018]:END of MPU9150 initialization.
[INFO][15:9 11/3/2018]:MPU9250:
[INFO][15:9 11/3/2018]:--> Device address: 0x68
[INFO][15:9 11/3/2018]:--> i2c bus: /dev/i2c-1
[INFO][15:9 11/3/2018]:--> Device ID: 0x73
[INFO][15:9 11/3/2018]:--> BYPASS enabled: Yes
[INFO][15:9 11/3/2018]:--> SleepEnabled Mode: Off
[INFO][15:9 11/3/2018]:--> i2c Master Mode: Disabled
[INFO][15:9 11/3/2018]:--> Power Management (0x6B, 0x6C):
[INFO][15:9 11/3/2018]:  --> Clock Source: 1 (Auto selects the best available clock source)
[INFO][15:9 11/3/2018]:  --> Accel enabled (x, y, z): (Yes, Yes, Yes)
[INFO][15:9 11/3/2018]:  --> Gyro enabled (x, y, z): (Yes, Yes, Yes)
[INFO][15:9 11/3/2018]:Accelerometer:
[INFO][15:9 11/3/2018]:--> Full Scale Range (0x1C): ±4g (1)
[INFO][15:9 11/3/2018]:--> Scalar: 1/1
[INFO][15:9 11/3/2018]:--> Calibration:
[INFO][15:9 11/3/2018]:  --> Offset:
[INFO][15:9 11/3/2018]:    --> x: 0
[INFO][15:9 11/3/2018]:    --> y: 0
[INFO][15:9 11/3/2018]:    --> z: 0
[INFO][15:9 11/3/2018]:  --> Scale:
[INFO][15:9 11/3/2018]:    --> x: -1,1
[INFO][15:9 11/3/2018]:    --> y: -1,1
[INFO][15:9 11/3/2018]:    --> z: -1,1
[INFO][15:9 11/3/2018]:Gyroscope:
[INFO][15:9 11/3/2018]:--> Full Scale Range (0x1B): +250dps (0)
[INFO][15:9 11/3/2018]:--> Scalar: 1/1
[INFO][15:9 11/3/2018]:--> Bias Offset:
[INFO][15:9 11/3/2018]:  --> x: 0
[INFO][15:9 11/3/2018]:  --> y: 0
[INFO][15:9 11/3/2018]:  --> z: 0
[INFO][15:9 11/3/2018]:Magnetometer (Compass):
[INFO][15:9 11/3/2018]:--> i2c address: 0xc
[INFO][15:9 11/3/2018]:--> Device ID: 0x48
[INFO][15:9 11/3/2018]:--> Mode: 0x06 (Continuous measurement mode 2: 100Hz)
[INFO][15:9 11/3/2018]:--> Scalars:
[INFO][15:9 11/3/2018]:  --> x: 1
[INFO][15:9 11/3/2018]:  --> y: 1
[INFO][15:9 11/3/2018]:  --> z: 1

Do you have an idea ?

Why the getYaw is a 'return 0; ' ? Is it possible to implement it ?

Thanks a lot for your help.

miniben-90 commented 6 years ago

Hello, No is not possible to implement it. You have to use the magnetometer if you want have yaw values or use some mathematical formula to predict this one. ref: #8