Преглед на файлове

Milliseconds in all logs

Marcel Zickler преди 3 години
родител
ревизия
cb230af2c6

+ 4 - 4
Assets/Scripts/Logging/BikeGameObjectDataLogger.cs

@@ -7,7 +7,7 @@ namespace Logging
 {
     public readonly struct BikeGameObjectDataLog
     {
-        private readonly float timestamp;
+        private readonly int timestamp;
         private readonly float positionX;
         private readonly float positionY;
         private readonly float positionZ;
@@ -18,7 +18,7 @@ namespace Logging
         private readonly float velocityY;
         private readonly float velocityZ;
 
-        public BikeGameObjectDataLog(float timestamp, float positionX, float positionY, float positionZ, float rotationX, float rotationY, float rotationZ, float velocityX, float velocityY, float velocityZ)
+        public BikeGameObjectDataLog(int timestamp, float positionX, float positionY, float positionZ, float rotationX, float rotationY, float rotationZ, float velocityX, float velocityY, float velocityZ)
         {
             this.timestamp = timestamp;
             this.positionX = positionX;
@@ -34,7 +34,7 @@ namespace Logging
 
         public string[] Serialize() => new[]
         {
-            timestamp.ToString("F4", CultureInfo.InvariantCulture),
+            timestamp.ToString("D", CultureInfo.InvariantCulture),
             positionX.ToString("F6", CultureInfo.InvariantCulture),
             positionY.ToString("F6", CultureInfo.InvariantCulture),
             positionZ.ToString("F6", CultureInfo.InvariantCulture),
@@ -65,7 +65,7 @@ namespace Logging
             var rot = bikeTransform.rotation.eulerAngles;
             var velocity = bike.velocity;
             
-            Log(new BikeGameObjectDataLog(Time.time,
+            Log(new BikeGameObjectDataLog(Mathf.RoundToInt(Time.time*1000),
                 pos.x, pos.y, pos.z,
                 rot.x, rot.y, rot.z,
                 velocity.x, velocity.y, velocity.z));

+ 10 - 10
Assets/Scripts/Logging/BikeSensorDataLogger.cs

@@ -8,16 +8,16 @@ using UnityEngine.TestTools;
 
 namespace Logging
 {
-    public class BikeSensorDataLog
+    public readonly struct BikeSensorDataLog
     {
-        private float timestamp;
-        private float speed;
-        private float cadence;
-        private int heartRate;
-        private float torque;
-        private float power;
+        private readonly int timestamp;
+        private readonly float speed;
+        private readonly float cadence;
+        private readonly int heartRate;
+        private readonly float torque;
+        private readonly float power;
 
-        public BikeSensorDataLog(float timestamp, float speed, float cadence, int heartRate, float torque, float power)
+        public BikeSensorDataLog(int timestamp, float speed, float cadence, int heartRate, float torque, float power)
         {
             this.timestamp = timestamp;
             this.speed = speed;
@@ -30,7 +30,7 @@ namespace Logging
         public string[] Serialize() =>
             new[]
             {
-                timestamp.ToString("F4", CultureInfo.InvariantCulture),
+                timestamp.ToString("D", CultureInfo.InvariantCulture),
                 speed.ToString("F4", CultureInfo.InvariantCulture), 
                 cadence.ToString("F4", CultureInfo.InvariantCulture), 
                 heartRate.ToString(),
@@ -58,7 +58,7 @@ namespace Logging
             var cadence = bikeSensorData.PowermeterData?.InstantaneousCadence ?? -1f;
             var power = bikeSensorData.PowermeterData?.InstantaneousPower ?? -1f;
             var torque = bikeSensorData.PowermeterData?.CrankTorque ?? -1f;
-            Log(new BikeSensorDataLog(Time.time, speed, cadence, hr, torque, power));
+            Log(new BikeSensorDataLog(Mathf.RoundToInt(Time.time*1000), speed, cadence, hr, torque, power));
         }
 
         public override void Log(BikeSensorDataLog value)

+ 4 - 4
Assets/Scripts/Logging/PolarAccDataLogger.cs

@@ -10,12 +10,12 @@ namespace Logging
 {
     public readonly struct PolarAccDataLog
     {
-        private readonly float timestamp;
+        private readonly int timestamp;
         private readonly float accX;
         private readonly float accY;
         private readonly float accZ;
 
-        public PolarAccDataLog(float timestamp, float accX, float accY, float accZ)
+        public PolarAccDataLog(int timestamp, float accX, float accY, float accZ)
         {
             this.timestamp = timestamp;
             this.accX = accX;
@@ -26,7 +26,7 @@ namespace Logging
         public string[] Serialize() =>
             new[]
             {
-                timestamp.ToString("F4", CultureInfo.InvariantCulture),
+                timestamp.ToString("D", CultureInfo.InvariantCulture),
                 accX.ToString("F4", CultureInfo.InvariantCulture),
                 accY.ToString("F4", CultureInfo.InvariantCulture),
                 accZ.ToString("F4", CultureInfo.InvariantCulture),
@@ -71,7 +71,7 @@ namespace Logging
 
             var internalTimestamp =
                 (data.Timestamp - startTimeAcc) / 1000000;
-            var timestamp = internalTimestamp + timeSync.DifDataStreamStart;
+            var timestamp = Mathf.RoundToInt(internalTimestamp + timeSync.DifDataStreamStart);
             foreach (var item in data.Values)
             {
                 Log(new PolarAccDataLog(timestamp, item.x, item.y, item.z));

+ 4 - 4
Assets/Scripts/Logging/PolarEcgDataLogger.cs

@@ -10,10 +10,10 @@ namespace Logging
 {
     public readonly struct PolarSensorEcgLog
     {
-        private readonly float timestamp;
+        private readonly int timestamp;
         private readonly float ecg;
 
-        public PolarSensorEcgLog(float timestamp, float ecg)
+        public PolarSensorEcgLog(int timestamp, float ecg)
         {
             this.timestamp = timestamp;
             this.ecg = ecg;
@@ -22,7 +22,7 @@ namespace Logging
         public string[] Serialize() =>
             new[]
             {
-                timestamp.ToString("F4", CultureInfo.InvariantCulture),
+                timestamp.ToString("D", CultureInfo.InvariantCulture),
                 ecg.ToString("F4", CultureInfo.InvariantCulture)
             };
     }
@@ -64,7 +64,7 @@ namespace Logging
 
             var internalTimestamp =
                 (data.Timestamp - startTime) / 1000000;
-            var timestamp = internalTimestamp + timeSync.DifDataStreamStart;
+            var timestamp = Mathf.RoundToInt(internalTimestamp + timeSync.DifDataStreamStart);
             foreach (var item in data.Values)
             {
                 Log(new PolarSensorEcgLog(timestamp, item));

+ 4 - 4
Assets/Scripts/Logging/ViveSensorDataLogger.cs

@@ -9,7 +9,7 @@ namespace Logging
 {
     public readonly struct ViveSensorDataLog
     {
-        private readonly float timestamp;
+        private readonly int timestamp;
         private readonly float steerAngle;
         private readonly float frontWheelTrackerPositionX;
         private readonly float frontWheelTrackerPositionY;
@@ -30,7 +30,7 @@ namespace Logging
         private readonly float hmdRotationY;
         private readonly float hmdRotationZ;
 
-        public ViveSensorDataLog(float timestamp, float steerAngle, float frontWheelTrackerPositionX,
+        public ViveSensorDataLog(int timestamp, float steerAngle, float frontWheelTrackerPositionX,
             float frontWheelTrackerPositionY, float frontWheelTrackerPositionZ, float frontWheelTrackerRotationX,
             float frontWheelTrackerRotationY, float frontWheelTrackerRotationZ, float kineticTrackerPositionX,
             float kineticTrackerPositionY, float kineticTrackerPositionZ, float kineticTrackerRotationX,
@@ -62,7 +62,7 @@ namespace Logging
 
         public string[] Serialize() => new[]
         {
-            timestamp.ToString("F6", CultureInfo.InvariantCulture),
+            timestamp.ToString("D", CultureInfo.InvariantCulture),
             steerAngle.ToString("F6", CultureInfo.InvariantCulture),
             frontWheelTrackerPositionX.ToString("F6", CultureInfo.InvariantCulture),
             frontWheelTrackerPositionY.ToString("F6", CultureInfo.InvariantCulture),
@@ -103,7 +103,7 @@ namespace Logging
             var hmdPosition = hmd.position;
             var hmdRotation = hmd.rotation.eulerAngles;
             //TODO: data always there?
-            Log(new ViveSensorDataLog(Time.time, steerAngle,
+            Log(new ViveSensorDataLog(Mathf.RoundToInt(Time.time * 1000), steerAngle,
                 fwtPosition.x, fwtPosition.y, fwtPosition.z,
                 fwtRotation.x, fwtRotation.y, fwtRotation.z,
                 kltPosition.x, kltPosition.y, kltPosition.z,