It is useful, to wait a finished moveTo() before to launch another. Without using a sleep(x) between 2 actions. because sleep() didn't take care of servo speed .
The magic will worky only if velocity > 0
There are several levels :
1 servo blocking event
Like a speakBlocking event, the next line will wait the previous one.
leftArm.bicep.moveToBlocking(0)
leftArm.bicep.moveToBlocking(180)
print "finished"
1 group of servo
Every servo of the group run at same time and wait until all the servo have finished the movement
i01.moveHeadBlocking(85,90,0)
1 global command
To wait for previous no blocking events
rest()
i01.waitTargetPos
print "robot is rest()"
Just pushed, maybe require some adjustment
No worky inside Virtual environment because no relation between Velocity and servo event at this time
Result is not worky as I
Result is not worky as I expect. I Will find good method
method changed to used
method changed to used synchronized things between wait event and servo position+disable status.
Seem robust now. Need more test.
Hi Moz4r, I think
Hi Moz4r,
I think moveToBlocking is a great idea, and I assume your using a stop event to release the blocking ?
Hi! I've tried lots of
Hi! I've tried lots of things, the published thing seems stable and do not cause interferences to moveTo thread. MoveToBlocking is conditioned by the finished event of a moveTo + autodisable delay if used.
What I have done is to use a synchronized object
Blocked event:
https://github.com/MyRobotLab/myrobotlab/blob/4f404e4dc237767817c1688d6240405ae6d83db1/src/org/myrobotlab/service/Servo.java#L515
Notify event to release the blocked event
https://github.com/MyRobotLab/myrobotlab/blob/4f404e4dc237767817c1688d6…
Notify event to release the blocked event if isAutoDisabled:
https://github.com/MyRobotLab/myrobotlab/blob/4f404e4dc237767817c1688d6240405ae6d83db1/src/org/myrobotlab/service/Servo.java#L542
Seems like a good
Seems like a good implementation moz4r ! Safety 30 seconds instead of infinite block is probably a good idea too. I'm going to do a little standardization & formatting.
log.error("something intelligent about the error", e);
this is now "classified" as an error and is controlled by the logger - done this way with the exception as the second parameter we will get the stack trace in the log file.
If interruption may be a valid use case, you might not want to log it as an error.
Since moveTo can release the thread (non error) - I changed it to
log.info("servo {} moveToBlocked was interrupted", getName());
/** above a comment then press enter and the comment will partially write itself !
You just need to fill in the details
I see now this ?
But I see in the comments .. "TODO - moveToBlocking - blocks until servo sends "ARRIVED_TO_POSITION" response"
Heh, it seemed like you set everything up well to have signalling done correctly .. and then didn't implement it ? Was there an issue in the appropriate signal ?
Was also curious about the
Was also curious about the method returning boolean, were you thinking it would return true if it completed the move and return false if it was interrupted ? If so should probably return false after the catch & log statement.
Thank for the time you take
Thank for the time you take to review. I will learn best practices. It is very useful.
About boolean , if a moveToBlocking() action is initiate, it will finish, there is no reason.
Exept if there is an other move action to the same servo initiated from an other thread. So at this time , this action will break the first moveToBlocking action. Personaly, I dont have utility to read if the moveToAction was breaked or not. But may be useful later for others.
About the second conditon : if velocity==-1 :
If velocity is not set ( set to max ) , we cannot know if the servo had finished the move, because magic cannot do the job. There is defaut autoDisable thing set to 10 seconds. This is only "estimated" thing. Beter is to set a velocity. A moveToBlocking() is not accurate if velocity==-1.