Merge pull request #3739 from larsbrubaker/master

Passing max velocity, acceleration and jerk to slicer
This commit is contained in:
Lars Brubaker 2018-09-20 11:47:35 -07:00 committed by GitHub
commit dc07d2fda9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 23 additions and 70 deletions

View file

@ -214,63 +214,6 @@ namespace MatterControl.Printing
return stringWithNumber;
}
// Vector4 maxAccelerationMmPerS2 = new Vector4(1000, 1000, 100, 5000);
// Vector4 maxVelocityMmPerS = new Vector4(500, 500, 5, 25);
// Vector4 velocitySameAsStopMmPerS = new Vector4(8, 8, .4, 5);
protected static double GetSecondsThisLine(Vector3 deltaPositionThisLine,
double deltaEPositionThisLine,
double feedRateMmPerMin,
Vector4 maxAccelerationMmPerS2,
Vector4 maxVelocityMmPerS,
Vector4 velocitySameAsStopMmPerS,
Vector4 speedMultiplierV4)
{
double lengthOfThisMoveMm = Math.Max(deltaPositionThisLine.Length, deltaEPositionThisLine);
if (lengthOfThisMoveMm == 0)
{
return 0;
}
double maxVelocityMmPerSx = Math.Min(feedRateMmPerMin / 60, maxVelocityMmPerS.X);
double startingVelocityMmPerS = Math.Min(velocitySameAsStopMmPerS.X, maxVelocityMmPerSx);
double endingVelocityMmPerS = startingVelocityMmPerS;
double acceleration = maxAccelerationMmPerS2.X;
double speedMultiplier = speedMultiplierV4.X;
double distanceToMaxVelocity = GetDistanceToReachEndingVelocity(startingVelocityMmPerS, maxVelocityMmPerSx, acceleration);
if (distanceToMaxVelocity <= lengthOfThisMoveMm / 2)
{
// we will reach max velocity then run at it and then decelerate
double accelerationTime = GetTimeToAccelerateDistance(startingVelocityMmPerS, distanceToMaxVelocity, acceleration) * 2;
double runningTime = (lengthOfThisMoveMm - (distanceToMaxVelocity * 2)) / maxVelocityMmPerSx;
return (accelerationTime + runningTime) * speedMultiplier;
}
else
{
// we will accelerate to the center then decelerate
double accelerationTime = GetTimeToAccelerateDistance(startingVelocityMmPerS, lengthOfThisMoveMm / 2, acceleration) * 2;
return (accelerationTime) * speedMultiplier;
}
}
private static double GetDistanceToReachEndingVelocity(double startingVelocityMmPerS, double endingVelocityMmPerS, double accelerationMmPerS2)
{
double endingVelocityMmPerS2 = endingVelocityMmPerS * endingVelocityMmPerS;
double startingVelocityMmPerS2 = startingVelocityMmPerS * startingVelocityMmPerS;
return (endingVelocityMmPerS2 - startingVelocityMmPerS2) / (2.0 * accelerationMmPerS2);
}
private static double GetTimeToAccelerateDistance(double startingVelocityMmPerS, double distanceMm, double accelerationMmPerS2)
{
// d = vi * t + .5 * a * t^2;
// t = (√(vi^2+2ad)-vi)/a
double startingVelocityMmPerS2 = startingVelocityMmPerS * startingVelocityMmPerS;
double distanceAcceleration2 = 2 * accelerationMmPerS2 * distanceMm;
return (Math.Sqrt(startingVelocityMmPerS2 + distanceAcceleration2) - startingVelocityMmPerS) / accelerationMmPerS2;
}
private static readonly bool Is32Bit = IntPtr.Size == 4;
#endregion Static Functions
}

View file

