From 1b75fcbd5268e6e41ed43de7ced469eca14b6be2 Mon Sep 17 00:00:00 2001
From: Sergi Hernandez Juan <shernand@iri.upc.edu>
Date: Thu, 14 Jan 2021 12:26:24 +0100
Subject: [PATCH] Fix units

---
 src/model_car_batteries.cpp | 3 +--
 src/model_car_egomotion.cpp | 6 +++---
 2 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/src/model_car_batteries.cpp b/src/model_car_batteries.cpp
index 81dd081..7d4f52c 100644
--- a/src/model_car_batteries.cpp
+++ b/src/model_car_batteries.cpp
@@ -29,7 +29,6 @@ void CModelCarBatteries::process_data_frame(uint8_t id,uint32_t timestamp, TData
   else
   {
     it->second = data_union.voltage;
-    it->second.voltage = it->second.voltage/1000.0; //mV to V
     //m_bat_values[currentSensor] = data_union.us;
   }
 
@@ -47,7 +46,7 @@ bool CModelCarBatteries::get_bat(SENSOR_ID id, float & value)
   }
   else
   {
-    value = it->second.voltage;
+    value = it->second.voltage/1000.0; //mV to V
     ok=true; 
   }
   this->data_mutex.exit();
diff --git a/src/model_car_egomotion.cpp b/src/model_car_egomotion.cpp
index c894255..7b73862 100644
--- a/src/model_car_egomotion.cpp
+++ b/src/model_car_egomotion.cpp
@@ -27,9 +27,9 @@ void CModelCarEgomotion::process_data_frame(uint8_t id,uint32_t timestamp, TData
       this->imu.gx = this->imu.gx*3.14159/180; // º/s to rad/s
       this->imu.gy = this->imu.gy*3.14159/180; // º/s to rad/s
       this->imu.gz = this->imu.gz*3.14159/180; // º/s to rad/s
-      this->imu.mx = this->imu.mx/1e-7; //miliGauss(mG) to Tesla(T)
-      this->imu.my = this->imu.my/1e-7; //miliGauss(mG) to Tesla(T)
-      this->imu.mz = this->imu.mz/1e-7; //miliGauss(mG) to Tesla(T)
+      this->imu.mx = this->imu.mx*1e-7; //miliGauss(mG) to Tesla(T)
+      this->imu.my = this->imu.my*1e-7; //miliGauss(mG) to Tesla(T)
+      this->imu.mz = this->imu.mz*1e-7; //miliGauss(mG) to Tesla(T)
       break;
     default:
       std::cout << "CModelCarEgomotion::process_data_frame: error, incorrect id: " << (unsigned int)id << std::endl;
-- 
GitLab