We introduced a feature to Easel that estimates the carving time of a design. Modeling the carving time is a complicated endeavor. The goal is to take a series of movements (next position and speed) and estimate the travel time. I will model the problem in several ways, each a bit more physically accurate than the last. You will learn a bit about physics and a bit about motion control.

Each model is explorable. Change the parameters of each model to see how they impact the speed profile and overall travel time.


Input Data

Our carving machines use the standard language for describing machine motion, g-code. It is similar to the imperative drawing API of HTML Canvas. There are different movement modes roughly corresponding to Canvas commands: moveTo (G0), lineTo (G1) and arcTo (G2, G3).

Each G1 carving movement also has a feed rate (F) specifying the speed at which to execute the movement. It is common to use different speeds for movements that carve vs. movements that move the machine above the material.

You can drag the points on the right to see the g-code change. You can also edit the g-code and watch the points change to get a feel for how g-code works.


Model 1: Constant Speed

The simplest way to model machine motion is to simply (and naively) assume that the machine travels at the given speed constantly through the entire movement. This assumes that accelerations between different speeds are instantaneous.

I will plot speed vs. time to help visualize each model. The first model, with instant and infinite acceleration, is a series of discontinuous steps while the machine travels at that movements speed.

This model does not account for the acceleration of the machine. In reality, the motion control system limits acceleration to a certain value to protect the motors.


Model 2: Ramped Speed

We can include the acceleration from one speed to another by ramping up or down at a constant acceleration. Try adjusting the acceleration rates to see how it impacts overall time.

This model respects the maximum acceleration of the machine due to speed changes. However, it does not respect acceleration due to direction changes.


Interlude: Some Physical Intuition

Remember that acceleration is a change in the vector velocity: both the magnitude (speed) and direction. A simple analogy should make this clear. Imagine you are driving in a car along the following roads.

Jim Rodovich drew this on our whiteboard a while back. Only recently has the math caught up with his intuition.

You certainly would not want to drive at the same speed around each curve. At each junction you will experience a force due to your centripetal acceleration around the bend. The question is, how can we take that into account in our motion model?


Model 3: Fixed Junction Speed

You could prevent yourself from cornering too fast by putting a fixed speed limit on all junctions. If that sounds like a bad idea, it is because it is. Grbl used to use this method for motion control before Sonny improved the cornering algorithm. But it is useful to visualize and see why it is a bad idea. You will see the impact it has on the time to complete a series of movements.

Try playing with the acceleration rate and junction speed limit to get an idea. Also pull around the points to change the junction angles. Notice each junction is treated the same, no matter the angle between the points.


Model 4: Dynamic Junction Speed

Hopefully the previous iterations have given you a good bit of intuition about this system. We need to find a model for the maximum speed you can go through a junction that takes into account the acceleration and angle of the junction.

Dimensional Analysis

I want to use one of my favorite physics problem solving tricks here: dimensional analysis. In the next section I will do the math in full, but it is usually a good idea to start with units to get an idea of where we are going. I will use to indicate units of length and units of time.

We are looking for a way to relate junction speed () to acceleration () and angle (unitless). This indicates a problem, we are missing some physical parameter of the system with units of length. We are not sure what this parameter is yet, but putting it in we can guess the final form the equation will take:

where is some value that depends on and has units of length.

Calculating Junction Speed

Centripetal acceleration going around a curve is based on the tangential velocity and the radius of the curve. This radius is the missing physical parameter. We can relate the radius of curvature to the angle at the junction with the following diagram. It involves one physical constant with units of length, shown in green. We call this the junction deviation. Try playing with the junction deviation to see how the radius of curvature changes.

From the diagram above, we can find from and junction deviation:

And using the formula for centripetal acceleration, confirm our earlier unit-based guess

This speed is the maximum speed you can travel through the junction. Try adjusting the junction deviation parameter and the points to form steeper angles to see how they interact.

The junction deviation is only a virtual deviation used to approximate a centripetal acceleration. The machine does not physically round the corners of the given path and there is no change in distance traveled.


Conclusion

Modeling the behavior of a motion planning system needs a bit of physics and a healthy dose of spatial reasoning. Through the iterations on the model we have approached a more and more accurate way to estimate the time that a path will take for a machine based on acceleration and a new physical parameter called junction deviation. Junction deviation is a virtual “cornering radius” that allows you to tune the max speed around curves depending on the junction angle.

The math for junction deviation is based on “Improving Grbl Cornering” by Sonny Jeong.