[chronojump] fixed Inertia Momentum calculation time-distance since 1.6.1
- From: Xavier Padullés <xpadulles src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] fixed Inertia Momentum calculation time-distance since 1.6.1
- Date: Fri, 15 Jul 2016 11:49:08 +0000 (UTC)
commit f4a752e4f9c34c9ba87d6b5e6a49793ab85dc9e4
Author: Xavier Padullés <x padulles gmail com>
Date: Fri Jul 15 13:47:58 2016 +0200
fixed Inertia Momentum calculation time-distance since 1.6.1
encoder/inertia-momentum.R | 30 ++++++++++++++++++++----------
src/gui/encoder.cs | 5 ++---
src/utilEncoder.cs | 4 ++--
3 files changed, 24 insertions(+), 15 deletions(-)
---
diff --git a/encoder/inertia-momentum.R b/encoder/inertia-momentum.R
index f3ccc08..ed7fa93 100644
--- a/encoder/inertia-momentum.R
+++ b/encoder/inertia-momentum.R
@@ -35,10 +35,14 @@
#Measure weight
#Measure distance between centre of axis and centre of weight
-calculate <- function (displacement, mass, length)
+calculate <- function (displacement, mass, distance)
{
print("at inertia-momentum.R calculate")
+ print("mass = ")
+ print(mass)
+ print("distance = ")
+ print(distance)
#cumulative movement of the encoder
x <- cumsum(displacement)
#print(c("x",x))
@@ -53,20 +57,23 @@ calculate <- function (displacement, mass, length)
#times where the maximums are found in milliseconds
tmax <- rowMeans(ex$maxindex)
- print(c("tmax",tmax))
+ print("Time of maximums")
print(tmax)
+ #times where the minimums are found in milliseconds
tmin <- rowMeans(ex$minindex)
- print(c("tmin",tmin))
+ print("Time of minimums")
+ print(tmin)
tall = sort(as.numeric(c(tmin, tmax)))
- print("tall")
+ print("Times of minimums and maximums")
print(tall)
#the last maximum is discarded
#tmax <- tmax[1:(length(tmax)-1)]
#print(c("tmax",tmax))
tall <- tall[1:(length(tall)-1)]
+ print("With the last maximum discarded")
print(c("tall",tall))
#Periods of the oscillations
@@ -79,15 +86,18 @@ calculate <- function (displacement, mass, length)
#Coefficients of a Logarithmic regression
logT <- lm( log(T) ~ I(log(tall[1:(length(tall)-1)])))
- print(c("logT",logT))
+ print("-------Results of the logarithmic regression (logT)--------- ")
+ print(logT)
+ print("----------------End of the logarithmic regression----------- ")
#The final period of the oscillation in seconds
finalT <- exp(logT$coefficients[1] + logT$coefficients[2]*log(tall[length(tall)]))/1000
- print(c("finalT",finalT))
+ print(c("finalT = ",finalT))
#Inertia momentum using the pendulus formula
- I <- ( (finalT / (2 * pi))^2 ) * mass * 9.81 * length - (mass * length^2)
- print(c("I",I))
+
+ I <- ( (finalT / (2 * pi))^2 ) * mass * 9.81 * distance - (mass * distance^2)
+ print(c("I = ",I))
return(as.numeric(I))
}
@@ -104,14 +114,14 @@ options = scan(optionsFile, comment.char="#", what=character(), sep="\n")
fileInput = options[1]
fileOutput = options[2]
mass = as.numeric(options[3]) / 1000.0 # g -> Kg
-length = as.numeric(options[4]) / 100.0 #cm -> m
+distance = as.numeric(options[4]) / 100.0 #cm -> m
scriptUtilR = options[5]
source(scriptUtilR)
displacement = scan(file=fileInput, sep=",")
-inertia = calculate(displacement, mass, length)
+inertia = calculate(displacement, mass, distance)
print (inertia)
write(inertia, fileOutput)
diff --git a/src/gui/encoder.cs b/src/gui/encoder.cs
index 8ee6e44..124bcf8 100644
--- a/src/gui/encoder.cs
+++ b/src/gui/encoder.cs
@@ -2085,7 +2085,7 @@ public partial class ChronoJumpWindow
eCapture.InitGlobal(
encoder_capture_signal_drawingarea.Allocation.Width,
encoder_capture_signal_drawingarea.Allocation.Height,
- encoder_configuration_win.Spin_im_duration,
+ 120, //hardcoded 2 minutes. Old: encoder_configuration_win.Spin_im_duration,
(int) encoderCaptureOptionsWin.spin_encoder_capture_inactivity_end_time.Value,
false,
findEccon(true),
@@ -2102,8 +2102,7 @@ public partial class ChronoJumpWindow
if(capturedOk)
UtilEncoder.RunEncoderCalculeIM(
encoder_configuration_win.Spin_im_weight,
- //encoder_configuration_win.Spin_im_length,
- 120, //hardcoded two minutes, better than above because it's in
another window and maybe too low
+ encoder_configuration_win.Spin_im_length,
encoderRProcAnalyze
);
else
diff --git a/src/utilEncoder.cs b/src/utilEncoder.cs
index 6f50d22..a44f9ad 100644
--- a/src/utilEncoder.cs
+++ b/src/utilEncoder.cs
@@ -359,7 +359,7 @@ public class UtilEncoder
//Inertia Momentum
//TODO: make this work with encoderRProc
- public static void RunEncoderCalculeIM(double weight, double length, EncoderRProcAnalyze
encoderRProcAnalyze)
+ public static void RunEncoderCalculeIM(double weight, double distance, EncoderRProcAnalyze
encoderRProcAnalyze)
{
encoderRProcAnalyze.CancelRScript = false;
@@ -396,7 +396,7 @@ public class UtilEncoder
inputData + "\n" +
outputData + "\n" +
Util.ConvertToPoint(weight) + "\n" +
- Util.ConvertToPoint(length) + "\n" +
+ Util.ConvertToPoint(distance) + "\n" +
scriptUtilR + "\n";
string optionsFile = Path.GetTempPath() + "Roptions.txt";
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]