control.c coord_cubic_active && eoffsets: no Drain

plasmac use case:
  Closing program (m2) after initiating clearing of external offsets
  exposes transient reset of joint->vel_cmd (2 servo periods)
  because of cubicDrain() on transition from coord mode to
  teleop mode.

  This commit: conditionally disable cubicDrain() if external offsets active
  at transition

Thanks to Phillc,snowgoer540 for isolating problem in a sim config
This commit is contained in:
Dewey Garrett 2021-02-27 05:55:08 -07:00
parent 3ff7a32638
commit 9fc45963f6

View file

@ -32,6 +32,7 @@
static int ext_offset_teleop_limit = 0; static int ext_offset_teleop_limit = 0;
static int ext_offset_coord_limit = 0; static int ext_offset_coord_limit = 0;
static double ext_offset_epsilon; static double ext_offset_epsilon;
static bool coord_cubic_active = 0;
/* kinematics flags */ /* kinematics flags */
KINEMATICS_FORWARD_FLAGS fflags = 0; KINEMATICS_FORWARD_FLAGS fflags = 0;
KINEMATICS_INVERSE_FLAGS iflags = 0; KINEMATICS_INVERSE_FLAGS iflags = 0;
@ -835,14 +836,20 @@ static void set_operating_mode(void)
if (joint_num < NO_OF_KINS_JOINTS) { if (joint_num < NO_OF_KINS_JOINTS) {
/* point to joint data */ /* point to joint data */
joint = &joints[joint_num]; joint = &joints[joint_num];
if (coord_cubic_active && *(emcmot_hal_data->eoffset_active)) {
//skip
} else {
cubicDrain(&(joint->cubic)); cubicDrain(&(joint->cubic));
}
positions[joint_num] = joint->coarse_pos; positions[joint_num] = joint->coarse_pos;
} else { } else {
positions[joint_num] = 0; positions[joint_num] = 0;
} }
} }
coord_cubic_active = 0;
/* Initialize things to do when starting teleop mode. */ /* Initialize things to do when starting teleop mode. */
SET_MOTION_TELEOP_FLAG(1); SET_MOTION_TELEOP_FLAG(1);
SET_MOTION_COORD_FLAG(0);
SET_MOTION_ERROR_FLAG(0); SET_MOTION_ERROR_FLAG(0);
kinematicsForward(positions, &emcmotStatus->carte_pos_cmd, &fflags, &iflags); kinematicsForward(positions, &emcmotStatus->carte_pos_cmd, &fflags, &iflags);
@ -1308,6 +1315,7 @@ static void get_pos_cmds(long period)
} // for(axis_num) } // for(axis_num)
/* check joint 0 to see if the interpolators are empty */ /* check joint 0 to see if the interpolators are empty */
coord_cubic_active = 1;
while (cubicNeedNextPoint(&(joints[0].cubic))) { while (cubicNeedNextPoint(&(joints[0].cubic))) {
/* they're empty, pull next point(s) off Cartesian planner */ /* they're empty, pull next point(s) off Cartesian planner */
/* run coordinated trajectory planning cycle */ /* run coordinated trajectory planning cycle */
@ -1332,7 +1340,7 @@ static void get_pos_cmds(long period)
if(!isfinite(positions[joint_num])) if(!isfinite(positions[joint_num]))
{ {
reportError(_("kinematicsInverse gave non-finite joint location on joint %d"), reportError(_("kinematicsInverse gave non-finite joint location on joint %d"),
joint_num); joint_num);
SET_MOTION_ERROR_FLAG(1); SET_MOTION_ERROR_FLAG(1);
emcmotDebug->enabling = 0; emcmotDebug->enabling = 0;
break; break;
@ -1361,7 +1369,7 @@ static void get_pos_cmds(long period)
for (joint_num = 0; joint_num < NO_OF_KINS_JOINTS; joint_num++) { for (joint_num = 0; joint_num < NO_OF_KINS_JOINTS; joint_num++) {
/* point to joint struct */ /* point to joint struct */
joint = &joints[joint_num]; joint = &joints[joint_num];
/* interpolate to get new position and velocity */ /* interpolate to get new position and velocity */
joint->pos_cmd = cubicInterpolate(&(joint->cubic), 0, &(joint->vel_cmd), &(joint->acc_cmd), 0); joint->pos_cmd = cubicInterpolate(&(joint->cubic), 0, &(joint->vel_cmd), &(joint->acc_cmd), 0);
} }
/* report motion status */ /* report motion status */
@ -1418,7 +1426,7 @@ static void get_pos_cmds(long period)
if(!isfinite(positions[joint_num])) if(!isfinite(positions[joint_num]))
{ {
reportError(_("kinematicsInverse gave non-finite joint location on joint %d"), reportError(_("kinematicsInverse gave non-finite joint location on joint %d"),
joint_num); joint_num);
SET_MOTION_ERROR_FLAG(1); SET_MOTION_ERROR_FLAG(1);
emcmotDebug->enabling = 0; emcmotDebug->enabling = 0;
break; break;
@ -1430,8 +1438,8 @@ static void get_pos_cmds(long period)
that fail soft limits, but we'll abort at the end of that fail soft limits, but we'll abort at the end of
this cycle so it doesn't really matter */ this cycle so it doesn't really matter */
cubicAddPoint(&(joint->cubic), joint->coarse_pos); cubicAddPoint(&(joint->cubic), joint->coarse_pos);
/* interpolate to get new position and velocity */ /* interpolate to get new position and velocity */
joint->pos_cmd = cubicInterpolate(&(joint->cubic), 0, &(joint->vel_cmd), &(joint->acc_cmd), 0); joint->pos_cmd = cubicInterpolate(&(joint->cubic), 0, &(joint->vel_cmd), &(joint->acc_cmd), 0);
} }
} }
else else