diff --git a/devices/img.properties b/devices/img.properties index 83e6c9c..785c9ea 100644 --- a/devices/img.properties +++ b/devices/img.properties @@ -1,4 +1,4 @@ -#Fri Aug 10 15:19:19 CEST 2018 +#Thu Aug 30 15:04:59 CEST 2018 colormap=Grayscale colormapAutomatic=false colormapMax=18.133 @@ -9,16 +9,16 @@ grayscale=false invert=false rescaleFactor=1.0 rescaleOffset=0.0 -roiHeight=972 -roiWidth=972 -roiX=12 -roiY=15 -rotation=229.8340828443476 +roiHeight=887 +roiWidth=887 +roiX=59 +roiY=56 +rotation=229.76067253596318 rotationCrop=true scale=1.0 -spatialCalOffsetX=-486.0 -spatialCalOffsetY=-486.0 -spatialCalScaleX=0.48315133165771174 -spatialCalScaleY=0.48314848201202937 +spatialCalOffsetX=-444.0 +spatialCalOffsetY=-444.0 +spatialCalScaleX=0.5295623677991782 +spatialCalScaleY=0.5294932790504361 spatialCalUnits=mm transpose=false diff --git a/plugins/MXSC-1.10.0.jar b/plugins/MXSC-1.10.0.jar index f46cf9b..7e61ff4 100644 Binary files a/plugins/MXSC-1.10.0.jar and b/plugins/MXSC-1.10.0.jar differ diff --git a/plugins/RobotPanel.form b/plugins/RobotPanel.form index 4e89f65..bf9c0d6 100644 --- a/plugins/RobotPanel.form +++ b/plugins/RobotPanel.form @@ -326,9 +326,17 @@ + + + + + + + + + + - - @@ -371,6 +379,12 @@ + + + + + + @@ -448,6 +462,25 @@ + + + + + + + + + + + + + + + + + + + diff --git a/plugins/RobotPanel.java b/plugins/RobotPanel.java index 93720b5..e841f57 100644 --- a/plugins/RobotPanel.java +++ b/plugins/RobotPanel.java @@ -58,6 +58,7 @@ public class RobotPanel extends DevicePanel { Integer speed = null; String task = null; String mode = null; + String position = null; if ((value != null) && (value instanceof Map)) { Map status = (Map) value; @@ -81,6 +82,13 @@ public class RobotPanel extends DevicePanel { speed = (Integer) status.get("speed"); } catch (Exception ex) { } + try { + position = (String) status.get("pos"); + if (position==null){ + position = ""; + } + } catch (Exception ex) { + } try { task = ((status.containsKey("task")) && (status.get("task") == null)) ? "" : ((String) status.get("task")).trim(); } catch (Exception ex) { @@ -120,6 +128,8 @@ public class RobotPanel extends DevicePanel { ledMoving.setColor((moving == null) ? Color.GRAY : (moving ? Color.YELLOW : Color.DARK_GRAY)); textTask.setText((task == null) ? "" : task); ledTask.setColor((task == null) ? Color.GRAY : (task.isEmpty() ? Color.DARK_GRAY : Color.YELLOW)); + textPosition.setText((position == null) ? "" : position); + ledPosition.setColor((position == null) ? Color.GRAY : (position.isEmpty() ? Color.DARK_GRAY : Color.GREEN)); //buttonAbort.setEnabled(!textTask.getText().isEmpty()); spinnerSpeed.setEnabled(speed != null); if (speed == null) { @@ -171,6 +181,9 @@ public class RobotPanel extends DevicePanel { jLabel8 = new javax.swing.JLabel(); ledTask = new ch.psi.pshell.swing.Led(); ledMode = new ch.psi.pshell.swing.Led(); + textPosition = new javax.swing.JTextField(); + ledPosition = new ch.psi.pshell.swing.Led(); + jLabel9 = new javax.swing.JLabel(); panelState = new ch.psi.pshell.swing.DeviceStatePanel(); jPanel4 = new javax.swing.JPanel(); ledOpen = new ch.psi.pshell.swing.Led(); @@ -380,6 +393,14 @@ public class RobotPanel extends DevicePanel { ledMode.setFont(new java.awt.Font("SansSerif", 0, 18)); // NOI18N + textPosition.setEditable(false); + textPosition.setHorizontalAlignment(javax.swing.JTextField.CENTER); + + ledPosition.setFont(new java.awt.Font("SansSerif", 0, 18)); // NOI18N + + jLabel9.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING); + jLabel9.setText("Position:"); + javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3); jPanel3.setLayout(jPanel3Layout); jPanel3Layout.setHorizontalGroup( @@ -401,9 +422,15 @@ public class RobotPanel extends DevicePanel { .addGroup(jPanel3Layout.createSequentialGroup() .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 52, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(ledSettled, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))) + .addComponent(ledSettled, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) + .addGroup(jPanel3Layout.createSequentialGroup() + .addComponent(jLabel9, javax.swing.GroupLayout.PREFERRED_SIZE, 52, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(ledPosition, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) - .addComponent(textTask)) + .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(textTask) + .addComponent(textPosition))) .addGroup(jPanel3Layout.createSequentialGroup() .addComponent(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, 52, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) @@ -415,7 +442,7 @@ public class RobotPanel extends DevicePanel { .addContainerGap()) ); - jPanel3Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {jLabel3, jLabel4, jLabel6, jLabel8}); + jPanel3Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {jLabel3, jLabel4, jLabel6, jLabel8, jLabel9}); jPanel3Layout.setVerticalGroup( jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) @@ -439,6 +466,11 @@ public class RobotPanel extends DevicePanel { .addComponent(jLabel8) .addComponent(ledTask, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(textTask, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGap(2, 2, 2) + .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER) + .addComponent(jLabel9) + .addComponent(ledPosition, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(textPosition, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(2, 2, 2)) ); @@ -628,6 +660,7 @@ public class RobotPanel extends DevicePanel { private javax.swing.JLabel jLabel6; private javax.swing.JLabel jLabel7; private javax.swing.JLabel jLabel8; + private javax.swing.JLabel jLabel9; private javax.swing.JPanel jPanel1; private javax.swing.JPanel jPanel2; private javax.swing.JPanel jPanel3; @@ -636,6 +669,7 @@ public class RobotPanel extends DevicePanel { private ch.psi.pshell.swing.Led ledMode; private ch.psi.pshell.swing.Led ledMoving; private ch.psi.pshell.swing.Led ledOpen; + private ch.psi.pshell.swing.Led ledPosition; private ch.psi.pshell.swing.Led ledPowered; private ch.psi.pshell.swing.Led ledSettled; private ch.psi.pshell.swing.Led ledTask; @@ -645,6 +679,7 @@ public class RobotPanel extends DevicePanel { private ch.psi.pshell.swing.DeviceStatePanel panelState; private javax.swing.JSpinner spinnerSpeed; private javax.swing.JTextField textMode; + private javax.swing.JTextField textPosition; private javax.swing.JTextField textTask; // End of variables declaration//GEN-END:variables } diff --git a/script/devices/RobotSC.py b/script/devices/RobotSC.py index fe33e3e..2024fff 100644 --- a/script/devices/RobotSC.py +++ b/script/devices/RobotSC.py @@ -224,7 +224,7 @@ robot.default_speed = 20 robot.set_tool(TOOL_DEFAULT) robot.setPolling(DEFAULT_ROBOT_POLLING) - +robot.get_current_point() #TODO: REMOVE WHEN CURRENT POINT REPORTED BY POLLING MESSAGE class jf1(ReadonlyRegisterBase): def doRead(self): diff --git a/script/devices/RobotTCP.py b/script/devices/RobotTCP.py index f70e948..33986b1 100644 --- a/script/devices/RobotTCP.py +++ b/script/devices/RobotTCP.py @@ -30,6 +30,7 @@ class RobotTCP(TcpDevice, Stoppable): self.current_task_ret = None self.high_level_tasks = [] self.known_points = [] + self.current_points = [] self.cartesian_destination = None #self.flange_pos = [None] * 6 self.cartesian_pos = [None] * 6 @@ -94,13 +95,28 @@ class RobotTCP(TcpDevice, Stoppable): def get_known_points(self): return self.known_points - def get_current_point(self, tolerance = None): + def get_current_points(self, tolerance = None): ret = self.is_in_points(*self.known_points, tolerance = tolerance) + current_points = [] for i in range(len(ret)): if ret[i] == True: - return self.known_points[i] + current_points.append(self.known_points[i]) + return current_points + + def get_current_point(self, tolerance = None): + current_points = self.get_current_points(tolerance) + if (current_points is not None) and ( len(current_points) >0): + return current_points[0] return None + def get_current_points_cached(self): + return self.current_points + + def get_current_point_cached(self): + if (self.current_points is not None) and (len (self.current_points) >0): + return self.current_points[0] + return None + def assert_in_known_point(self, tolerance = None): if self.get_current_point(tolerance) is None: raise Exception ("Robot not in known point") @@ -585,7 +601,8 @@ class RobotTCP(TcpDevice, Stoppable): "task": cur_task, "mode": self.working_mode, "status": self.status, - "open": self.tool_open + "open": self.tool_open, + "pos": self.get_current_point_cached() if self.state==State.Ready else None #TODO: make it calculated in robot by possiung funtion }, None) if self.cartesian_motors_enabled: for m in self.cartesian_motors: @@ -620,6 +637,9 @@ class RobotTCP(TcpDevice, Stoppable): return self.distance_p("tcp_p", name) def is_in_point(self, p, tolerance = None): #Tolerance in mm + if (tolerance is None) and p in self.known_points: + #If checking a known point with default tolerance, updates the position cache + return p in self.get_current_points() tolerance = self.default_tolerance if tolerance == None else tolerance d = self.get_distance_to_pnt(p) if d<0: @@ -644,6 +664,12 @@ class RobotTCP(TcpDevice, Stoppable): ret[i] = None else: ret[i] = ret[i]