[chronojump] gearedDown <-> gearedUp also on R inertial
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] gearedDown <-> gearedUp also on R inertial
- Date: Fri, 26 Feb 2016 18:01:48 +0000 (UTC)
commit 0a69cc69e6d793f8d400686bb610f885cbe8e665
Author: Xavier de Blas <xaviblas gmail com>
Date: Fri Feb 26 18:59:29 2016 +0100
gearedDown <-> gearedUp also on R inertial
encoder/capture.R | 3 +-
encoder/graph.R | 11 ++-
encoder/util.R | 24 ++++--
glade/chronojump.glade | 180 +++++++++++++++++++++++++++++++++++++--
src/encoder.cs | 82 ++++++++++++++++--
src/gui/encoderConfiguration.cs | 23 ++++-
6 files changed, 297 insertions(+), 26 deletions(-)
---
diff --git a/encoder/capture.R b/encoder/capture.R
index fb36999..1cab715 100644
--- a/encoder/capture.R
+++ b/encoder/capture.R
@@ -204,7 +204,8 @@ doProcess <- function(options)
if(isInertial(op$EncoderConfigurationName))
{
diametersPerTick = getInertialDiametersPerMs(displacement, op$diameter)
- displacement = getDisplacementInertial(displacement, op$EncoderConfigurationName,
diametersPerTick, op$diameterExt)
+ displacement = getDisplacementInertial(displacement, op$EncoderConfigurationName,
+ diametersPerTick, op$diameterExt,
op$gearedDown)
#need to do this before getDisplacementInertialBody cuts the curve: /|\
positionTemp = cumsum(displacement)
diff --git a/encoder/graph.R b/encoder/graph.R
index fcde238..53970ac 100644
--- a/encoder/graph.R
+++ b/encoder/graph.R
@@ -2270,7 +2270,8 @@ doProcess <- function(options)
if(isInertial(inputMultiData$econfName[i])) {
dataTempFile = getDisplacementInertial(
dataTempFile,
inputMultiData$econfName[i],
- inputMultiData$econfd[i],
inputMultiData$econfD[i])
+ inputMultiData$econfd[i],
inputMultiData$econfD[i],
+ inputMultiData$gearedDown[i] )
#getDisplacementInertialBody is not needed because it's done on curve save
} else {
dataTempFile = getDisplacement(inputMultiData$econfName[i], dataTempFile,
op$diameter, op$diameterExt)
@@ -2319,7 +2320,7 @@ doProcess <- function(options)
econfAnglePush[(i+newLines)] = inputMultiData$econfAnglePush[i]
econfAngleWeight[(i+newLines)] = inputMultiData$econfAngleWeight[i]
econfInertia[(i+newLines)] = inputMultiData$econfInertia[i]/10000.0 #comes in
Kg*cm^2 eg: 100; convert it to Kg*m^2 eg: 0.010
- econfGearedDown[(i+newLines)] = inputMultiData$econfGearedDown[i]
+ econfGearedDown[(i+newLines)] =
readFromFile.gearedDown(inputMultiData$econfGearedDown[i])
curvesHeight[(i+newLines)] = sum(dataTempPhase)
@@ -2389,7 +2390,9 @@ doProcess <- function(options)
if(isInertial(op$EncoderConfigurationName))
{
diametersPerMs = getInertialDiametersPerMs(displacement, op$diameter)
- displacement = getDisplacementInertial(displacement, op$EncoderConfigurationName,
diametersPerMs, op$diameterExt)
+ displacement = getDisplacementInertial(displacement, op$EncoderConfigurationName,
+ diametersPerMs, op$diameterExt, op$gearedDown)
+
displacement = getDisplacementInertialBody(0, displacement, curvesPlot, op$Title)
#positionStart is 0 in graph.R. It is different on capture.R because depends on the
start of every repetition
@@ -2475,8 +2478,10 @@ doProcess <- function(options)
}
text(x=((curves[i,1]+curves[i,2])/2/1000), #/1000 ms -> s
y=myY,labels=myLabel, adj=c(0.5,adjVert),cex=.9,col="blue")
+
arrows(x0=(curves[i,1]/1000),y0=myY,x1=(curves[i,2]/1000), #/1000 ms -> s
y1=myY, col="blue",code=0,length=0.1)
+
#mtext(at=((curves[i,1]+curves[i,2])/2/1000), #/1000 ms -> s
# side=1,text=myLabel, cex=.8, col="blue")
abline(v=c(curves[i,1],curves[i,2])/1000, lty=3, col="gray")
diff --git a/encoder/util.R b/encoder/util.R
index f362fd4..2885eb8 100644
--- a/encoder/util.R
+++ b/encoder/util.R
@@ -27,7 +27,7 @@
#it can be printed safely to stderr. See end capture.R
#used in graph.R and capture.R
-assignOptions <- function(options) {
+assignOptions <- function(options) {
return(list(
File = options[1],
OutputGraph = options[2],
@@ -63,7 +63,7 @@ assignOptions <- function(options) {
anglePush = as.numeric(options[17]),
angleWeight = as.numeric(options[18]),
inertiaMomentum = (as.numeric(options[19])/10000.0), #comes in Kg*cm^2 eg: 100;
convert it to Kg*m^2 eg: 0.010
- gearedDown = as.numeric(options[20]),
+ gearedDown = readFromFile.gearedDown(as.numeric(options[20])),
SmoothingOneC = as.numeric(options[21]),
Jump = options[22],
@@ -76,6 +76,18 @@ assignOptions <- function(options) {
))
}
+#gearedDown comes as:
+#4 and should be converted to 4
+#-4 and should be converted to 1/4 : 0.25
+#more info at GearedUpDisplay() on EncoderConfiguration C# class
+
+readFromFile.gearedDown <- function(gd) {
+ if(gd > 0)
+ return(gd)
+
+ return( abs( 1 / gd ) )
+}
+
extrema <- function(y, ndata = length(y), ndatam1 = ndata - 1) {
@@ -960,7 +972,7 @@ getDisplacement <- function(encoderConfigurationName, displacement, diameter, di
#This function converts angular information from rotary encoder to linear information like linear encoder
#This is NOT the displacement of the person because con-ec phases roll in the same direction
#This is solved by the function getDisplacementInertialBody
-getDisplacementInertial <- function(displacement, encoderConfigurationName, diameter, diameterExt)
+getDisplacementInertial <- function(displacement, encoderConfigurationName, diameter, diameterExt,
gearedDown)
{
write("at getDisplacementInertial", stderr())
@@ -982,9 +994,9 @@ getDisplacementInertial <- function(displacement, encoderConfigurationName, diam
encoderConfigurationName == "ROTARYFRICTIONSIDEINERTIALLATERAL"){
displacement = displacement * diameter / diameterExt #displacement of the axis
} else if(encoderConfigurationName == "ROTARYFRICTIONAXISINERTIALMOVPULLEY"){
- displacement = displacement / 2 #Half the displacement of the axis
+ displacement = displacement / gearedDown #if gearedDown = 2 : Half the displacement of the axis
} else if(encoderConfigurationName == "ROTARYFRICTIONSIDEINERTIALMOVPULLEY"){
- displacement = displacement * diameter /(2 * diameterExt) #Half the displacement of the axis
+ displacement = displacement * diameter /(gearedDown * diameterExt) #if gearedDown = 2 : Half the
displacement of the axis
} else if(encoderConfigurationName == "ROTARYAXISINERTIALMOVPULLEY"){
displacementMeters = displacement / 1000 #mm -> m
diameterMeters = diameter / 100 #cm -> m
@@ -992,7 +1004,7 @@ getDisplacementInertial <- function(displacement, encoderConfigurationName, diam
#angle in radians
angle = cumsum(displacementMeters * 1000) * 2 * pi / ticksRotaryEncoder
position = angle * diameterMeters / 2
- position = position * 500 #m -> mm and the rope moves twice as the body
+ position = position * 1000 / gearedDown #m -> mm if gearedDown = 2 : Half the
displacement of the axis
#this is to make "inverted cumsum"
displacement = diff(position) #this displacement is going to be used now
displacement = c(displacement[1],displacement) #this is to recuperate the lost 1st value in the
diff operation
diff --git a/glade/chronojump.glade b/glade/chronojump.glade
index f002bd9..8e07236 100644
--- a/glade/chronojump.glade
+++ b/glade/chronojump.glade
@@ -7967,6 +7967,12 @@ after time</property>
<child>
<placeholder/>
</child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
</widget>
</child>
<child>
@@ -9468,6 +9474,12 @@ after time</property>
<child>
<placeholder/>
</child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
</widget>
<packing>
<property name="position">2</property>
@@ -10610,6 +10622,12 @@ after time</property>
<child>
<placeholder/>
</child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
</widget>
<packing>
<property name="position">4</property>
@@ -18829,6 +18847,12 @@ on current Chronojump version.</property>
<child>
<placeholder/>
</child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
</widget>
<packing>
<property name="expand">False</property>
@@ -23389,6 +23413,12 @@ by you</property>
<child>
<placeholder/>
</child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
</widget>
</child>
</widget>
@@ -24430,6 +24460,12 @@ by you</property>
<child>
<placeholder/>
</child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
</widget>
</child>
</widget>
@@ -25963,6 +25999,12 @@ by you</property>
<placeholder/>
</child>
<child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
<widget class="GtkButton" id="button_video_url">
<property name="visible">True</property>
<property name="can_focus">True</property>
@@ -26553,6 +26595,12 @@ by you</property>
<child>
<placeholder/>
</child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
</widget>
<packing>
<property name="expand">True</property>
@@ -29721,6 +29769,48 @@ to the center of the loads.</property>
<property name="position">7</property>
</packing>
</child>
+ <child>
+ <widget class="GtkHBox" id="hbox_gearedUp">
+ <property name="can_focus">False</property>
+ <property name="spacing">8</property>
+ <child>
+ <widget class="GtkLabel" id="label23">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0</property>
+ <property name="label"
translatable="yes">Multiplied</property>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkComboBox" id="combo_gearedUp">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="items">4
+3
+2
+1
+1/2
+1/3
+1/4</property>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">8</property>
+ </packing>
+ </child>
</widget>
</child>
</widget>
@@ -38701,6 +38791,42 @@ options</property>
<child>
<placeholder/>
</child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
</widget>
</child>
</widget>
@@ -40828,6 +40954,30 @@ To differentiate between male and female, use the values 1/0, or m/f, or M/F on
<child>
<placeholder/>
</child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
</widget>
</child>
</widget>
@@ -42209,12 +42359,6 @@ To differentiate between male and female, use the values 1/0, or m/f, or M/F on
<placeholder/>
</child>
<child>
- <placeholder/>
- </child>
- <child>
- <placeholder/>
- </child>
- <child>
<widget class="GtkLabel" id="label218">
<property name="visible">True</property>
<property name="can_focus">False</property>
@@ -43255,6 +43399,12 @@ To differentiate between male and female, use the values 1/0, or m/f, or M/F on
<child>
<placeholder/>
</child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
</widget>
</child>
</widget>
@@ -47068,6 +47218,12 @@ It starts before and arrives there with some speed.</property>
<child>
<placeholder/>
</child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
</widget>
<packing>
<property name="left_attach">2</property>
@@ -47773,6 +47929,12 @@ It starts before and arrives there with some speed.</property>
<child>
<placeholder/>
</child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
</widget>
</child>
</widget>
@@ -48493,6 +48655,12 @@ It starts before and arrives there with some speed.</property>
<child>
<placeholder/>
</child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
</widget>
</child>
</widget>
diff --git a/src/encoder.cs b/src/encoder.cs
index 0699191..8936a13 100644
--- a/src/encoder.cs
+++ b/src/encoder.cs
@@ -941,6 +941,7 @@ public class EncoderConfiguration {
public bool has_angle_push;
public bool has_angle_weight;
public bool has_inertia;
+ public bool has_gearedDown;
public bool rotaryFrictionOnAxis;
public double d; //axis
public double D; //external disc or pulley
@@ -949,6 +950,7 @@ public class EncoderConfiguration {
public int inertiaMachine; //this is the inertia without the disc
+ // see methods: GearedUpDisplay() SetGearedDownFromDisplay(string gearedUpStr)
public int gearedDown; //demultiplication
public int inertiaTotal; //this is the inertia used by R
@@ -975,6 +977,7 @@ public class EncoderConfiguration {
has_angle_push = false;
has_angle_weight = false;
has_inertia = false;
+ has_gearedDown = false; //gearedDown can be changed by user
rotaryFrictionOnAxis = false;
d = -1;
D = -1;
@@ -999,6 +1002,7 @@ public class EncoderConfiguration {
has_angle_push = false;
has_angle_weight = false;
has_inertia = false;
+ has_gearedDown = false; //gearedDown can be changed by user
rotaryFrictionOnAxis = false;
gearedDown = 1;
list_d = new List<double>();
@@ -1176,8 +1180,7 @@ public class EncoderConfiguration {
has_d = true;
has_D = true;
has_inertia = true;
-
- gearedDown = -2; //gearedDown is not used in inertial machines. It's hardcoded
+ has_gearedDown = true;
}
// ---- rotary friction on axis
@@ -1220,8 +1223,7 @@ public class EncoderConfiguration {
has_d = true;
has_inertia = true;
rotaryFrictionOnAxis = true;
-
- gearedDown = -2; //gearedDown is not used in inertial machines. It's hardcoded
+ has_gearedDown = true;
}
// ---- ROTARY AXIS ----
@@ -1282,8 +1284,7 @@ public class EncoderConfiguration {
has_d = true;
has_inertia = true;
-
- gearedDown = -2; //gearedDown is not used in inertial machines. It's hardcoded
+ has_gearedDown = true;
}
}
@@ -1431,6 +1432,75 @@ public class EncoderConfiguration {
return code + str_d + str_D + str_anglePush + str_angleWeight + str_inertia + str_gearedDown;
}
+
+ /*
+ * IMPORTANT: on GUI is gearedDown is shown as UP (for clarity: 4, 3, 2, 1, 1/2, 1/3, 1/4)
+ * on C#, R, SQL we use "gearedDown" for historical reasons. So a conversion is done on displaying
data to user
+ * gearedDown is stored as integer on database and is converted to this gearedUp for GUI
+ * R will do another conversion and will use the double
+ * 4 , 3 , 2 , 1, 1/2, 1/3, 1/4 #gearedUp string (GUI)
+ * -4 , -3 , -2 , 1, 2, 3, 4 #gearedDown
+ * 0.25, 0.333, 0.5, 1, 2, 3, 4 #gearedDown on R (see
readFromFile.gearedDown() on util.cs)
+ */
+ public string GearedUpDisplay()
+ {
+ switch(gearedDown) {
+ case -4:
+ return "4";
+ break;
+ case -3:
+ return "3";
+ break;
+ case -2:
+ return "2";
+ break;
+ case 1:
+ return "1";
+ break;
+ case 2:
+ return "1/2";
+ break;
+ case 3:
+ return "1/3";
+ break;
+ case 4:
+ return "1/4";
+ break;
+ default:
+ return "1";
+ break;
+ }
+ }
+ public void SetGearedDownFromDisplay(string gearedUpStr)
+ {
+ switch(gearedUpStr) {
+ case "4":
+ gearedDown = -4;
+ break;
+ case "3":
+ gearedDown = -3;
+ break;
+ case "2":
+ gearedDown = -2;
+ break;
+ case "1":
+ gearedDown = 1;
+ break;
+ case "1/2":
+ gearedDown = 2;
+ break;
+ case "1/3":
+ gearedDown = 3;
+ break;
+ case "1/4":
+ gearedDown = 4;
+ break;
+ default:
+ gearedDown = 1;
+ break;
+ }
+ }
+
}
public class EncoderAnalyzeInstant
diff --git a/src/gui/encoderConfiguration.cs b/src/gui/encoderConfiguration.cs
index 078f282..de0d1e0 100644
--- a/src/gui/encoderConfiguration.cs
+++ b/src/gui/encoderConfiguration.cs
@@ -41,7 +41,7 @@ public class EncoderConfigurationWindow
[Widget] Gtk.RadioButton radio_gravity;
[Widget] Gtk.RadioButton radio_inertia;
-
+
[Widget] Gtk.CheckButton check_rotary_friction_inertia_on_axis;
[Widget] Gtk.HBox hbox_encoder_types;
[Widget] Gtk.Alignment alignment_options;
@@ -86,6 +86,9 @@ public class EncoderConfigurationWindow
[Widget] Gtk.SpinButton spin_inertia_machine;
[Widget] Gtk.SpinButton spin_inertia_mass; //mass of each of the extra load (weights)
[Widget] Gtk.SpinButton spin_inertia_length;
+
+ [Widget] Gtk.HBox hbox_gearedUp;
+ [Widget] Gtk.ComboBox combo_gearedUp;
[Widget] Gtk.Box vbox_select_encoder;
[Widget] Gtk.VSeparator vseparator_im;
@@ -162,7 +165,8 @@ public class EncoderConfigurationWindow
EncoderConfigurationWindowBox.putValuesStoredPreviously(
ec.d, ec.list_d, ec.D, ec.anglePush, ec.angleWeight,
- ec.inertiaMachine, ec.extraWeightGrams, ec.extraWeightLength);
+ ec.inertiaMachine, ec.extraWeightGrams, ec.extraWeightLength,
+ ec.has_gearedDown, ec.GearedUpDisplay());
//id definedInConfig then only few things can change
@@ -281,6 +285,10 @@ public class EncoderConfigurationWindow
hbox_inertia_length.Visible = ec.has_inertia;
vbox_inertia_calcule.Visible = (ec.has_inertia && ! definedInConfig);
+ hbox_gearedUp.Visible = ec.has_gearedDown;
+ if(ec.has_gearedDown)
+ combo_gearedUp.Active = UtilGtk.ComboMakeActive(combo_gearedUp, "2");
+
label_count.Text = (listCurrent + 1).ToString() + " / " + list.Count.ToString();
//hide inertia moment calculation options when change mode
@@ -289,7 +297,8 @@ public class EncoderConfigurationWindow
}
private void putValuesStoredPreviously(double d, List<double> list_d, double D, int anglePush, int
angleWeight,
- int inertia, int extraWeightGrams, double extraWeightLength)
+ int inertia, int extraWeightGrams, double extraWeightLength,
+ bool has_gearedDown, string gearedUpDisplay)
{
if(d != -1)
spin_d.Value = d;
@@ -310,7 +319,9 @@ public class EncoderConfigurationWindow
spin_angle_weight.Value = angleWeight;
if(inertia != -1)
spin_inertia_machine.Value = inertia;
-
+ if(has_gearedDown)
+ combo_gearedUp.Active = UtilGtk.ComboMakeActive(combo_gearedUp, gearedUpDisplay);
+
spin_inertia_mass.Value = extraWeightGrams;
spin_inertia_length.Value = extraWeightLength;
}
@@ -441,6 +452,10 @@ public class EncoderConfigurationWindow
ec.extraWeightLength = (double) spin_inertia_length.Value;
}
+ if(ec.has_gearedDown) {
+ ec.SetGearedDownFromDisplay(UtilGtk.ComboGetActive(combo_gearedUp));
+ }
+
return ec;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]