@ -402,8 +402,21 @@ namespace MatterControl.Printing
if (feedRateMmPerMin > 0)
{
instruction.secondsThisLine = (float)GetSecondsThisLine(deltaPositionThisLine, deltaEPositionThisLine, feedRateMmPerMin,
maxAccelerationMmPerS2, maxVelocityMmPerS, velocitySameAsStopMmPerS, speedMultiplier);
var timeForE = Estimator.GetSecondsForMovement(deltaEPositionThisLine,
feedRateMmPerMin / 60.0,
maxAccelerationMmPerS2[3],
maxVelocityMmPerS[3],
velocitySameAsStopMmPerS[3],
speedMultiplier[3]);
var timeForPosition = Estimator.GetSecondsForMovement(deltaPositionThisLine,
feedRateMmPerMin / 60.0,
new Vector3(maxAccelerationMmPerS2),
new Vector3(maxVelocityMmPerS),
new Vector3(velocitySameAsStopMmPerS),
new Vector3(speedMultiplier));
instruction.secondsThisLine = (float)Math.Max(timeForE, timeForPosition);
}
if (progressReporter != null && maxProgressReport.ElapsedMilliseconds > 200)

View file

@ -108,10 +108,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
SettingsKey.model,
SettingsKey.enable_network_printing,
SettingsKey.enable_sailfish_communication,
SettingsKey.max_velocity,
SettingsKey.jerk_velocity,
SettingsKey.print_time_estimate_multiplier,
SettingsKey.max_acceleration,
SettingsKey.ip_address,
SettingsKey.ip_port,
SettingsKey.progress_reporting,
@ -168,6 +165,9 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
new MappedSetting("min_print_speed", "minimumPrintingSpeed"),
new OverrideSpeedOnSlaPrinters("perimeter_speed", "insidePerimetersSpeed", "infill_speed"),
new MappedSetting("raft_air_gap", "raftAirGap"),
new MappedSetting(SettingsKey.max_acceleration, "maxAcceleration"),
new MappedSetting(SettingsKey.max_velocity, "maxVelocity"),
new MappedSetting(SettingsKey.jerk_velocity, "jerkVelocity"),
// fan settings
new VisibleButNotMappedToEngine("enable_fan"), // this is considered when sending fan speeds to slicing
new MappedFanSpeedSetting("min_fan_speed", "fanSpeedMinPercent"),

View file

@ -1924,8 +1924,7 @@
"HelpText": "The maximum amount the printer can accelerate on a G-Code move. Only effects G-Code time estimates, does not change printer behavior.",
"DataEditType": "POSITIVE_DOUBLE",
"DefaultValue": "1000",
"Units": "mm/s²",
"RebuildGCodeOnChange": false
"Units": "mm/s²"
},
{
"SlicerConfigName": "max_velocity",
@ -1933,8 +1932,7 @@
"HelpText": "The maximum speed the printer can move. Only effects G-Code time estimates, does not change printer behavior.",
"DataEditType": "POSITIVE_DOUBLE",
"DefaultValue": "500",
"Units": "mm/s",
"RebuildGCodeOnChange": false
"Units": "mm/s"
},
{
"SlicerConfigName": "jerk_velocity",
@ -1942,8 +1940,7 @@
"HelpText": "The maximum speed that the printer treats as 0 and changes direction instantly. Only effects G-Code time estimates, does not change printer behavior.",
"DataEditType": "POSITIVE_DOUBLE",
"DefaultValue": "8",
"Units": "mm/s",
"RebuildGCodeOnChange": false
"Units": "mm/s"
},
{
"SlicerConfigName": "print_time_estimate_multiplier",

@ -1 +1 @@
Subproject commit ee48276540d35a0b192206f3ce61e360b7bf07c7
Subproject commit 23b9c89d823242f74d3109fe0c68b2213e22d9c9

@ -1 +1 @@
Subproject commit 721ec70bd37432a0f1aade5109b4eb2cea34a6bd
Subproject commit dc4cb0aaaa5fda072b0fd99657b644334c5c19b5