Skip to main content

Module path

Module path 

Source
Expand description

Paths of straight lines, circular arcs and smooth curves through via points in tool coordinates, and the planning of the timing along them. Both planners give poses at times, one per profile cycle, which Command::Trajectory runs.

A path file has one piece per line. The path starts where the machine stands.

line,0.5,0.35              straight to this point: one position per axis
arc,0.6,0.25,0.5,0.25,cw   on a circle to the point (0.6, 0.25) around the centre (0.5, 0.25)
spline,0.7,0.2             on a smooth curve through this point

cw and ccw are seen with the first axis to the right and the second upwards. An arc that ends on the end of the piece before it is a full turn. As the first piece an arc has to end at least 1 mm from where the machine stands (see FIRST_ARC). Spline pieces that follow one another form one curve through all their points (see spline); it leaves the line or arc before it in that piece’s direction and ends in the direction the line or arc after it starts with. Lines work on any number of axes; arcs and splines on two and on three (see below). Empty lines and lines starting with # are skipped.

On a machine with three axes (x, y, z) a line has three positions (line,0.1,0.0,-0.8), and so does a spline point. An arc gives its end and its centre with three positions each, arc,x,y,z,cx,cy,cz,cw: it lies in the plane through where it starts, its end and its centre, and cw/ccw is seen from the side of that plane its normal points to when the normal is taken upwards (+z); for a vertical plane, towards the viewer (-y), as the scene looks at the machine; for the y-z plane, from +x. So an arc in the x-z plane is seen as on a two-axis machine with x and z. What three axes do not have: a full turn (start and end the same). A half turn (start, centre and end on one line) leaves the plane open: a program states it (Piece::Arc::plane, G17, G18, G19, the three points of a MoveC), else it is laid in the first of the x-y, x-z and y-z planes that holds the line; one that no such plane holds, or that the stated plane does not hold, is refused. Transition curves on three axes are laid in the plane of the arc they meet (blend3); where two arcs in different planes meet, the path passes as given.

Where the axes are x, y, z and an orientation as a rotation vector rx, ry, rz (an arm in tool space), a line moves the place straight and turns the orientation by slerp (Geo::Slerp): about one fixed axis at a steady rate, not along the straight line between the two rotation vectors, which is not the same turn where they are not parallel.

Structs§

LoopKeep
What speed_kept_of takes of one motor’s loop and drive: the loop’s integral gain (N m per rad), the share of the torque J a its precontrol gives, the drive’s peak torque (N m) and the top speed (rad/s) the share is taken over.
PlanLimits
What a time-optimal plan keeps within beside each motor’s torque-speed curve, its rated speed and the axes’ jerk limits (see plan_time_optimal).
Tolerance
How far a planned path may leave the pieces as given: path for the transition curves where pieces meet in their direction (profile.path_tolerance_m), corner for rounding the corners (round_corners, profile.corner_tolerance_m). A tolerance alone is a path tolerance, with corners stopped at.

Enums§

Piece

Constants§

ARC_SLACK
For an arc that is the first piece: how far its end may be off the circle through its start (the planners’ slack). A path starts at the setpoint of the machine at rest, which is where the motors stand: under belt stretch and gear twist that far from the pose the file was written for. The controller passes Machine::setpoint_slack (12 and 46 um on a gantry holding its Z axis against gravity, within this default of 0.1 mm; more on the delta, whose gearboxes sag under the platform); this is for a path from a stated point.

Functions§

