yarf 0.1
Yet Another RepRap Firmware
|
The lookahead component tries to keep the speed at which movements are made as high as possible. That is, it tries to raise the entry and exit speeds of blocks, while at the same time preventing jerky movement. The code is based on chamnit's fork of Grbl (https://github.com/chamnit/grbl). More...
#include "planner_lookahead.h"
#include "yarf.h"
#include "planner.h"
#include "planner_queue.h"
#include "util/math.h"
#include <stdint.h>
#include <string.h>
Go to the source code of this file.
Functions | |
static speed_t | max_allowable_speed (speed_t target_speed, float distance_mm) |
Returns the highest speed that will still allow the machine to reach a given target speed within a given distance, without decelerating faster than the configured acceleration. | |
static void | reverse_pass_kernel (block_t *current, block_t *next) |
The kernel for the reverse pass of the lookahead algorithm. | |
static void | reverse_pass (void) |
Calls the reverse pass kernel for each element of the planning queue, in reverse order. | |
static void | forward_pass_kernel (block_t *previous, block_t *current) |
The kernel for the forward pass of the lookahead algorithm. | |
static void | forward_pass (void) |
Calls the forward pass kernel for each element of the planning queue, in forward order. | |
static void | recalculate_trapezoids (void) |
Calls the plan_calculate_trapezoid method from the planner component for each block in the planning queue for which the entry or exit speed was changed by the reverse or forward passes of the lookahead algorithm. | |
static void | recalculate_motion_plan (void) |
Recalculates the motion plan for the entire queue of blocks by first calling the reverse pass, then calling the forward pass and finally calling the recalculate_trapezoids method, to recalculate the acceleration parameters based on the changes to the entry speeds performed by the reverse and forward passes. | |
void | plan_lookahead_init () |
Initializes the lookahead component. | |
void | plan_lookahead () |
Updates the motion plan for the entire planning queue, to account for the additional contraints on the motion plan, imposed by the last block that was added to the queue. | |
Variables | |
struct { | |
float direction [NUM_AXES] | |
The four-dimensional unit direction vector (containing the direction cosines for each axis) of the previous block. | |
float plateau_speed | |
The plateau speed (the maximum speed) of the previous block in mm/min. | |
} | previous_block_info |
The lookahead component tries to keep the speed at which movements are made as high as possible. That is, it tries to raise the entry and exit speeds of blocks, while at the same time preventing jerky movement. The code is based on chamnit's fork of Grbl (https://github.com/chamnit/grbl).
Definition in file planner_lookahead.c.
static void forward_pass | ( | void | ) | [static] |
Calls the forward pass kernel for each element of the planning queue, in forward order.
That is, the block that will be executed first by the block handler (the block at the tail of the queue) is handled first and the block that was added last to the planning queue will be handled last. The forward pass is performed after the reverse pass.
Definition at line 204 of file planner_lookahead.c.
The kernel for the forward pass of the lookahead algorithm.
previous | pointer to the block that will be executed by the block handler before the block referred to by current, i.e. the block processed previously by this kernel. |
current | pointer to the block to which to apply this kernel |
Lowers the entry speed of the block pointed to by current, if necessary. The entry speed needs to be lowered if the previous block is slow and too short for the machine to be able to accelerate up to the entry speed of the current block.
Definition at line 172 of file planner_lookahead.c.
Returns the highest speed that will still allow the machine to reach a given target speed within a given distance, without decelerating faster than the configured acceleration.
target_speed | the speed that needs to be reached after distance_mm |
distance_mm | the distance after which the target speed must be reached |
speed ^ | +-----+ <-- return value | : \ | : \ | : + <-- target speed | : | | +------:---+ | : : | ^----- distance_mm |______________________ distance traveled -->
You can also view this function as returning the maximum obtainable speed, within a given distance, starting from target_speed and without exceeding the configured acceleration.
Definition at line 92 of file planner_lookahead.c.
void plan_lookahead | ( | void | ) |
Updates the motion plan for the entire planning queue, to account for the additional contraints on the motion plan, imposed by the last block that was added to the queue.
To use the lookahead component, this method should be called right after adding a new block to the planning queue.
The lookahead component tries to keep the speed in between blocks as high as possible, without causing jerky movement at the junctions between blocks.
Definition at line 284 of file planner_lookahead.c.
static void recalculate_trapezoids | ( | void | ) | [static] |
Calls the plan_calculate_trapezoid method from the planner component for each block in the planning queue for which the entry or exit speed was changed by the reverse or forward passes of the lookahead algorithm.
The exit speed of a block is set equal to entry speed of the next block in the queue (the block that will be executed next by the block handler).
speed ^ | | +-------+ | / \ entry speed --|-> + \ | | + <-- exit speed = | +------------+ next->entry_speed |____________________________ time -->
Definition at line 237 of file planner_lookahead.c.
static void reverse_pass | ( | void | ) | [static] |
Calls the reverse pass kernel for each element of the planning queue, in reverse order.
That is, the block that was added last to the planning queue will be handled first and the block that will be executed first by the block handler (the block at the tail of the queue) is handled last. The reverse pass is performed before the forward pass.
Definition at line 145 of file planner_lookahead.c.
The kernel for the reverse pass of the lookahead algorithm.
current | pointer to the block to which to apply this kernel |
next | pointer to the block that will be executed by the block handler after the block referred to by current, i.e. the block processed previously by this kernel. |
This kernel tries to raise the entry speed of the block pointed to by current. It will raise the entry speed as high as possible, while still making sure the machine has time enough to be able to decelerate down to the entry speed of the next block. Also, the entry speed will never be raised higher than the block's max_entry_speed, which was calculated earlier in the plan_lookahead method, based on the angle between this block and the previous block (the block that is executed by the block handler before the block pointed to by current).
Definition at line 117 of file planner_lookahead.c.
float direction[NUM_AXES] |
The four-dimensional unit direction vector (containing the direction cosines for each axis) of the previous block.
Definition at line 52 of file planner_lookahead.c.
float plateau_speed |
The plateau speed (the maximum speed) of the previous block in mm/min.
Definition at line 53 of file planner_lookahead.c.