diff --git a/config/settings.properties b/config/settings.properties
index cc13f59..8ba16a1 100644
--- a/config/settings.properties
+++ b/config/settings.properties
@@ -1,13 +1,14 @@
-#Tue Jul 23 15:28:01 CEST 2019
+#Tue Sep 17 16:36:06 CEST 2019
barcode_reader_scan_pucks=false
beamline_status_enabled=false
cold_position_timeout=3600
dry_mount_counter=0
-dry_timestamp=1.563869039847E9
-force_dry_mount_count=10
+dry_timestamp=1.5687283096E9
+force_dry_mount_count=8
force_dry_timeout=0
imaging_enabled=false
-led_level=0.0
+led_level=100.0
+mounted_sample_position=A25
pin_offset=0.0
puck_types=true
roi_h=1000
diff --git a/config/setup.properties b/config/setup.properties
index b0b857a..7ad15eb 100644
--- a/config/setup.properties
+++ b/config/setup.properties
@@ -1,9 +1,10 @@
-#Mon Dec 17 17:00:32 CET 2018
+#Tue Sep 17 15:06:05 CEST 2019
configFile={config}/config.properties
configFileDevices={config}/devices.properties
configFilePlugins={config}/plugins.properties
configFileSettings={config}/settings.properties
configFileTasks={config}/tasks.properties
+configFileVariables={config}/variables.properties
configPath={home}/config
contextPath={outp}/context
dataPath={outp}/data
diff --git a/devices/B4.properties b/devices/B4.properties
index 5382cce..39c7a01 100644
--- a/devices/B4.properties
+++ b/devices/B4.properties
@@ -1,3 +1,3 @@
-#Mon Apr 29 16:40:10 CEST 2019
+#Wed Aug 21 15:20:23 CEST 2019
detection=Mechanical
disabled=false
diff --git a/devices/B5.properties b/devices/B5.properties
index 1651b90..bb45e5a 100644
--- a/devices/B5.properties
+++ b/devices/B5.properties
@@ -1,3 +1,3 @@
-#Mon Apr 29 16:40:13 CEST 2019
+#Wed Aug 21 15:20:26 CEST 2019
detection=Mechanical
disabled=false
diff --git a/devices/C1.properties b/devices/C1.properties
index cb744a3..9b9088d 100644
--- a/devices/C1.properties
+++ b/devices/C1.properties
@@ -1,3 +1,3 @@
-#Wed Feb 06 11:01:55 CET 2019
+#Wed Aug 21 15:34:38 CEST 2019
detection=Mechanical
-disabled=false
+disabled=true
diff --git a/devices/C2.properties b/devices/C2.properties
index e18400b..c6592e7 100644
--- a/devices/C2.properties
+++ b/devices/C2.properties
@@ -1,3 +1,3 @@
-#Wed Feb 06 11:02:02 CET 2019
+#Wed Aug 21 15:34:40 CEST 2019
detection=Mechanical
-disabled=false
+disabled=true
diff --git a/devices/C3.properties b/devices/C3.properties
index 85868a7..4eccc7c 100644
--- a/devices/C3.properties
+++ b/devices/C3.properties
@@ -1,3 +1,3 @@
-#Thu Jun 06 15:47:11 CEST 2019
+#Wed Aug 21 15:34:43 CEST 2019
detection=Mechanical
-disabled=false
+disabled=true
diff --git a/devices/C4.properties b/devices/C4.properties
index b994628..c88441d 100644
--- a/devices/C4.properties
+++ b/devices/C4.properties
@@ -1,3 +1,3 @@
-#Tue Jun 25 10:55:28 CEST 2019
+#Wed Aug 21 15:34:45 CEST 2019
detection=Mechanical
-disabled=false
+disabled=true
diff --git a/devices/C5.properties b/devices/C5.properties
index b6c3239..6291d73 100644
--- a/devices/C5.properties
+++ b/devices/C5.properties
@@ -1,3 +1,3 @@
-#Tue Jun 25 10:55:33 CEST 2019
+#Wed Aug 21 15:34:48 CEST 2019
detection=Mechanical
-disabled=false
+disabled=true
diff --git a/devices/D1.properties b/devices/D1.properties
index aa52ecf..23e3c3f 100644
--- a/devices/D1.properties
+++ b/devices/D1.properties
@@ -1,3 +1,3 @@
-#Wed Feb 06 11:02:24 CET 2019
+#Wed Aug 21 15:34:50 CEST 2019
detection=Mechanical
-disabled=false
+disabled=true
diff --git a/devices/D2.properties b/devices/D2.properties
index c60b5f8..9ba64b9 100644
--- a/devices/D2.properties
+++ b/devices/D2.properties
@@ -1,3 +1,3 @@
-#Wed Feb 06 11:02:29 CET 2019
+#Wed Aug 21 15:34:57 CEST 2019
detection=Mechanical
-disabled=false
+disabled=true
diff --git a/devices/D3.properties b/devices/D3.properties
index eeee766..4db5dde 100644
--- a/devices/D3.properties
+++ b/devices/D3.properties
@@ -1,3 +1,3 @@
-#Wed Feb 06 11:02:33 CET 2019
+#Wed Aug 21 15:34:59 CEST 2019
detection=Mechanical
-disabled=false
+disabled=true
diff --git a/devices/D4.properties b/devices/D4.properties
index 1dfe8ba..ffd9e92 100644
--- a/devices/D4.properties
+++ b/devices/D4.properties
@@ -1,3 +1,3 @@
-#Wed Feb 06 11:02:38 CET 2019
+#Wed Aug 21 15:35:02 CEST 2019
detection=Mechanical
-disabled=false
+disabled=true
diff --git a/devices/D5.properties b/devices/D5.properties
index a98fde2..e0a110b 100644
--- a/devices/D5.properties
+++ b/devices/D5.properties
@@ -1,3 +1,3 @@
-#Wed Feb 06 11:02:43 CET 2019
+#Wed Aug 21 15:35:04 CEST 2019
detection=Mechanical
-disabled=false
+disabled=true
diff --git a/devices/E1.properties b/devices/E1.properties
index 4008403..5399f6c 100644
--- a/devices/E1.properties
+++ b/devices/E1.properties
@@ -1,3 +1,3 @@
-#Wed Feb 06 11:03:08 CET 2019
+#Tue Aug 27 11:23:36 CEST 2019
detection=Mechanical
disabled=false
diff --git a/devices/E2.properties b/devices/E2.properties
index dc5ee8f..f72d393 100644
--- a/devices/E2.properties
+++ b/devices/E2.properties
@@ -1,3 +1,3 @@
-#Wed Feb 06 11:03:13 CET 2019
+#Tue Aug 27 11:23:40 CEST 2019
detection=Mechanical
disabled=false
diff --git a/devices/E3.properties b/devices/E3.properties
index 1d4765f..8969310 100644
--- a/devices/E3.properties
+++ b/devices/E3.properties
@@ -1,3 +1,3 @@
-#Thu Jun 06 15:47:19 CEST 2019
+#Tue Aug 27 11:23:43 CEST 2019
detection=Mechanical
disabled=false
diff --git a/devices/E4.properties b/devices/E4.properties
index 2ba4cae..c44f3ec 100644
--- a/devices/E4.properties
+++ b/devices/E4.properties
@@ -1,3 +1,3 @@
-#Wed Feb 06 11:03:23 CET 2019
+#Tue Aug 27 11:23:47 CEST 2019
detection=Mechanical
disabled=false
diff --git a/devices/E5.properties b/devices/E5.properties
index 0bb0b86..9b88e92 100644
--- a/devices/E5.properties
+++ b/devices/E5.properties
@@ -1,3 +1,3 @@
-#Wed Feb 06 11:03:27 CET 2019
+#Tue Aug 27 11:23:51 CEST 2019
detection=Mechanical
disabled=false
diff --git a/devices/F2.properties b/devices/F2.properties
index 7094b2c..dce85b2 100644
--- a/devices/F2.properties
+++ b/devices/F2.properties
@@ -1,3 +1,3 @@
-#Thu Jun 06 15:46:33 CEST 2019
+#Tue Sep 10 08:18:28 CEST 2019
detection=Mechanical
disabled=false
diff --git a/devices/F4.properties b/devices/F4.properties
index 2b6dd64..547817a 100644
--- a/devices/F4.properties
+++ b/devices/F4.properties
@@ -1,3 +1,3 @@
-#Tue Jun 25 10:55:43 CEST 2019
+#Tue Sep 10 08:18:31 CEST 2019
detection=Mechanical
disabled=false
diff --git a/devices/led_ctrl_1.properties b/devices/led_ctrl_1.properties
index 061bf83..b1b7adc 100644
--- a/devices/led_ctrl_1.properties
+++ b/devices/led_ctrl_1.properties
@@ -1,5 +1,5 @@
-#Wed Jul 17 08:29:01 CEST 2019
-maxValue=0.4
+#Wed Sep 11 13:17:28 CEST 2019
+maxValue=1.0
minValue=0.0
offset=0.0
precision=2
diff --git a/devices/led_ctrl_2.properties b/devices/led_ctrl_2.properties
index 061bf83..b1b7adc 100644
--- a/devices/led_ctrl_2.properties
+++ b/devices/led_ctrl_2.properties
@@ -1,5 +1,5 @@
-#Wed Jul 17 08:29:01 CEST 2019
-maxValue=0.4
+#Wed Sep 11 13:17:28 CEST 2019
+maxValue=1.0
minValue=0.0
offset=0.0
precision=2
diff --git a/devices/led_ctrl_3.properties b/devices/led_ctrl_3.properties
index 061bf83..b1b7adc 100644
--- a/devices/led_ctrl_3.properties
+++ b/devices/led_ctrl_3.properties
@@ -1,5 +1,5 @@
-#Wed Jul 17 08:29:01 CEST 2019
-maxValue=0.4
+#Wed Sep 11 13:17:28 CEST 2019
+maxValue=1.0
minValue=0.0
offset=0.0
precision=2
diff --git a/devices/smart_magnet.properties b/devices/smart_magnet.properties
index eae60c8..29bedad 100644
--- a/devices/smart_magnet.properties
+++ b/devices/smart_magnet.properties
@@ -1,8 +1,8 @@
-#Wed Jul 03 11:55:12 CEST 2019
-holdingCurrent=40.0
-mountCurrent=20.0
+#Tue Sep 17 13:46:27 CEST 2019
+holdingCurrent=50.0
+mountCurrent=30.0
remanenceCurrent=-10.0
-restingCurrent=20.0
+restingCurrent=30.0
reverseCurrent=-10.0
-reverseTime=0.4
+reverseTime=0.2
unmountCurrent=20.0
diff --git a/plugins/Commands.form b/plugins/Commands.form
index add3c8a..0dd7059 100644
--- a/plugins/Commands.form
+++ b/plugins/Commands.form
@@ -134,6 +134,7 @@
+
diff --git a/plugins/Commands.java b/plugins/Commands.java
index 1867bcb..fa3595d 100644
--- a/plugins/Commands.java
+++ b/plugins/Commands.java
@@ -89,11 +89,8 @@ public class Commands extends Panel {
try {
evalAsync(statement, background).handle((ret, ex) -> {
if (ex != null){
- try {
- if (getContext().getSetting("recovering") == null) {
- showException((Exception)ex);
- }
- } catch (IOException e) {
+ if (getContext().getGlobal("recovering") == null) {
+ showException((Exception)ex);
}
} else if (showReturn){
SwingUtils.showMessage(getTopLevel(), "Return", String.valueOf(ret));
@@ -181,6 +178,7 @@ public class Commands extends Panel {
jLabel6.setText("Heat time(s):");
spinnerDryTime.setModel(new javax.swing.SpinnerNumberModel(30.0d, 1.0d, 50.0d, 1.0d));
+ spinnerDryTime.setRequestFocusEnabled(false);
buttonDry.setText("Dry");
buttonDry.addActionListener(new java.awt.event.ActionListener() {
diff --git a/plugins/MXSC-1.10.0.jar b/plugins/MXSC-1.10.0.jar
index 64c6c94..1556226 100644
Binary files a/plugins/MXSC-1.10.0.jar and b/plugins/MXSC-1.10.0.jar differ
diff --git a/plugins/Recovery.form b/plugins/Recovery.form
index 60f2786..fa22373 100644
--- a/plugins/Recovery.form
+++ b/plugins/Recovery.form
@@ -27,22 +27,13 @@
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
-
+
@@ -54,12 +45,12 @@
-
-
-
-
+
+
+
+
-
+
@@ -78,27 +69,16 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
-
+
@@ -156,12 +136,5 @@
-
-
-
-
-
-
-
diff --git a/plugins/Recovery.java b/plugins/Recovery.java
index 118fe5f..ee1e216 100644
--- a/plugins/Recovery.java
+++ b/plugins/Recovery.java
@@ -26,7 +26,7 @@ public class Recovery extends Panel {
//Overridable callbacks
@Override
public void onInitialize(int runCount) {
-
+ getContext().setGlobal("recovering", null);
}
@Override
@@ -43,10 +43,15 @@ public class Recovery extends Panel {
void updateButton(){
buttonRecover.setEnabled((getContext().getState().isNormal()) &&
(textPosition.getText().trim().isEmpty()) &&
- ((!textSegment.getText().trim().isEmpty()) || (ledIsInDewar.getColor()==Color.GREEN))
+ (!textSegment.getText().trim().isEmpty()) &&
+ !isRecovering()
);
}
+
+ boolean isRecovering(){
+ return "true".equals(getContext().getGlobal("recovering"));
+ }
@Override
public void onExecutedFile(String fileName, Object result) {
@@ -64,7 +69,6 @@ public class Recovery extends Panel {
textSegment.setText("");
ledKnownPosition.setColor(Color.BLACK);
textPosition.setText("");
- ledIsInDewar.setColor(Color.BLACK);
} else {
if (getState().isNormal()){
String point = null;
@@ -76,9 +80,10 @@ public class Recovery extends Panel {
System.out.println(ex);
ledKnownPosition.setColor(Color.BLACK);
textPosition.setText("");
- }
+ }
+ List segment = null;
try{
- List segment = (List) eval("get_current_segment()", true);
+ segment = (List) eval("get_current_segment()", true);
ledValidSegment.setColor((segment == null) ? Color.RED : Color.GREEN);
textSegment.setText((segment == null) ? "": segment.get(0) + "->" + segment.get(1) + " [" + segment.get(2) + "mm]");
if ((segment == null)||(point!=null)){
@@ -99,10 +104,12 @@ public class Recovery extends Panel {
}
try{
Boolean is_in_dewar = (Boolean) eval("is_in_dewar()", true);
- ledIsInDewar.setColor(is_in_dewar ? Color.GREEN : Color.RED);
+ if ((segment==null) && is_in_dewar){
+ ledValidSegment.setColor(Color.GREEN);
+ textSegment.setText("Inside Dewar");
+ }
} catch (Exception ex) {
System.out.println(ex);
- ledIsInDewar.setColor(Color.BLACK);
}
}
}
@@ -124,8 +131,6 @@ public class Recovery extends Panel {
textSegment = new javax.swing.JTextField();
textDistance = new javax.swing.JTextField();
jLabel8 = new javax.swing.JLabel();
- ledIsInDewar = new ch.psi.pshell.swing.Led();
- jLabel9 = new javax.swing.JLabel();
jLabel6.setText("Known position");
@@ -155,8 +160,6 @@ public class Recovery extends Panel {
jLabel8.setText("Distance:");
- jLabel9.setText("Is in Dewar");
-
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
@@ -171,34 +174,25 @@ public class Recovery extends Panel {
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(textPosition))
.addGroup(layout.createSequentialGroup()
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(layout.createSequentialGroup()
- .addComponent(ledValidSegment, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addComponent(jLabel7))
- .addGroup(layout.createSequentialGroup()
- .addComponent(ledIsInDewar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addComponent(jLabel9)))
+ .addComponent(ledValidSegment, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addComponent(jLabel7)
.addGap(16, 16, 16)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
- .addGap(0, 0, Short.MAX_VALUE)
+ .addGap(0, 103, Short.MAX_VALUE)
.addComponent(jLabel8)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(textDistance, javax.swing.GroupLayout.PREFERRED_SIZE, 86, javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(textSegment))))
.addGap(8, 8, 8))
.addGroup(layout.createSequentialGroup()
- .addContainerGap(136, Short.MAX_VALUE)
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
- .addComponent(buttonAbort, javax.swing.GroupLayout.PREFERRED_SIZE, 73, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addComponent(buttonRecover))
- .addContainerGap(144, Short.MAX_VALUE))
+ .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
+ .addComponent(buttonRecover, javax.swing.GroupLayout.DEFAULT_SIZE, 179, Short.MAX_VALUE)
+ .addComponent(buttonAbort, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
+ .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
-
- layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {buttonAbort, buttonRecover});
-
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
@@ -212,29 +206,26 @@ public class Recovery extends Panel {
.addComponent(ledValidSegment, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel7)
.addComponent(textSegment, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(layout.createSequentialGroup()
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
- .addComponent(jLabel8)
- .addComponent(textDistance, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
- .addGroup(layout.createSequentialGroup()
- .addGap(30, 30, 30)
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
- .addComponent(ledIsInDewar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addComponent(jLabel9))))
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 62, Short.MAX_VALUE)
- .addComponent(buttonRecover)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
+ .addComponent(jLabel8)
+ .addComponent(textDistance, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 61, Short.MAX_VALUE)
+ .addComponent(buttonRecover)
+ .addGap(18, 18, 18)
.addComponent(buttonAbort)
- .addContainerGap())
+ .addGap(24, 24, 24))
);
}// //GEN-END:initComponents
private void buttonRecoverActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonRecoverActionPerformed
try{
+ if (isRecovering()){
+ getLogger().warning("Ongoing recovery ");
+ return;
+ }
buttonAbort.setEnabled(true);
- getContext().setSetting("recovering", "true");
+ getContext().setGlobal("recovering", "true");
Device robot = getContext().getDevicePool().getByName("robot", Device.class);
abort();
getContext().waitState(State.Ready, 5000);
@@ -242,23 +233,19 @@ public class Recovery extends Panel {
robot.waitReady(5000);
evalAsync("recover()", false).handle((ret, ex) -> {
if (ex != null){
- showException((Exception)ex);
+ if (!getContext().isAborted()){
+ showException((Exception)ex);
+ }
} else {
SwingUtils.showMessage(getTopLevel(), "Return", String.valueOf(ret));
}
- try {
- getContext().setSetting("recovering", null);
- } catch (IOException e) {
- }
+ getContext().setGlobal("recovering", null);
buttonAbort.setEnabled(false);
return ret;
});
} catch (Exception ex) {
showException(ex);
- try {
- getContext().setSetting("recovering", null);
- } catch (IOException e) {
- }
+ getContext().setGlobal("recovering", null);
buttonAbort.setEnabled(false);
}
}//GEN-LAST:event_buttonRecoverActionPerformed
@@ -272,7 +259,7 @@ public class Recovery extends Panel {
this.showException(ex);
}
try{
- eval("stop_task()", true);
+ eval("robot.stop_task()", true);
} catch (Exception ex){
this.showException(ex);
}
@@ -282,7 +269,7 @@ public class Recovery extends Panel {
this.showException(ex);
}
} catch (InterruptedException ex) {
- showException(ex);
+ //showException(ex);
}
}//GEN-LAST:event_buttonAbortActionPerformed
@@ -292,8 +279,6 @@ public class Recovery extends Panel {
private javax.swing.JLabel jLabel6;
private javax.swing.JLabel jLabel7;
private javax.swing.JLabel jLabel8;
- private javax.swing.JLabel jLabel9;
- private ch.psi.pshell.swing.Led ledIsInDewar;
private ch.psi.pshell.swing.Led ledKnownPosition;
private ch.psi.pshell.swing.Led ledValidSegment;
private javax.swing.JTextField textDistance;
diff --git a/script/calibration/ScanX.py b/script/calibration/ScanX.py
index e72350d..462681b 100644
--- a/script/calibration/ScanX.py
+++ b/script/calibration/ScanX.py
@@ -55,12 +55,18 @@ center_positon = ret.getPositions(0)[center_index]
y = ret.getReadable(0)[_range[0] : _range[1]]
x = ret.getPositions(0)[_range[0]: _range[1]]
+
+#Clear NaNs
+first_value=ret.getReadable(0)[first_index]
+y = [(first_value if math.isnan(v) else v) for v in y]
+
+
#x = enforce_monotonic(x)
#(normalization, mean_val, sigma) = fit_gaussian([-v for v in y], x)
-closest_x = x[y.indexOf(min(y))]
-closest_y = y[y.indexOf(min(y))]
+closest_x = x[y.index(min(y))]
+closest_y = y[y.index(min(y))]
diff --git a/script/calibration/ScanY.py b/script/calibration/ScanY.py
index 17252f1..72e0759 100644
--- a/script/calibration/ScanY.py
+++ b/script/calibration/ScanY.py
@@ -1,6 +1,7 @@
import plotutils
from mathutils import fit_gaussian, Gaussian
+FIT = True
d = robot.get_distance_to_pnt("pLaser")
if d<0:
@@ -9,7 +10,7 @@ if d<0:
if d>20:
raise Exception ("Should be near the laser position to perform the scan")
-RANGE = [-2.0, 2.0] #[-1.5, 1.5]
+RANGE = [-6.0, 3.0] #[-1.5, 1.5]
STEP = 0.02
Z_OFFSET = 0 #-1.0
LATENCY = 0.025
@@ -20,6 +21,15 @@ robot.set_motors_enabled(True)
current_positon = robot_y.getPosition()
robot_z.moveRel(Z_OFFSET)
+
+print "Moving to scan start position: " , RANGE[0]
+robot.set_motors_enabled(True)
+robot_y.moveRel( RANGE[0])
+robot.set_motors_enabled(True)
+print "Starting scan Y"
+
+RANGE = [0, (RANGE[1] - RANGE[0] )]
+
robot.setPolling(25)
try:
ret = lscan(robot_y, ue.readable, RANGE[0], RANGE[1], STEP, latency = LATENCY, relative = True)
@@ -55,13 +65,21 @@ center_positon = ret.getPositions(0)[center_index]
y = ret.getReadable(0)[_range[0] : _range[1]]
x = ret.getPositions(0)[_range[0]: _range[1]]
-#x = enforce_monotonic(x)
-#(normalization, mean_val, sigma) = fit_gaussian([-v for v in y], x)
+
+#Clear NaNs
+first_value=ret.getReadable(0)[first_index]
+y = [(first_value if math.isnan(v) else v) for v in y]
-closest_y = x[y.indexOf(min(y))]
-closest_x = y[y.indexOf(min(y))]
-
+if FIT:
+ x = enforce_monotonic(x)
+ offset=100
+ (normalization, mean_val, sigma) = fit_gaussian([offset-v for v in y], x)
+ closest_y = mean_val
+ closest_x = 100 -normalization
+else:
+ closest_y = x[y.index(min(y))]
+ closest_x = y[y.index(min(y))]
if closest_y is None or closest_y <= ret.getPositions(0)[first_index] or closest_y >= ret.getPositions(0)[last_index]:
diff --git a/script/calibration/ToolCalibration6s.py b/script/calibration/ToolCalibration6s.py
new file mode 100644
index 0000000..c6eea39
--- /dev/null
+++ b/script/calibration/ToolCalibration6s.py
@@ -0,0 +1,76 @@
+import plotutils
+from mathutils import fit_gaussian, Gaussian
+
+cal_tool = TOOL_CALIBRATION
+
+robot.set_tool(cal_tool)
+
+robot.enable()
+move_to_laser("pPark")
+
+
+robot.set_motors_enabled(True)
+robot.set_joint_motors_enabled(True)
+initial_pos = robot.get_cartesian_pos()
+
+#robot.align()
+run("calibration/ScanY")
+
+pos1 = robot.get_cartesian_pos()
+l1, y1 = closest_x, closest_y
+
+print "Scan 1 result: ", [l1, y1]
+print "Position 1: ", pos1
+
+
+pj6 = robot_j6.position
+if pj6>0:
+ robot_j6.move(pj6 - 180.0)
+else:
+ robot_j6.move(pj6 + 180.0)
+
+run("calibration/ScanY")
+
+pos2 =robot.get_cartesian_pos()
+l2, y2 = closest_x, closest_y
+
+print "Scan 2 result: ", [l2, y2]
+print "Position 2: ", pos1
+
+off_l = l2 - l1
+print "Offset l: ", off_l
+
+#For composing cannot use tcp_p, need another auxiliary point. tcp_t is also destroyed.
+robot.set_pnt(robot.get_cartesian_pos(), "pTemp")
+robot.set_trsf([-off_l, 0, 0, 0, 0, 0])
+c=robot.compose("pTemp", FRAME_DEFAULT, "tcp_t" )
+robot.set_pnt(c, "pTemp")
+robot.movel("pTemp", cal_tool, DESC_SCAN, sync=True)
+
+
+pos3 = robot.get_cartesian_pos()
+print "Position 3: ", pos3
+
+
+#Updates the tool
+t=robot.get_tool_trsf(TOOL_DEFAULT)
+print "Former tool: " + str(t)
+
+xoff = (pos3[0]-pos1[0])/2
+yoff = (pos3[1]-pos1[1])/2
+xrot = math.degrees(math.atan(yoff/t[2]))
+yrot = math.degrees(math.atan(xoff/t[2]))
+t[0]=xoff
+t[1]=-yoff
+print "Calibrated tool: " + str(t)
+
+
+robot.set_tool_trsf(t, TOOL_DEFAULT)
+
+robot.set_tool(TOOL_DEFAULT)
+d = robot.get_distance_to_pnt("pLaser")
+if d