import Nice
import SharknirDrot
drot = SharknirDrot.DROT.connectWithEndpoint("drotPY", "[NAME=track_ctrl-svr,PORT=50300,PATH=TRACK_CTRL.DROT.DEROTATOR.1.SVC]")
drot.moveAbsolute(0, "STEPS")
i = 1
minStepInc = 1
absEncPos = drot.getAbsoluteEncoderPosition()

print ("Absolute Encoder starting position is {}".format(absEncPos))
print ("Covering the backlash ...")
while (absEncPos == drot.getAbsoluteEncoderPosition()):
    absEncPos = drot.getAbsoluteEncoderPosition()
    print ("Moving to {}".format(i*minStepInc))
    drot.moveAbsoluteStart(i*minStepInc,"STEPS")
    i += 1
    drot.moveAbsoluteWait()
    if (absEncPos != drot.getAbsoluteEncoderPosition()):
        break

print ("Absolute Encoder position is now {} after {} motor steps".format(drot.getAbsoluteEncoderPosition(), i*minStepInc))

