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)
|
static long MotorRunImpl(void *sulf, SConnection * pCon, float fNew)
|
||||||
{
|
{
|
||||||
float fHard;
|
float fHard, fCurrHard, fNewHard, fZero;
|
||||||
int i, iRet, iCode;
|
int i, iRet, iCode, iSign;
|
||||||
char pBueffel[512];
|
char pBueffel[512];
|
||||||
char pError[132];
|
char pError[132];
|
||||||
pMotor self;
|
pMotor self;
|
||||||
@ -709,6 +709,13 @@ static long MotorRunImpl(void *sulf, SConnection * pCon, float fNew)
|
|||||||
SCSetInterrupt(pCon, eAbortBatch);
|
SCSetInterrupt(pCon, eAbortBatch);
|
||||||
return 0;
|
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 */
|
/* check boundaries first */
|
||||||
iRet = MotorCheckBoundaryImpl(self, fNew, &fHard, pError, 131);
|
iRet = MotorCheckBoundaryImpl(self, fNew, &fHard, pError, 131);
|
||||||
|
Reference in New Issue
Block a user