diff --git a/g2core/gcode.h b/g2core/gcode.h index e8fee655..bf915bd4 100644 --- a/g2core/gcode.h +++ b/g2core/gcode.h @@ -176,7 +176,7 @@ typedef enum { // axis modes (ordered: see _cm_get_feed_time()) /* Gcode state structures */ -/***************************************************************************** +/**************************************************************************************** * GCODE MODEL - The following GCodeModel/GCodeInput structs are used: * * - gm is the core Gcode model state. It keeps the internal gcode state model in @@ -193,22 +193,23 @@ typedef enum { // axis modes (ordered: see _cm_get_feed_time()) * Other Gcode model state is kept in the singletons for various sub-systems, such * as arcs, spindle, coolant, and others (i.e. not ALL gcode global state is in gmx) * - * - gn is used by the gcode interpreter and is re-initialized for each - * gcode block.It accepts data in the new gcode block in the formats - * present in the block (pre-normalized forms). During initialization - * some state elements are necessarily restored from gm. + * - gn is used by the gcode interpreter and is re-initialized for each gcode block. + * It accepts data in the new gcode block in the formats present in the block + * (pre-normalized forms). During initialization some state elements are necessarily + * restored from gm. * - * - gf is used by the gcode parser interpreter to hold flags for any data - * that has changed in gn during the parse. gf.target[] values are also used - * by the canonical machine during set_target(). + * - gf is used by the gcode parser interpreter to hold flags for any data that has + * changed in gn during the parse. gf.target[] values are also used by the + * canonical machine during set_target(). * - * - cfg (config struct in config.h) is also used heavily and contains some - * values that might be considered to be Gcode model values. The distinction - * is that all values in the config are persisted and restored, whereas the - * gm structs are transient. So cfg has the G54 - G59 offsets, but gm has the - * G92 offsets. cfg has the power-on / reset gcode default values, but gm has - * the operating state for the values (which may have changed). + * - cfg (config struct in config.h) is also used heavily and contains some values + * that might be considered to be Gcode model values. The distinction is that all + * values in the config are persisted and restored, whereas the gm structs are + * transient. So cfg has the G54 - G59 offsets, but gm has the G92 offsets. + * cfg has the power-on / reset gcode default values, but gm has the operating + * state for the values (which may have changed). */ + typedef struct GCodeState { // Gcode model state - used by model, planning and runtime uint32_t linenum; // Gcode block line number cmMotionMode motion_mode; // Group1: G0, G1, G2, G3, G38.2, G80, G81, diff --git a/g2core/plan_exec.cpp b/g2core/plan_exec.cpp index 938f47cf..c1f40e3f 100644 --- a/g2core/plan_exec.cpp +++ b/g2core/plan_exec.cpp @@ -540,8 +540,8 @@ stat_t mp_exec_aline(mpBuf_t *bf) st_request_forward_plan(); } } - copy_vector(mr->end_position, mr->position); // record end position - copy_vector(mp->position, mr->position); // record end position +//+++++ copy_vector(mr->end_position, mr->position); // record end position + copy_vector(mp->position, mr->position); // record actual end position of the move } return (status); } @@ -1027,14 +1027,13 @@ static stat_t _exec_aline_feedhold(mpBuf_t *bf) cm->hold_state = FEEDHOLD_OFF; } - // In a regular p1 hold + // In a regular p1 hold. Motion has stopped, so we can rely on positions and other values to be stable else { // Reset the state of the p1 planner regardless of how hold will ultimately be exited. bf->length = get_axis_vector_length(mr->position, mr->target); // get remaining length in move - copy_vector(mp->position, mr->position); // update planner position from runtime - copy_vector(mr->end_position, mr->position);// record end position - + copy_vector(mp->position, mr->position); // update planner position from runtime position + bf->block_state = BLOCK_INITIAL_ACTION; // tell _exec to re-use the bf buffer mr->block_state = BLOCK_INACTIVE; // invalidate mr buffer to reset the new move bf->plannable = true; // needed so black can be adjusted @@ -1045,7 +1044,7 @@ static stat_t _exec_aline_feedhold(mpBuf_t *bf) // Set state to enable transition to p2 and perform entry actions in the p2 planner cm->hold_state = FEEDHOLD_ACTIONS_START; // executes entirely out of p2 planner } - + sr_request_status_report(SR_REQUEST_IMMEDIATE); cs.controller_state = CONTROLLER_READY; // remove controller readline() PAUSE } diff --git a/g2core/planner.h b/g2core/planner.h index c6ebe396..ed997eba 100644 --- a/g2core/planner.h +++ b/g2core/planner.h @@ -338,7 +338,6 @@ typedef struct mpBuffer { blockHint hint; // hint the block for zoid and other planning operations. Must be accurate or NO_HINT // block parameters -// float position[AXES]; // XYZABC position at start of move float unit[AXES]; // unit vector for axis scaling & planning bool axis_flags[AXES]; // set true for axes participating in the move & for command parameters @@ -391,7 +390,6 @@ typedef struct mpBuffer { hint = NO_HINT; for (uint8_t i = 0; i< AXES; i++) { -// position[i] = 0; unit[i] = 0; axis_flags[i] = 0; } @@ -456,7 +454,7 @@ typedef struct mpPlannerRuntime { // persistent runtime variables bool axis_flags[AXES]; // set true for axes participating in the move float target[AXES]; // final target for bf (used to correct rounding errors) float position[AXES]; // current move position - float end_position[AXES]; // endpoint position of previous move +// float end_position[AXES]; // endpoint position of previous move +++++ float waypoint[SECTIONS][AXES]; // head/body/tail endpoints for correction float target_steps[MOTORS]; // current MR target (absolute target as steps)