motion: check for kinematicsInverse failures

.. and NaN and inf returns of joint positions from kinematicsInverse
This commit is contained in:
Jeff Epler 2013-07-18 13:43:23 -05:00 committed by Sebastian Kuzminsky
parent 6f9ae3cf86
commit 4b8995385c
2 changed files with 70 additions and 24 deletions

View file

@ -256,7 +256,12 @@ STATIC int inRange(EmcPose pos, int id, char *move_type)
}
/* now fill in with real values, for joints that are used */
kinematicsInverse(&pos, joint_pos, &iflags, &fflags);
if (kinematicsInverse(&pos, joint_pos, &iflags, &fflags) < 0)
{
reportError(_("%s move on line %d fails kinematicsInverse"),
move_type, id);
return 0;
}
for (joint_num = 0; joint_num < emcmotConfig->numJoints; joint_num++) {
/* point to joint data */

View file

@ -1127,10 +1127,20 @@ static void get_pos_cmds(long period)
tpGetPos(&emcmotDebug->coord_tp, &emcmotStatus->carte_pos_cmd);
/* OUTPUT KINEMATICS - convert to joints in local array */
kinematicsInverse(&emcmotStatus->carte_pos_cmd, positions,
result = kinematicsInverse(&emcmotStatus->carte_pos_cmd, positions,
&iflags, &fflags);
if(result == 0)
{
/* copy to joint structures and spline them up */
for (joint_num = 0; joint_num < emcmotConfig->numJoints; joint_num++) {
if(!isfinite(positions[joint_num]))
{
reportError(_("kinematicsInverse gave non-finite joint location on joint %d"), joint_num);
SET_MOTION_ERROR_FLAG(1);
SET_MOTION_ENABLE_FLAG(0);
emcmotDebug->enabling = 0;
break;
}
/* point to joint struct */
joint = &joints[joint_num];
joint->coarse_pos = positions[joint_num];
@ -1139,6 +1149,16 @@ static void get_pos_cmds(long period)
this cycle so it doesn't really matter */
cubicAddPoint(&(joint->cubic), joint->coarse_pos);
}
}
else
{
reportError(_("kinematicsInverse failed"));
SET_MOTION_ERROR_FLAG(1);
SET_MOTION_ENABLE_FLAG(0);
emcmotDebug->enabling = 0;
break;
}
/* END OF OUTPUT KINS */
}
/* there is data in the interpolators */
@ -1182,9 +1202,19 @@ static void get_pos_cmds(long period)
to compute the next positions of the joints */
/* OUTPUT KINEMATICS - convert to joints in local array */
kinematicsInverse(&emcmotStatus->carte_pos_cmd, positions, &iflags, &fflags);
result = kinematicsInverse(&emcmotStatus->carte_pos_cmd, positions, &iflags, &fflags);
/* copy to joint structures and spline them up */
if(result == 0)
{
for (joint_num = 0; joint_num < emcmotConfig->numJoints; joint_num++) {
if(!isfinite(positions[joint_num]))
{
reportError(_("kinematicsInverse gave non-finite joint location on joint %d"), joint_num);
SET_MOTION_ERROR_FLAG(1);
SET_MOTION_ENABLE_FLAG(0);
emcmotDebug->enabling = 0;
break;
}
/* point to joint struct */
joint = &joints[joint_num];
joint->coarse_pos = positions[joint_num];
@ -1197,6 +1227,17 @@ static void get_pos_cmds(long period)
joint->pos_cmd = cubicInterpolate(&(joint->cubic), 0, 0, 0, 0);
joint->vel_cmd = (joint->pos_cmd - old_pos_cmd) * servo_freq;
}
}
else
{
reportError(_("kinematicsInverse failed"));
SET_MOTION_ERROR_FLAG(1);
SET_MOTION_ENABLE_FLAG(0);
emcmotDebug->enabling = 0;
break;
}
/* END OF OUTPUT KINS */
/* end of teleop mode */