Skip to content

Commit

Permalink
Moved main() to separate test files
Browse files Browse the repository at this point in the history
  • Loading branch information
i-make-robots committed Dec 8, 2023
1 parent c44a086 commit 4d100bb
Show file tree
Hide file tree
Showing 18 changed files with 218 additions and 131 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,23 @@ public Object get(int property) {
}
}

@Override
public void set(int property, Object value) {
switch (property) {
case ACTIVE_JOINT -> activeJoint = Math.max(0, Math.min(getNumBones(), (int) value));
case JOINT_VALUE -> setActiveJointValue((double) value);
case END_EFFECTOR_TARGET -> setEndEffectorTargetPose((Matrix4d) value);
case END_EFFECTOR_TARGET_POSITION -> setEndEffectorTargetPosition((Point3d) value);
case TOOL_CENTER_POINT -> setToolCenterPointOffset((Matrix4d) value);
case POSE -> setPoseWorld((Matrix4d) value);
case JOINT_HOME -> getBone(activeJoint).setJointHome((double) value);
case ALL_JOINT_VALUES -> setAllJointValues((double[]) value);
case DESIRED_LINEAR_VELOCITY -> desiredLinearVelocity.set((double) value);
case TOOL_ACTIVE -> fireRobotEvent(new RobotEvent(RobotEvent.TOOL_ACTIVATE, this, value));
default -> logger.warn("invalid set() property {}", property);
}
}

