Skip to content

Commit 66c7b9d

Browse files
committed
Never forget the concept of vectors now, huh?
Unit vectors with offsets close to zero are literally monsters!
1 parent 33d27f4 commit 66c7b9d

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/MPU6050.cpp

+5-1
Original file line numberDiff line numberDiff line change
@@ -3424,7 +3424,11 @@ void MPU6050_Base::PID(uint8_t ReadAddress, float kP,float kI, uint8_t Loops){
34243424
v_rawG.x = rawG[0];
34253425
v_rawG.y = rawG[1];
34263426
v_rawG.z = rawG[2];
3427-
v_normG = v_rawG.getNormalized();
3427+
if (v_rawG.getMagnitude() < gravity) {
3428+
// do nothing
3429+
}else {
3430+
v_normG = v_rawG.getNormalized();
3431+
}
34283432
Reading[0] -= gravity * v_normG.x; //remove Gravity
34293433
Reading[1] -= gravity * v_normG.y;
34303434
Reading[2] -= gravity * v_normG.z;

0 commit comments

Comments
 (0)