SICS-597: Don't drive a motor if it is within precision of the target.
This commit is contained in:
11
motor.c
11
motor.c
@ -689,8 +689,8 @@ static int MotorGetHardPositionImpl(pMotor self, SConnection * pCon,
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static long MotorRunImpl(void *sulf, SConnection * pCon, float fNew)
|
||||
{
|
||||
float fHard;
|
||||
int i, iRet, iCode;
|
||||
float fHard, fCurrHard, fNewHard, fZero;
|
||||
int i, iRet, iCode, iSign;
|
||||
char pBueffel[512];
|
||||
char pError[132];
|
||||
pMotor self;
|
||||
@ -709,6 +709,13 @@ static long MotorRunImpl(void *sulf, SConnection * pCon, float fNew)
|
||||
SCSetInterrupt(pCon, eAbortBatch);
|
||||
return 0;
|
||||
}
|
||||
self->pDriver->GetPosition(self->pDriver, &fCurrHard);
|
||||
iSign = ObVal(self->ParArray, SIGN);
|
||||
fZero = ObVal(self->ParArray, SZERO);
|
||||
fNewHard = iSign * (fNew + fZero);
|
||||
if (absf(fCurrHard - fNewHard) <= ObVal(self->ParArray, PREC)) {
|
||||
return OKOK;
|
||||
}
|
||||
|
||||
/* check boundaries first */
|
||||
iRet = MotorCheckBoundaryImpl(self, fNew, &fHard, pError, 131);
|
||||
|
Reference in New Issue
Block a user