private Object getActiveJointValue() {
DHComponent b = getBone(activeJoint);
return b.getJointValue();
Expand All @@ -122,19 +139,9 @@ public double[] getAllJointValues() {
return result;
}

@Override
public void set(int property, Object value) {
switch (property) {
case ACTIVE_JOINT -> activeJoint = Math.max(0, Math.min(getNumBones(), (int) value));
case JOINT_VALUE -> setActiveJointValue((double) value);
case END_EFFECTOR_TARGET -> setEndEffectorTargetPose((Matrix4d) value);
case END_EFFECTOR_TARGET_POSITION -> setEndEffectorTargetPosition((Point3d) value);
case TOOL_CENTER_POINT -> setToolCenterPointOffset((Matrix4d) value);
case POSE -> setPoseWorld((Matrix4d) value);
case JOINT_HOME -> getBone(activeJoint).setJointHome((double) value);
case ALL_JOINT_VALUES -> setAllJointValues((double[]) value);
case DESIRED_LINEAR_VELOCITY -> desiredLinearVelocity.set((double) value);
default -> logger.warn("invalid set() property {}", property);
private void fireRobotEvent(RobotEvent robotEvent) {
for(RobotEventListener p : listeners) {
p.onRobotEvent(robotEvent);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,21 +93,4 @@ private JRadioButton makeRadioButton(ButtonGroup group, String label) {
group.add(rb);
return rb;
}

// TEST

public static void main(String[] args) {
Log.start();
Translator.start();

try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch (Exception ignored) {}

JFrame frame = new JFrame(AngleDrivePanel.class.getSimpleName());
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.add(new AngleDrivePanel(new RobotComponent()));
frame.pack();
frame.setVisible(true);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -84,20 +84,4 @@ private JSlider makeSliderFromBone(Robot robot,int i) {
slider.setEnabled(false);
return slider;
}

// TEST

public static void main(String[] args) {
Log.start();

try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch (Exception ignored) {}

JFrame frame = new JFrame(AngleReportPanel.class.getSimpleName());
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.add(new AngleReportPanel(new RobotComponent()));
frame.pack();
frame.setVisible(true);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -187,20 +187,4 @@ private void translateMatrix(Matrix4d m4, Vector3d v, double v_mm) {
m4.m13 += v.y;
m4.m23 += v.z;
}

// TEST

public static void main(String[] args) {
Log.start();

try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch (Exception ignored) {}

JFrame frame = new JFrame(CartesianDrivePanel.class.getSimpleName());
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.add(new CartesianDrivePanel(new RobotComponent()));
frame.pack();
frame.setVisible(true);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -93,23 +93,4 @@ public void updateReport(Matrix4d m) {
table.setValueAt(String.format("%.3f", m.m32), 3, 2);
table.setValueAt(String.format("%.3f", m.m33), 3, 3);
}

// TEST

public static void main(String[] args) {
Log.start();

try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch (Exception ignored) {}

Matrix4d m = new Matrix4d();
m.setIdentity();

JFrame frame = new JFrame(CartesianReportPanel.class.getSimpleName());
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.add(new CartesianReportPanel(m));
frame.pack();
frame.setVisible(true);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -74,20 +74,4 @@ private void updateReport(RobotComponent arm) {
}
}
}

// TEST

public static void main(String[] args) {
Log.start();

try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch (Exception ignored) {}

JFrame frame = new JFrame(JacobianReportPanel.class.getSimpleName());
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.add(new JacobianReportPanel(new RobotComponent()));
frame.pack();
frame.setVisible(true);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -373,21 +373,4 @@ public boolean isIdleCommand(ActionEvent e) {
public JPanel getPanel() {
return panel;
}

// TEST

public static void main(String[] args) {
Log.start();

try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch (Exception ignored) {}

JFrame frame = new JFrame(GRBLPresentation.class.getName());
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
GRBLPresentation presentation = new GRBLPresentation(new RobotComponent());
frame.add(presentation.getPanel());
frame.pack();
frame.setVisible(true);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -357,21 +357,4 @@ public boolean isIdleCommand(ActionEvent e) {
public JPanel getPanel() {
return panel;
}

// TEST

public static void main(String[] args) {
Log.start();

try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch (Exception ignored) {}

JFrame frame = new JFrame(MarlinPresentation.class.getName());
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
MarlinPresentation presentation = new MarlinPresentation(new RobotComponent());
frame.add(presentation.getPanel());
frame.pack();
frame.setVisible(true);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.marginallyclever.robotoverlord.systems.robot.robotarm.controlarmpanel.jogpanel;

import com.marginallyclever.convenience.log.Log;
import com.marginallyclever.robotoverlord.components.RobotComponent;
import com.marginallyclever.robotoverlord.swing.translator.Translator;

import javax.swing.*;

public class AngleDrivePanelTest {
public static void main(String[] args) {
Log.start();
Translator.start();
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch (Exception ignored) {}

JFrame frame = new JFrame(AngleDrivePanel.class.getSimpleName());
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.add(new AngleDrivePanel(new RobotComponent()));
frame.pack();
frame.setLocationRelativeTo(null);
frame.setVisible(true);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.marginallyclever.robotoverlord.systems.robot.robotarm.controlarmpanel.jogpanel;

import com.marginallyclever.convenience.log.Log;
import com.marginallyclever.robotoverlord.components.RobotComponent;
import com.marginallyclever.robotoverlord.swing.translator.Translator;

import javax.swing.*;

public class AngleReportPanelTest {
public static void main(String[] args) {
Log.start();
Translator.start();
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch (Exception ignored) {}

JFrame frame = new JFrame(AngleReportPanel.class.getSimpleName());
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.add(new AngleReportPanel(new RobotComponent()));
frame.pack();
frame.setLocationRelativeTo(null);
frame.setVisible(true);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.marginallyclever.robotoverlord.systems.robot.robotarm.controlarmpanel.jogpanel;

import com.marginallyclever.convenience.log.Log;
import com.marginallyclever.robotoverlord.components.RobotComponent;

import javax.swing.*;

public class CartesianDrivePanelTest {
public static void main(String[] args) {
Log.start();

try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch (Exception ignored) {}

JFrame frame = new JFrame(CartesianDrivePanel.class.getSimpleName());
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.add(new CartesianDrivePanel(new RobotComponent()));
frame.pack();
frame.setLocationRelativeTo(null);
frame.setVisible(true);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.marginallyclever.robotoverlord.systems.robot.robotarm.controlarmpanel.jogpanel;

import com.marginallyclever.convenience.log.Log;

import javax.swing.*;
import javax.vecmath.Matrix4d;

public class CartesianReportPanelTest {
public static void main(String[] args) {
Log.start();

try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch (Exception ignored) {}

Matrix4d m = new Matrix4d();
m.setIdentity();

JFrame frame = new JFrame(CartesianReportPanel.class.getSimpleName());
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.add(new CartesianReportPanel(m));
frame.pack();
frame.setLocationRelativeTo(null);
frame.setVisible(true);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.marginallyclever.robotoverlord.systems.robot.robotarm.controlarmpanel.jogpanel;

import com.marginallyclever.convenience.log.Log;
import com.marginallyclever.robotoverlord.components.RobotComponent;

import javax.swing.*;

public class JacobianReportPanelTest {
public static void main(String[] args) {
Log.start();

try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch (Exception ignored) {}

JFrame frame = new JFrame(JacobianReportPanelTest.class.getSimpleName());
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.add(new JacobianReportPanel(new RobotComponent()));
frame.pack();
frame.setLocationRelativeTo(null);
frame.setVisible(true);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public static void main(String[] args) {
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.add(new JogPanel(robot));
frame.pack();
frame.setLocationRelativeTo(null);
frame.setVisible(true);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public static void main(String[] args) {
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.add(new JointHistoryPanel(robot));
frame.pack();
frame.setLocationRelativeTo(null);
frame.setVisible(true);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.marginallyclever.robotoverlord.systems.robot.robotarm.controlarmpanel.presentationlayer;

import com.marginallyclever.convenience.log.Log;
import com.marginallyclever.robotoverlord.components.RobotComponent;
import com.marginallyclever.robotoverlord.swing.translator.Translator;

import javax.swing.*;

public class GRBLPresentationTest {
public static void main(String[] args) {
Log.start();
Translator.start();
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch (Exception ignored) {}

JFrame frame = new JFrame(GRBLPresentation.class.getName());
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
GRBLPresentation presentation = new GRBLPresentation(new RobotComponent());
frame.add(presentation.getPanel());
frame.pack();
frame.setLocationRelativeTo(null);
frame.setVisible(true);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package com.marginallyclever.robotoverlord.systems.robot.robotarm.controlarmpanel.presentationlayer;

import com.marginallyclever.convenience.log.Log;
import com.marginallyclever.robotoverlord.components.RobotComponent;
import com.marginallyclever.robotoverlord.swing.translator.Translator;

import javax.swing.*;

public class MarlinPresentationTest {
public static void main(String[] args) {
Log.start();
Translator.start();
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch (Exception ignored) {}

JFrame frame = new JFrame(MarlinPresentation.class.getName());
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
MarlinPresentation presentation = new MarlinPresentation(new RobotComponent());
frame.add(presentation.getPanel());
frame.pack();
frame.setLocationRelativeTo(null);
frame.setVisible(true);
}
}
Loading

0 comments on commit 4d100bb

Please sign in to comment.