Skip to content

Commit

Permalink
Merge pull request openpnp#1082 from markmaker/feature/advanced-motio…
Browse files Browse the repository at this point in the history
…n-control--7

Feature / Advanced Motion Control - Update 7
  • Loading branch information
markmaker committed Dec 2, 2020
2 parents 0b3969a + 2b85e8c commit e12b91a
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@

import org.openpnp.gui.support.PropertySheetWizardAdapter;
import org.openpnp.gui.support.Wizard;
import org.openpnp.machine.reference.ActuatorInterlockMonitor;
import org.openpnp.machine.reference.ReferenceHeadMountable;
import org.openpnp.machine.reference.ReferenceMachine;
import org.openpnp.machine.reference.axis.ReferenceControllerAxis;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,14 @@ public void setGlobalOffsets(ReferenceMachine machine, AxesLocation axesLocation
ControllerAxis axis = axesLocation.getAxisByVariable(this, variable);
if (axis != null) {
if (hasVariable(command, variable)) {
double coordinate = axesLocation.getCoordinate(axis, getUnits());
double coordinate;
if (axis.getType() == Type.Rotation) {
// Never convert rotation to driver units.
coordinate = axesLocation.getCoordinate(axis);
}
else {
coordinate = axesLocation.getCoordinate(axis, getUnits());
}
command = substituteVariable(command, variable, coordinate);
command = substituteVariable(command, variable+"L",
axis.getLetter());
Expand Down Expand Up @@ -582,8 +589,6 @@ public void moveTo(ReferenceHeadMountable hm, MoveToCommand move)
Double feedRate = move.getFeedRatePerMinute();
Double acceleration = move.getAccelerationPerSecond2();
Double jerk = move.getJerkPerSecond3();
AxesLocation segment = move.getLocation0().motionSegmentTo(allAxesLocation);

double driverDistance = movedAxesLocation.getEuclideanMetric(this, (axis) ->
movedAxesLocation.getLengthCoordinate(axis).convertToUnits(getUnits()).getValue() - axis.getDriverCoordinate()).third;

Expand Down Expand Up @@ -638,8 +643,14 @@ public void moveTo(ReferenceHeadMountable hm, MoveToCommand move)
// The move is definitely on.
doesMove = true;
// TODO: discuss whether we should round to axis resolution here.
double coordinate = allAxesLocation.getLengthCoordinate(axis)
.convertToUnits(getUnits()).getValue();
double coordinate;
if (axis.getType() == Type.Rotation) {
// Never convert rotation to driver units.
coordinate = allAxesLocation.getCoordinate(axis);
}
else {
coordinate = allAxesLocation.getCoordinate(axis, getUnits());
}
double previousCoordinate = axis.getDriverCoordinate();
int direction = ((Double)coordinate).compareTo(previousCoordinate);
// Substitute the axis variables.
Expand Down Expand Up @@ -1182,7 +1193,13 @@ protected boolean processPositionReport(Line line) {
String variable = axis.getLetter();
String s = matcher.group(variable);
Double d = Double.valueOf(s);
position = position.put(new AxesLocation(axis, new Length(d, getUnits())));
if (axis.getType() == Type.Rotation) {
// Rotation axis is not converted from driver units.
position = position.put(new AxesLocation(axis, new Length(d, AxesLocation.getUnits())));
}
else {
position = position.put(new AxesLocation(axis, new Length(d, getUnits())));
}
}
catch (IllegalArgumentException e) {
// Axis is not present in pattern. That's a warning, but might not be supported by controller, so we let it go.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,11 @@ public void setState(Solutions.State state) throws Exception {
commandBuilt = "$H ; Home all axes";
}
else if (tinyG) {
commandBuilt = "G28.2 ; Home all axes";
commandBuilt = "G28.2 ";
for (String variable : gcodeDriver.getAxisVariables(machine)) {
commandBuilt += variable+"0 "; // In TinyG you need to indicate the axis and only 0 is possible.
}
commandBuilt += "; Home all axes";
}
else {
commandBuilt = "G28 ; Home all axes";
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/openpnp/model/Solutions.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public enum Severity {
Warning(new Color(255, 220, 157)),
Error(new Color(255, 157, 157)),
None(new Color(255, 255, 255)),
Fundamental(new Color(255, 157, 157));
Fundamental(new Color(200, 220, 255));

private Color color;

Expand Down

0 comments on commit e12b91a

Please sign in to comment.