I already fixed a bug Gael pointed out regarding autoDisable happening too soon in a long move. But, this bug flushed out another bug, I call it "Disable to Crazy Move".

It was easier to reproduce when the autoDisable bug was still causing problems, but you can reproduce it currently by doing the following.

1. Create a long move .. This can be done by :
2. Setup an Arduino & Servo
3. Set speed to 10
4. Start the servo at 0 move it to 180
5.  While the servo is moving - disable it.

If you use the webgui - you will see even though its "disabled" the grey position counter keeps moving to 180.
Additionally I can tell you I bet currentPos inside of MrlServo.cpp and the virtual servo are doing the same thing :(

6. wait a little - move the webgui cursor a little CRAZY WILD MOVEMENT !!! ... bad .. very bad

The Fix :

When a servo is disabled, it is "stopped"  even when its in the middle of a move.  So anything trying to calculate its current position (TimeEncoder, MrlServo.cpp, MrlServo.java)  all these need to STOP were they are in processing the move.

Proposal is putting stop() inside of AbstractServo.disable() .. so that the servo stops, then disables.

PR - https://github.com/MyRobotLab/myrobotlab/pull/719


4 years 1 month ago

I'm now working on a ServoTest that will lock the desired behavior for the resolved issue.

In process I notice servo.isMoving() is not behaving as I would expect.

the isSweeping and isMoving are both status variables "THEY SHOULD NEVER BE SET BY CONTROL METHODS !" (dismount soapbox)

So the following would be inappropriate.

I think this is the appropriate place

Added new test to ServoTest to lock in behavior.