1
0
Fork 0

let movements accumulate before initiating a move

This commit is contained in:
Kevin Matz 2019-07-31 08:25:11 -04:00
parent 02a775c3be
commit 0c2731bd7f
1 changed files with 18 additions and 3 deletions

View File

@ -28,11 +28,20 @@ class ArmCtlListener(ArmControlListener):
def __init__(self, robot):
self.r = robot
# Enter a parse tree produced by ArmControlParser#statement.
def enterStatement(self, ctx: ArmControlParser.StatementContext):
ctx.doMove = False
# Exit a parse tree produced by ArmControlParser#statement.
def exitStatement(self, ctx: ArmControlParser.StatementContext):
if ctx.doMove:
self.r.move()
# Exit a parse tree produced by ArmControlParser#Go.
def exitGo(self, ctx: ArmControlParser.GoContext):
if ctx.coords() is not None:
self.r.target = ctx.coords().values
self.r.move()
ctx.parentCtx.doMove = True
return
if ctx.name() is None:
logger.error("ERROR: Go command with no name?")
@ -47,7 +56,7 @@ class ArmCtlListener(ArmControlListener):
logger.error("ERROR: preset invalid")
return
self.r.target = preset
self.r.move()
ctx.parentCtx.doMove = True
return
index = int(self.r.config.get(ctx.name().getText(), -1))
@ -55,14 +64,20 @@ class ArmCtlListener(ArmControlListener):
logger.error("Error: axis name not recognized.")
return
self.r.target[index] = ctx.value().value
self.r.move()
ctx.parentCtx.doMove = True
# Exit a parse tree produced by ArmControlParser#Pause.
def exitPause(self, ctx: ArmControlParser.PauseContext):
if ctx.parentCtx.doMove:
ctx.parentCtx.doMove = False
self.r.move()
sleep(ctx.number().value)
# Exit a parse tree produced by ArmControlParser#Wait.
def exitWait(self, ctx: ArmControlParser.WaitContext):
if ctx.parentCtx.doMove:
ctx.parentCtx.doMove = False
self.r.move()
while self.r.isMoving():
pass
if (ctx.number() is not None):