deviation
How far the path that is planned for these pieces is from the pieces as given, at most: the deviation the transition curves make, plus how far an arc ends off its stated end (given). Zero with a tolerance of zero and arcs that end on their circles. For the plan within the axis limits. A program’s run with a feed per piece (plan_feeds) is shaped per stretch of one feed, with no curve across a change of feed and shorter curves at a lower feed: this reads it as without the feeds, so it may read higher than that run’s own path, never lower, and never more than the larger of the two tolerances plus how far an arc ends off its stated end.
deviation_time_optimal
deviation for the path plan_time_optimal plans: its transition curves are as long as the speeds the motors allow need them to be, not the speeds of the axis limits. Refused as that plan is.
parse
Reads a path file (format: see the top of this file). The error is the line that cannot be read.
parse_trajectory
Reads a path given as poses at times: per line the time in seconds and one position per axis. Lines that do not start with a number (a header, comments) are skipped. The error is the line that cannot be read.
plan
Plans the timing of a path within the velocity, acceleration and jerk limits of every axis, from rest to rest.
plan_at
plan with the speed along the path no higher than feed (in the axes’ units per second, the length of the speed vector over all axes): a program’s feed (G-code F, a robot’s v or $VEL.CP), which is the speed along the path, not along each axis. Infinite: the axes’ limits alone.
plan_feeds
plan_at with a feed per piece (feeds[i] for pieces[i]; none or too few: no cap): a program’s blocks at their own feeds, planned as one path, no stop between them. Each piece’s speed is bound by its own feed and the path passes from one piece into the next at the lower of the two feeds at most, with the junction’s own limit (timed). The stretches at one feed are shaped on their own (geometry_fed).
plan_time_optimal
Plans the timing of a path as fast as the motors allow, within the jerk limits of the axes, point by point.
plan_within
plan_feeds with the flange’s angular speed and acceleration limits spin (rad/s, rad/s^2; MotionLaw::spin, an arm in tool space) kept on the pieces that turn by slerp: about one axis, so the flange turns at the angle between their orientations over their length times the speed along the path, and accelerates as much times the path’s acceleration (no other part, the axis fixed). The axes’ limits bound the rotation vector’s rates only, which spin the flange faster away from no turn.
speed_kept_of
The share of its top speed top (rad/s) that a motor’s velocity loop follows a ramp of acceleration acc (rad/s^2) off by, at most, from the loop’s integral gain ki (N m per rad), the inertia inertia (kg m^2) it is tuned for and the share feedforward of the torque J a that the precontrol gives. The speed error e of the PI loop on a ramp a t, with the loop’s torque (1 - feedforward) J a to find, obeys J e’’ + kp e’ + ki e = 0 with e’(0) = (1 - feedforward) a, whose peak is at most (1 - feedforward) a / w_n for the natural frequency w_n = sqrt(ki / J) (the underdamped peak a/w_n exp(-z acos(z) / sqrt(1 - z^2)) is below it, as is the critical a/(e w_n)). The share is that over top, at least SPEED_KEPT: a loop that follows a ramp closely keeps the least. On top of it the speed train (rad/s) that an elastic drive train adds (train_speed); at most SPEED_KEPT_MOST in all.
train_speed
How much faster than the plan’s rigid motion a motor runs with an elastic drive train (Machine::trains) while its acceleration changes at the jerk jerk (rad/s^3), rad/s. Two masses on a spring k, the rotor’s side J_m and the load’s J_L (s = J_L / (J_m + J_L), w^2 = k / J_L the load’s frequency against the motor held), the motor’s torque the rigid (J_m + J_L) a(t): the twist x = theta_m - theta_L obeys x’’ + k (1/J_m + 1/J_L) x = (J_m + J_L) / J_m a, so at a steady a it holds x = a / w^2, and while a changes at j it grows at x’ = j / w^2 (to which the free swing (j / w^2) (1 - cos) settles about its mean). The motor runs ahead of the masses’ common speed by s x’, so by s j / w^2; the swing’s peak is twice that, which the velocity loop damps. A ramp quicker than the train’s swing is a step of the acceleration acc (rad/s^2, the most the motor has): x = acc / w^2 (1 - cos W t) at the swing’s own frequency W = sqrt(k (1/J_m + 1/J_L)) = w / sqrt(1 - s), so x’ peaks at acc W / w^2 however high the jerk limit; the lower of the two.