From 637a115e3ced62157bd81668ba440ca8ab559b11 Mon Sep 17 00:00:00 2001
From: darwin <darwin@darwin.users.iri.prv>
Date: Fri, 25 Aug 2017 00:02:01 +0200
Subject: [PATCH] Solved a problem with the sign of the accelerometer sensor.
 Chnaged the sign of the X axis of the gyroscope sensor.

---
 src/imu.c            | 2 +-
 src/motion_manager.c | 8 ++++----
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/src/imu.c b/src/imu.c
index e792585..bbaed72 100755
--- a/src/imu.c
+++ b/src/imu.c
@@ -258,7 +258,7 @@ void imu_accel_convert_data(uint8_t *data_in,uint8_t *data_out)
 
   for(i=0;i<3;i++)
   {
-    accel_data[i]=(data_in[i*2]+(data_in[i*2+1]<<8));
+    accel_data[i]=(int16_t)(data_in[i*2]+(data_in[i*2+1]<<8));
     data_out[i*2]=accel_data[i]%256;
     data_out[i*2+1]=accel_data[i]/256;
   }
diff --git a/src/motion_manager.c b/src/motion_manager.c
index 65f06bf..8faa546 100755
--- a/src/motion_manager.c
+++ b/src/motion_manager.c
@@ -149,10 +149,10 @@ void manager_balance(void)
     manager_balance_offset[R_ANKLE_PITCH]=((((int64_t)gyro_y*(int64_t)ankle_pitch_gain)/12000)>>9);    
     manager_balance_offset[L_KNEE]=((((int64_t)gyro_y*(int64_t)knee_gain)/12000)>>9);    
     manager_balance_offset[L_ANKLE_PITCH]=-((((int64_t)gyro_y*(int64_t)ankle_pitch_gain)/12000)>>9);
-    manager_balance_offset[R_HIP_ROLL]=-((((int64_t)gyro_x*(int64_t)hip_roll_gain)/12000)>>9);
-    manager_balance_offset[L_HIP_ROLL]=-((((int64_t)gyro_x*(int64_t)hip_roll_gain)/12000)>>9);
-    manager_balance_offset[R_ANKLE_ROLL]=((((int64_t)gyro_x*(int64_t)ankle_roll_gain)/12000)>>9);
-    manager_balance_offset[L_ANKLE_ROLL]=((((int64_t)gyro_x*(int64_t)ankle_roll_gain)/12000)>>9);
+    manager_balance_offset[R_HIP_ROLL]=((((int64_t)gyro_x*(int64_t)hip_roll_gain)/12000)>>9);
+    manager_balance_offset[L_HIP_ROLL]=((((int64_t)gyro_x*(int64_t)hip_roll_gain)/12000)>>9);
+    manager_balance_offset[R_ANKLE_ROLL]=-((((int64_t)gyro_x*(int64_t)ankle_roll_gain)/12000)>>9);
+    manager_balance_offset[L_ANKLE_ROLL]=-((((int64_t)gyro_x*(int64_t)ankle_roll_gain)/12000)>>9);
   }
   // fall detection (using accelerometer)
   imu_get_accel_data(&accel_x,&accel_y,&accel_z);
-- 
GitLab