def onVectorValueReceived(vectorName, vectorValue, invalid): global cursorR global cursorL global HistBallR global histR global HistBallL global histL global boxL global boxR global targettol global target global steptimeL global steptimeR global scalorxx global RCOUNT global LCOUNT global Rforceold global Lforceold global rvideo global lvideo global Rquad global Lquad #global data #print(data) #print(vectorName) if (vectorName == 'BallPositionR') and not invalid: # look for the BallPosition variable in the data stream# mmserver.sendVectorValue('ReturnedBallPositionR', vectorValue) # echo back the value of BallPosition to #MotionMonitor mmserver.sendScalarValue('RCOUNT',RCOUNT) cursorR.setScale(0.1,vectorValue[2]*scalorxx,0.01250)#scale height according to step time in Z direction # print(vectorValue[0]) if (vectorValue[2] <= 0.1): HistBallR.setPosition([0.2, histR*scalorxx, 0])#update yellow history bar when HS happens steptimeR = histR else: histR = vectorValue[2] if (abs(steptimeR-targetR) <= targettol):#highlight the target when the target is hit gold = boxR.getColor(node = '') # boxR.color( viz.WHITE ) rvideo.play() else: gold = boxR.getColor(node = '') boxR.color( viz.BLUE ) if (vectorValue[0] < -20) & (Rforceold == 0.0) & (abs(steptimeR-targetR) <= targettol): RCOUNT = RCOUNT+1 #rightcounter.setText(str(RCOUNT)) rightcounter.message(str(RCOUNT)) Rforceold = vectorValue[0] if (vectorName == 'BallPositionL') and not invalid: mmserver.sendVectorValue('ReturnedBallPositionL', vectorValue) mmserver.sendScalarValue('LCOUNT',LCOUNT) cursorL.setScale(0.1,vectorValue[2]*scalorxx,0.01250)#scale cursor according to step time in Z direction if (vectorValue[2] <= 0.1): HistBallL.setPosition([-0.2, histL*scalorxx, 0]) steptimeL = histL else: histL = vectorValue[2] if (abs(steptimeL-targetL) <= targettol): boxL.color( viz.WHITE ) lvideo.play() else: boxL.color( viz.BLUE ) if (vectorValue[0] < -20) & (Lforceold == 0.0) & (abs(steptimeL-targetL) <= targettol): LCOUNT = LCOUNT+1 #leftcounter.setText(str(LCOUNT)) leftcounter.message(str(LCOUNT)) Lforceold = vectorValue[0]
def onVectorValueReceived(vectorName, vectorValue, invalid): global ballR global ballL global HistBallR global histR global HistBallL global histL global boxL global boxR global targettol global target global steplengthL global steplengthR #global psudoR #global psudoL global neutralL global neutralR global RCOUNT global LCOUNT global Rforceold global Lforceold if (vectorName == 'BallPositionR') and not invalid: # look for the BallPosition variable in the data stream# mmserver.sendVectorValue('ReturnedBallPositionR', vectorValue) # echo back the value of BallPosition to #MotionMonitor mmserver.sendScalarValue('RCOUNT',RCOUNT) #update Cursor ball position to reflect where the foot is in sagittal plane motion cursorR.setScale(0.1,vectorValue[0],0.01250)#scale cursor according to step time in Z direction #hide the cursor ball if the foot is behind the pelvis if (vectorValue[0] < 0) | (vectorValue[2] < 0):# | (vectorValue[0] <= psudoR): cursorR.visible(0) neutralR.visible(1) #HistBallR.visible(0)#turn of the history ball so its not confusing else: cursorR.visible(1) neutralR.visible(0) #HistBallR.visible(1) #*!*!*!*!*!*!*Hide the target box and cursor when the subject begins to move for the target. Hides upon toe-off. Also hide the history ball ''' if (vectorValue[2] == 0): boxR.visible(0) ballR.visible(0) HistBallR.visible(0) else: boxR.visible(1) ballR.visible(1) HistBallR.visible(1) ''' #set history ball based on local maximum relative to anterior pelvic Y direction########################## #if (vectorValue[0] > histR) & (vectorValue[0] > 0): # HistBallR.setPosition([- vectorValue[1], 0, vectorValue[0]])#update yellow history ball when HS happens # steplengthR = histR # histR = vectorValue[0] #else: # histR = vectorValue[0] #set history at heel strike#################################### if (vectorValue[2] < 0) & (histR == 0): if (vectorValue[0] < targettol): HistBallR.visible(0) HistBallR.setPosition([0.2, vectorValue[0], 0])#update yellow history ball when HS happens else: HistBallR.visible(1) HistBallR.setPosition([0.2, vectorValue[0], 0])#update yellow history ball when HS happens steplengthR = vectorValue[0] histR = vectorValue[2] else: histR = vectorValue[2] if (abs(steplengthR-targetR) <= targettol):#highlight the target when the target is hit boxR.color( viz.WHITE ) else: boxR.color( viz.BLUE ) #determine if step was the right length if (vectorValue[2] < -20) & (Rforceold == 0.0) & (abs(steplengthR-targetR) <= targettol): RCOUNT = RCOUNT+1 rightcounter.message(str(RCOUNT)) Rforceold = vectorValue[2] #lastly, determine if the right belt needs to move************************************************** if (vectorValue[2] < 0) & (vectorValue[0] > 0.02):#subject is on forceplate, and foot is away from neutral #print(vectorValue[0]) #time.sleep(0.1) RightBeltSpeed = 0.1 else: RightBeltSpeed = 0 #send speed command as long as there is enough time left in the 30s of capture if ((time.time()-mmserver.starttime) > 158): print('session is ending...') mmserver.sendScalarValue('RightBeltSpeed',0) else: mmserver.sendScalarValue('RightBeltSpeed',RightBeltSpeed) #print('mmserver starttime was:') #print(mmserver.starttime) if (vectorName == 'BallPositionL') and not invalid: mmserver.sendVectorValue('ReturnedBallPositionL', vectorValue) mmserver.sendScalarValue('LCOUNT',LCOUNT) cursorL.setScale(0.1,vectorValue[0],0.01250)#scale cursor according to step time in Z direction #hide cursor ball if foot is posterior to pelvis if (vectorValue[0] < 0) | (vectorValue[2] < 0):# | (vectorValue[0] <= psudoL): cursorL.visible(0) neutralL.visible(1) #HistBallL.visible(0) else: cursorL.visible(1) neutralL.visible(0) #HistBallL.visible(1) #*!*!*!*!*!*!*Hide the target box when the subject begins to move for the target. Hides upon toe-off. Also hide history ball """ if (vectorValue[2] == 0): boxL.visible(0) ballL.visible(0) HistBallL.visible(0) else: boxL.visible(1) ballL.visible(1) HistBallL.visible(1) """ #set history ball based on local maximum relative to anterior pelvic Y direction########################## #if (vectorValue[0] > histL) & (vectorValue[0] > 0): # HistBallL.setPosition([- vectorValue[1], 0, vectorValue[0]])#update yellow history ball when HS happens # steplengthL = histL # histL = vectorValue[0] #else: # histL = vectorValue[0] if (vectorValue[2] < 0) & (histL == 0.0): if (vectorValue[0] < targettol): HistBallL.visible(0) HistBallL.setPosition([-0.2, vectorValue[0], 0])#update yellow history ball when HS happens else: HistBallL.visible(1) HistBallL.setPosition([-0.2, vectorValue[0], 0])#update yellow history ball when HS happens steplengthL = vectorValue[0] histL = vectorValue[2] else: histL = vectorValue[2] if (abs(steplengthL-targetL) <= targettol): boxL.color( viz.WHITE ) else: boxL.color( viz.BLUE ) #count if step is correct if (vectorValue[2] < -20) & (Lforceold == 0.0) & (abs(steplengthL-targetL) <= targettol): LCOUNT = LCOUNT+1 leftcounter.message(str(LCOUNT)) Lforceold = vectorValue[2] #lastly, determine if the right belt needs to move************************************************** if (vectorValue[2] < 0) & (vectorValue[0] > 0.02):#subject is on forceplate, and foot is away from neutral #print(vectorValue[0]) #time.sleep(0.5) LeftBeltSpeed = 0.1 else: LeftBeltSpeed = 0 if ((time.time()-mmserver.starttime) > 158): #print('time elapsed is:') #print(time.time()-starttime1) mmserver.sendScalarValue('LeftBeltSpeed',0) else: mmserver.sendScalarValue('LeftBeltSpeed',LeftBeltSpeed)
def onVectorValueReceived(vectorName, vectorValue, invalid): global ballR global ballL global HistBallR global histR global HistBallL global histL global boxL global boxR global targettol global target global steplengthL global steplengthR global neutralL global neutralR global RCOUNT global LCOUNT global randy # global RightBeltSpeed # global LeftBeltSpeed global RGOB global LGOB global stepind #this keeps track of the total # of attempts global RightBeltSpeed global LeftBeltSpeed global rxplode global lxplode global Rattempts global Lattempts #***************************************************************************************************************************************************************************** if ( vectorName == 'BallPositionR' ) and not invalid: # look for the BallPosition variable in the data stream mmserver.sendVectorValue( 'ReturnedBallPositionR', vectorValue ) # echo back the value of BallPosition to #MotionMonitor mmserver.sendScalarValue('RCOUNT', RCOUNT) # echo attempt # mmserver.sendScalarValue( 'Rgorb', RGOB) # echo if the latest attempt was good or bad mmserver.sendScalarValue('STEPIND', stepind) #echo total # of steps taken #update Cursor ball position to reflect where the foot is in sagittal plane motion cursorR.setScale( 0.1, vectorValue[0], 0.01250) #scale cursor according to step time in Z direction #vectorValue[0] is the difference in Y direction between GT and Ankle markers. e.g. RGY-RANKY #vectirValue[1] is meaningless right now #vectorValue[2] is Fz for detecting gait events #hide the cursor ball if the foot is behind the other foot if (vectorValue[0] < 0) | (vectorValue[2] < 0): # | (vectorValue[0] <= psudoR): cursorR.visible(0) neutralR.visible(1) #HistBallR.visible(0)#turn of the history ball so its not confusing else: cursorR.visible(1) neutralR.visible(0) #HistBallR.visible(1) #set history at heel strike, display feedback if (vectorValue[2] < -30) & (histR >= -30) & (vectorValue[0] > targetR / 4): # RCOUNT = RCOUNT+1#keep track of how many HS happen stepind = stepind + 1 Rattempts = Rattempts + 1 # rightcounter.message(str(RCOUNT)) if (vectorValue[0] < targettol ): #if the step taken was too short, don't give feedback HistBallR.visible(0) HistBallR.setPosition( [0.2, vectorValue[0], 0]) #update yellow history ball when HS happens else: HistBallR.visible(1) HistBallR.setPosition( [0.2, vectorValue[0], 0]) #update yellow history ball when HS happens steplengthR = vectorValue[0] #get the current distance between histR = vectorValue[2] #check which target should be visible next if (abs(steplengthR - targetR) <= targettol): #highlight the target when the target is hit # boxR.visible(0) RCOUNT = RCOUNT + 1 #keep track of how many HS happen rightcounter.message(str(RCOUNT) + '/' + str(Rattempts)) rxplode = viz.addChild('targetexplode13.osgb', pos=[0.2, targetR, 0.05], scale=[0.1, targettol + .019, 0.0125 ]) #make the target explode rxplode.setAnimationState(0) boxR.visible(0) RGOB = 1 else: boxR.color(viz.BLUE) RGOB = 0 rightcounter.message(str(RCOUNT) + '/' + str(Rattempts)) else: histR = vectorValue[2] #see if it is time to hide everything before the next step if (vectorValue[0] < targetR / 2 ) & (vectorValue[0] > targetR / 2 - 0.01) & ( vectorValue[2] < -30 ): #this changes the targets when the moving leg is half-way back boxR.color( viz.BLUE) #change colors of targets back to default blue boxL.color(viz.BLUE) boxR.visible(0) boxL.visible(0) HistBallR.visible(0) #hide until the next HS HistBallL.visible(0) rxplode.remove() #lastly, determine if the right belt needs to move if (vectorValue[2] < -10) & ( vectorValue[0] > 0.05 ): #subject is on forceplate, and foot is away from neutral #print(vectorValue[0]) #time.sleep(0.1) RightBeltSpeed = 0.2 mmserver.sendScalarValue('RightBeltSpeed', RightBeltSpeed) else: RightBeltSpeed = 0 mmserver.sendScalarValue('RightBeltSpeed', RightBeltSpeed) if (RightBeltSpeed == 0) & (LeftBeltSpeed == 0): if (randy[stepind] == 1 ): #when the feet are back together, display the new target boxR.visible(1) boxL.visible(0) else: boxR.visible(0) boxL.visible(1) ''' #send speed command as long as there is enough time left in the 30s of capture if ((time.time()-mmserver.starttime) > 158): print('session is ending...') mmserver.sendScalarValue('RightBeltSpeed',0) else: mmserver.sendScalarValue('RightBeltSpeed',RightBeltSpeed) ''' #print('mmserver starttime was:') #print(mmserver.starttime) #***************************************************************************************************************************************************************************** if (vectorName == 'BallPositionL') and not invalid: mmserver.sendVectorValue('ReturnedBallPositionL', vectorValue) mmserver.sendScalarValue('LCOUNT', LCOUNT) mmserver.sendScalarValue('Lgorb', LGOB) mmserver.sendScalarValue('STEPIND', stepind) cursorL.setScale( 0.1, vectorValue[0], 0.01250) #scale cursor according to step time in Z direction #hide cursor ball if foot is posterior to pelvis if (vectorValue[0] < 0) | (vectorValue[2] < 0): # | (vectorValue[0] <= psudoL): cursorL.visible(0) neutralL.visible(1) #HistBallL.visible(0) else: cursorL.visible(1) neutralL.visible(0) #HistBallL.visible(1) #detect left HS if (vectorValue[2] < -30) & (histL >= -30) & (vectorValue[0] > targetL / 4): # LCOUNT = LCOUNT+1 stepind = stepind + 1 Lattempts = Lattempts + 1 # leftcounter.message(str(LCOUNT)) if (vectorValue[0] < targettol): HistBallL.visible(0) HistBallL.setPosition( [-0.2, vectorValue[0], 0]) #update yellow history ball when HS happens else: HistBallL.visible(1) HistBallL.setPosition( [-0.2, vectorValue[0], 0]) #update yellow history ball when HS happens steplengthL = vectorValue[0] histL = vectorValue[2] #check which target should be visible next # randy = random.randint(1,2)#this generates a new value for randy to say which leg to test next if (abs(steplengthL - targetL) <= targettol): # boxL.visible(0) LCOUNT = LCOUNT + 1 leftcounter.message(str(LCOUNT) + '/' + str(Lattempts)) lxplode = viz.addChild('targetexplode13.osgb', pos=[-0.2, targetL, 0], scale=[0.1, (targettol + 0.19), 0.0125]) lxplode.setAnimationState(0) boxL.visible(0) LGOB = 1 else: boxL.color(viz.BLUE) LGOB = 0 leftcounter.message(str(LCOUNT) + '/' + str(Lattempts)) else: histL = vectorValue[2] #see if it is time to display the new target if (vectorValue[0] < targetL / 2 ) & (vectorValue[0] > targetL / 2 - 0.01) & ( vectorValue[2] < -30 ): #this changes teh targets when the moving leg is half-way back boxR.color(viz.BLUE) boxL.color(viz.BLUE) boxR.visible(0) boxL.visible(0) HistBallR.visible(0) HistBallL.visible(0) lxplode.remove() #lastly, determine if the right belt needs to move************************************************** if (vectorValue[2] < 0) & ( vectorValue[0] > 0.05 ): #subject is on forceplate, and foot is away from neutral #print(vectorValue[0]) #time.sleep(0.5) LeftBeltSpeed = 0.2 mmserver.sendScalarValue('LeftBeltSpeed', LeftBeltSpeed) else: LeftBeltSpeed = 0 mmserver.sendScalarValue('LeftBeltSpeed', LeftBeltSpeed) if (RightBeltSpeed == 0) & (LeftBeltSpeed == 0): if (randy[stepind] == 1): boxR.visible(1) boxL.visible(0) else: boxR.visible(0) boxL.visible(1) '''
def onVectorValueReceived(vectorName, vectorValue, invalid): global ballR global ballL global HistBallR global histR global HistBallL global histL global boxL global boxR global targettol global target global steplengthL global steplengthR global neutralL global neutralR global RCOUNT global LCOUNT global randy #***************************************************************************************************************************************************************************** if ( vectorName == 'BallPositionR' ) and not invalid: # look for the BallPosition variable in the data stream# mmserver.sendVectorValue( 'ReturnedBallPositionR', vectorValue ) # echo back the value of BallPosition to #MotionMonitor mmserver.sendScalarValue('RCOUNT', RCOUNT) #update Cursor ball position to reflect where the foot is in sagittal plane motion cursorR.setScale( 0.1, vectorValue[0], 0.01250) #scale cursor according to step time in Z direction #hide the cursor ball if the foot is behind the other foot if (vectorValue[0] < 0) | (vectorValue[2] < 0): # | (vectorValue[0] <= psudoR): cursorR.visible(0) neutralR.visible(1) #HistBallR.visible(0)#turn of the history ball so its not confusing else: cursorR.visible(1) neutralR.visible(0) #HistBallR.visible(1) #set history at heel strike if (vectorValue[2] < 0) & (histR == 0): RCOUNT = RCOUNT + 1 #keep track of how many HS happen rightcounter.message(str(RCOUNT)) if (vectorValue[0] < targettol): HistBallR.visible(0) HistBallR.setPosition( [0.2, vectorValue[0], 0]) #update yellow history ball when HS happens else: HistBallR.visible(1) HistBallR.setPosition( [0.2, vectorValue[0], 0]) #update yellow history ball when HS happens steplengthR = vectorValue[0] histR = vectorValue[2] #check which target should be visible next randy = random.randint( 1, 2 ) #this generates a new value for randy to say which leg to test next else: histR = vectorValue[2] if (abs(steplengthR - targetR) <= targettol): #highlight the target when the target is hit boxR.color(viz.WHITE) else: boxR.color(viz.BLUE) #see if it is time to display the new target if (vectorValue[0] < targetR / 2 ) & (vectorValue[0] > targetR / 2 - 0.01) & ( vectorValue[2] < -10 ): #this changes teh targets when the moving leg is half-way back if (randy == 1): boxR.visible(1) boxL.visible(0) else: boxR.visible(0) boxL.visible(1) #lastly, determine if the right belt needs to move if (vectorValue[2] < 0) & ( vectorValue[0] > 0.05 ): #subject is on forceplate, and foot is away from neutral #print(vectorValue[0]) #time.sleep(0.1) RightBeltSpeed = 0.2 else: RightBeltSpeed = 0 #send speed command as long as there is enough time left in the 30s of capture if ((time.time() - mmserver.starttime) > 158): print('session is ending...') mmserver.sendScalarValue('RightBeltSpeed', 0) else: mmserver.sendScalarValue('RightBeltSpeed', RightBeltSpeed) #print('mmserver starttime was:') #print(mmserver.starttime) #***************************************************************************************************************************************************************************** if (vectorName == 'BallPositionL') and not invalid: mmserver.sendVectorValue('ReturnedBallPositionL', vectorValue) mmserver.sendScalarValue('LCOUNT', LCOUNT) cursorL.setScale( 0.1, vectorValue[0], 0.01250) #scale cursor according to step time in Z direction #hide cursor ball if foot is posterior to pelvis if (vectorValue[0] < 0) | (vectorValue[2] < 0): # | (vectorValue[0] <= psudoL): cursorL.visible(0) neutralL.visible(1) #HistBallL.visible(0) else: cursorL.visible(1) neutralL.visible(0) #HistBallL.visible(1) #detect left HS if (vectorValue[2] < 0) & (histL == 0.0): LCOUNT = LCOUNT + 1 leftcounter.message(str(LCOUNT)) if (vectorValue[0] < targettol): HistBallL.visible(0) HistBallL.setPosition( [-0.2, vectorValue[0], 0]) #update yellow history ball when HS happens else: HistBallL.visible(1) HistBallL.setPosition( [-0.2, vectorValue[0], 0]) #update yellow history ball when HS happens steplengthL = vectorValue[0] histL = vectorValue[2] #check which target should be visible next randy = random.randint( 1, 2 ) #this generates a new value for randy to say which leg to test next else: histL = vectorValue[2] if (abs(steplengthL - targetL) <= targettol): boxL.color(viz.WHITE) else: boxL.color(viz.BLUE) #see if it is time to display the new target if (vectorValue[0] < targetL / 2 ) & (vectorValue[0] > targetL / 2 - 0.01) & ( vectorValue[2] < -10 ): #this changes teh targets when the moving leg is half-way back if (randy == 1): boxL.visible(1) boxR.visible(0) else: boxL.visible(0) boxR.visible(1) #lastly, determine if the right belt needs to move************************************************** if (vectorValue[2] < 0) & ( vectorValue[0] > 0.05 ): #subject is on forceplate, and foot is away from neutral #print(vectorValue[0]) #time.sleep(0.5) LeftBeltSpeed = 0.2 else: LeftBeltSpeed = 0 if ((time.time() - mmserver.starttime) > 158): #print('time elapsed is:') #print(time.time()-starttime1) mmserver.sendScalarValue('LeftBeltSpeed', 0) else: mmserver.sendScalarValue('LeftBeltSpeed', LeftBeltSpeed)
def onVectorValueReceived(vectorName, vectorValue, invalid): global ballR global ballL global HistBallR global histR global HistBallL global histL global boxL global boxR global targettol global target global steplengthL global steplengthR #global psudoR #global psudoL global neutralL global neutralR if ( vectorName == 'BallPositionR' ) and not invalid: # look for the BallPosition variable in the data stream# mmserver.sendVectorValue( 'ReturnedBallPositionR', vectorValue ) # echo back the value of BallPosition to #MotionMonitor #update Cursor ball position to reflect where the foot is in sagittal plane motion cursorR.setScale( 0.1, vectorValue[0], 0.01250) #scale cursor according to step time in Z direction #hide the cursor ball if the foot is behind the pelvis if (vectorValue[0] < 0) | (vectorValue[2] < 0): # | (vectorValue[0] <= psudoR): cursorR.visible(0) neutralR.visible(1) #HistBallR.visible(0)#turn of the history ball so its not confusing else: cursorR.visible(1) neutralR.visible(0) #HistBallR.visible(1) #*!*!*!*!*!*!*Hide the target box and cursor when the subject begins to move for the target. Hides upon toe-off. Also hide the history ball ''' if (vectorValue[2] == 0): boxR.visible(0) ballR.visible(0) HistBallR.visible(0) else: boxR.visible(1) ballR.visible(1) HistBallR.visible(1) ''' #set history ball based on local maximum relative to anterior pelvic Y direction########################## #if (vectorValue[0] > histR) & (vectorValue[0] > 0): # HistBallR.setPosition([- vectorValue[1], 0, vectorValue[0]])#update yellow history ball when HS happens # steplengthR = histR # histR = vectorValue[0] #else: # histR = vectorValue[0] #set history at heel strike#################################### if (vectorValue[2] < 0) & (histR == 0): if (vectorValue[0] < targettol): HistBallR.visible(0) HistBallR.setPosition( [0.2, vectorValue[0], 0]) #update yellow history ball when HS happens else: HistBallR.visible(1) HistBallR.setPosition( [0.2, vectorValue[0], 0]) #update yellow history ball when HS happens steplengthR = vectorValue[0] histR = vectorValue[2] else: histR = vectorValue[2] if (abs(steplengthR - targetR) <= targettol): #highlight the target when the target is hit boxR.color(viz.WHITE) else: boxR.color(viz.BLUE) #lastly, determine if the right belt needs to move************************************************** if (vectorValue[2] < 0) & ( vectorValue[0] > 0.02 ): #subject is on forceplate, and foot is away from neutral #print(vectorValue[0]) #time.sleep(0.1) RightBeltSpeed = 0.1 else: RightBeltSpeed = 0 #send speed command as long as there is enough time left in the 30s of capture if ((time.time() - mmserver.starttime) > 28): print('session is ending...') mmserver.sendScalarValue('RightBeltSpeed', 0) else: mmserver.sendScalarValue('RightBeltSpeed', RightBeltSpeed) #print('mmserver starttime was:') #print(mmserver.starttime) if (vectorName == 'BallPositionL') and not invalid: mmserver.sendVectorValue('ReturnedBallPositionL', vectorValue) cursorL.setScale( 0.1, vectorValue[0], 0.01250) #scale cursor according to step time in Z direction #hide cursor ball if foot is posterior to pelvis if (vectorValue[0] < 0) | (vectorValue[2] < 0): # | (vectorValue[0] <= psudoL): cursorL.visible(0) neutralL.visible(1) #HistBallL.visible(0) else: cursorL.visible(1) neutralL.visible(0) #HistBallL.visible(1) #*!*!*!*!*!*!*Hide the target box when the subject begins to move for the target. Hides upon toe-off. Also hide history ball """ if (vectorValue[2] == 0): boxL.visible(0) ballL.visible(0) HistBallL.visible(0) else: boxL.visible(1) ballL.visible(1) HistBallL.visible(1) """ #set history ball based on local maximum relative to anterior pelvic Y direction########################## #if (vectorValue[0] > histL) & (vectorValue[0] > 0): # HistBallL.setPosition([- vectorValue[1], 0, vectorValue[0]])#update yellow history ball when HS happens # steplengthL = histL # histL = vectorValue[0] #else: # histL = vectorValue[0] if (vectorValue[2] < 0) & (histL == 0.0): if (vectorValue[0] < targettol): HistBallL.visible(0) HistBallL.setPosition( [-0.2, vectorValue[0], 0]) #update yellow history ball when HS happens else: HistBallL.visible(1) HistBallL.setPosition( [-0.2, vectorValue[0], 0]) #update yellow history ball when HS happens steplengthL = vectorValue[0] histL = vectorValue[2] else: histL = vectorValue[2] if (abs(steplengthL - targetL) <= targettol): boxL.color(viz.WHITE) else: boxL.color(viz.BLUE) #lastly, determine if the right belt needs to move************************************************** if (vectorValue[2] < 0) & ( vectorValue[0] > 0.02 ): #subject is on forceplate, and foot is away from neutral #print(vectorValue[0]) #time.sleep(0.5) LeftBeltSpeed = 0.1 else: LeftBeltSpeed = 0 if ((time.time() - mmserver.starttime) > 28): #print('time elapsed is:') #print(time.time()-starttime1) mmserver.sendScalarValue('LeftBeltSpeed', 0) else: mmserver.sendScalarValue('LeftBeltSpeed', LeftBeltSpeed)
def onVectorValueReceived(vectorName, vectorValue, invalid): global ballR global ballL global HistBallR global histR global HistBallL global histL global boxL global boxR global targettol global target global steplengthL global steplengthR global neutralL global neutralR global RCOUNT global LCOUNT global randy global RGOB global LGOB global stepind #this keeps track of the total # of attempts global RightBeltSpeed global LeftBeltSpeed global rxplode global lxplode global Rattempts global Lattempts global Rdistance global lscaler # global rscaler #***************************************************************************************************************************************************************************** if (vectorName == 'BallPositionR') and not invalid: # look for the BallPosition variable in the data stream mmserver.sendVectorValue('ReturnedBallPositionR', vectorValue) # echo back the value of BallPosition to #MotionMonitor mmserver.sendScalarValue('RCOUNT',RCOUNT)# echo attempt # mmserver.sendScalarValue('Rgorb',RGOB)# echo if the latest attempt was good or bad mmserver.sendScalarValue('STEPIND',stepind)#echo total # of steps taken #update Cursor ball position to reflect where the foot is in sagittal plane motion cursorR.setScale(1.2*rscale1,Rdistance*math.tan(2*math.atan2(vectorValue[0],2*1)),0.0125)#scale cursor according to step time in Z direction #vectorValue[0] is the difference in Y direction between GT and Ankle markers. e.g. RGY-RANKY #vectirValue[1] is meaningless right now #vectorValue[2] is Fz for detecting gait events #hide the cursor ball if the foot is behind the other foot if (vectorValue[0] < 0) | (vectorValue[2] < 0):# | (vectorValue[0] <= psudoR): cursorR.visible(0) neutralR.visible(1) #HistBallR.visible(0)#turn of the history ball so its not confusing else: cursorR.visible(1) neutralR.visible(0) #HistBallR.visible(1) #set history at heel strike, display feedback if (vectorValue[2] < -30) & (histR >= -30) & (vectorValue[0] > targetR/4): # RCOUNT = RCOUNT+1#keep track of how many HS happen stepind = stepind+1 Rattempts = Rattempts+1 # rightcounter.message(str(RCOUNT)) if (vectorValue[0] < targettol): #if the step taken was too short, don't give feedback HistBallR.visible(0) HistBallR.setPosition([rxdistance,Rdistance*math.tan(2*math.atan2(vectorValue[0],2*1)),Rdistance])#update yellow history ball when HS happens else: HistBallR.visible(1) HistBallR.setPosition([rxdistance,Rdistance*math.tan(2*math.atan2(vectorValue[0],2*1)),Rdistance])#update yellow history ball when HS happens steplengthR = vectorValue[0] #get the current distance between histR = vectorValue[2] #check which target should be visible next if (abs(steplengthR-targetR) <= targettol):#highlight the target when the target is hit # boxR.visible(0) RCOUNT = RCOUNT+1#keep track of how many HS happen rightcounter.message(str(RCOUNT)+'/'+str(Rattempts)) rxplode = viz.addChild('targetexplode13.osgb',pos=[0.2,targetR,0.05],scale=[0.1,targettol+.019,0.0125])#make the target explode rxplode.setAnimationState(0) boxR.visible(0) RGOB = 1 else: boxR.color( viz.BLUE ) RGOB = 0 rightcounter.message(str(RCOUNT)+'/'+str(Rattempts)) else: histR = vectorValue[2] #see if it is time to hide everything before the next step if (vectorValue[0] < targetR/2) & (vectorValue[0] > targetR/2-0.01) & (vectorValue[2] < -30):#this changes the targets when the moving leg is half-way back boxR.color( viz.BLUE )#change colors of targets back to default blue boxL.color( viz.BLUE ) boxR.visible(0) boxL.visible(0) HistBallR.visible(0)#hide until the next HS HistBallL.visible(0) rxplode.remove() #lastly, determine if the right belt needs to move if (vectorValue[2] < -10) & (vectorValue[0] > 0.05):#subject is on forceplate, and foot is away from neutral #print(vectorValue[0]) #time.sleep(0.1) RightBeltSpeed = 0.2 mmserver.sendScalarValue('RightBeltSpeed',RightBeltSpeed) else: RightBeltSpeed = 0 mmserver.sendScalarValue('RightBeltSpeed',RightBeltSpeed) if (RightBeltSpeed == 0) & (LeftBeltSpeed == 0): if (randy[stepind] == 1):#when the feet are back together, display the new target boxR.visible(1) boxL.visible(0) else: boxR.visible(0) boxL.visible(1) ''' #send speed command as long as there is enough time left in the 30s of capture if ((time.time()-mmserver.starttime) > 158): print('session is ending...') mmserver.sendScalarValue('RightBeltSpeed',0) else: mmserver.sendScalarValue('RightBeltSpeed',RightBeltSpeed) ''' #print('mmserver starttime was:') #print(mmserver.starttime) #***************************************************************************************************************************************************************************** if (vectorName == 'BallPositionL') and not invalid: mmserver.sendVectorValue('ReturnedBallPositionL', vectorValue) mmserver.sendScalarValue('LCOUNT',LCOUNT) mmserver.sendScalarValue('Lgorb',LGOB) mmserver.sendScalarValue('STEPIND',stepind) cursorL.setScale(0.1,vectorValue[0]*lscaler,0.01250)#scale cursor according to step time in Z direction #hide cursor ball if foot is posterior to pelvis if (vectorValue[0] < 0) | (vectorValue[2] < 0):# | (vectorValue[0] <= psudoL): cursorL.visible(0) neutralL.visible(1) #HistBallL.visible(0) else: cursorL.visible(1) neutralL.visible(0) #HistBallL.visible(1) #detect left HS if (vectorValue[2] < -30) & (histL >= -30) & (vectorValue[0] > targetL/4): # LCOUNT = LCOUNT+1 stepind = stepind+1 Lattempts = Lattempts+1 # leftcounter.message(str(LCOUNT)) if (vectorValue[0] < targettol): HistBallL.visible(0) HistBallL.setPosition([-0.2, vectorValue[0], 0])#update yellow history ball when HS happens else: HistBallL.visible(1) HistBallL.setPosition([-0.2, vectorValue[0], 0])#update yellow history ball when HS happens steplengthL = vectorValue[0] histL = vectorValue[2] #check which target should be visible next # randy = random.randint(1,2)#this generates a new value for randy to say which leg to test next if (abs(steplengthL-targetL) <= targettol): # boxL.visible(0) LCOUNT = LCOUNT+1 leftcounter.message(str(LCOUNT)+'/'+str(Lattempts)) lxplode = viz.addChild('targetexplode13.osgb',pos=[-0.2,targetL,0],scale=[0.1,(targettol+0.19),0.0125]) lxplode.setAnimationState(0) boxL.visible(0) LGOB = 1 else: boxL.color( viz.BLUE ) LGOB = 0 leftcounter.message(str(LCOUNT)+'/'+str(Lattempts)) else: histL = vectorValue[2] #see if it is time to display the new target if (vectorValue[0] < targetL/2) & (vectorValue[0] > targetL/2-0.01) & (vectorValue[2] < -30):#this changes teh targets when the moving leg is half-way back boxR.color( viz.BLUE ) boxL.color( viz.BLUE ) boxR.visible(0) boxL.visible(0) HistBallR.visible(0) HistBallL.visible(0) lxplode.remove() #lastly, determine if the right belt needs to move************************************************** if (vectorValue[2] < 0) & (vectorValue[0] > 0.05):#subject is on forceplate, and foot is away from neutral #print(vectorValue[0]) #time.sleep(0.5) LeftBeltSpeed = 0.2 mmserver.sendScalarValue('LeftBeltSpeed',LeftBeltSpeed) else: LeftBeltSpeed = 0 mmserver.sendScalarValue('LeftBeltSpeed',LeftBeltSpeed) if (RightBeltSpeed == 0) & (LeftBeltSpeed == 0): if (randy[stepind] == 1): boxR.visible(1) boxL.visible(0) else: boxR.visible(0) boxL.visible(1) '''
def onVectorValueReceived(vectorName, vectorValue, invalid): global cursorR global cursorL global HistBallR global histR global HistBallL global histL global boxL global boxR global targettol global target global steptimeL global steptimeR global flipflop global RCOUNT global LCOUNT global Rforceold global Lforceold steptimeR = 0 steptimeL = 0 if (vectorName == 'BallPositionR') and not invalid: # look for the BallPosition variable in the data stream# mmserver.sendVectorValue('ReturnedBallPositionR', vectorValue) # echo back the value of BallPosition to #MotionMonitor #IMPORTANT: vectorValue[0] is flipflop, vectorValue[1] is HS, vectorValue[2] is steptime if vectorValue[0] == 1:#L to R cursorR.setScale(0.1,vectorValue[2],0.0125)#move cursor according to step time in Z direction cursorL.setScale(0.1,0.01,0.0125);#minimize the other cursor histR = vectorValue[2] #boxR.color( viz.BLUE ) if (vectorValue[2] <= 0.1): HistBallL.setPosition([-0.2, histL, 0])#update yellow history bar when HS happens steptimeL = histL if (abs(histL-targetL) <= targettol):#highlight the target when the target is hit boxL.color( viz.WHITE ) else: boxL.color( viz.BLUE ) elif vectorValue[0] == 0:#R to L cursorL.setScale(0.1,vectorValue[2],0.0125)#move cursor according to step time in Z direction cursorR.setScale(0.1,0.01,0.0125); histL = vectorValue[2] #boxL.color( viz.BLUE ) if (vectorValue[2] <= 0.1): HistBallR.setPosition([0.2, histR, 0])#update yellow history bar when HS happens steptimeR = histR if (abs(histR-targetR) <= targettol):#highlight the target when the target is hit boxR.color( viz.WHITE ) else: boxR.color( viz.BLUE ) if (vectorName == 'BallPositionL') and not invalid:#this vector brings in forceplate data to use for success detection mmserver.sendVectorValue('ReturnedBallPositionL', vectorValue) mmserver.sendScalarValue('RCOUNT',RCOUNT) mmserver.sendScalarValue('LCOUNT',LCOUNT) #look for RHS if (vectorValue[0] < -20) & (Rforceold == 0.0) & (abs(histR-targetR) <= targettol): RCOUNT = RCOUNT+1 rightcounter.message(str(RCOUNT)) #look for LHS if (vectorValue[1] < -20) & (Lforceold == 0.0) & (abs(histL-targetL) <= targettol): LCOUNT = LCOUNT+1 leftcounter.message(str(RCOUNT)) Rforceold = vectorValue[0] Lforceold = vectorValue[1]
def onVectorValueReceived(vectorName, vectorValue, invalid): global cursorR global cursorL global HistBallR global histR global HistBallL global histL global boxL global boxR global targettol global targetR global targetL global steplengthL global steplengthR global psudoR global psudoL global RCOUNT global LCOUNT global Rforceold global Lforceold global Rtop global Rhsp global Ltop global Lhsp if ( vectorName == 'BallPositionR' ) and not invalid: # look for the BallPosition variable in the data stream# mmserver.sendVectorValue( 'ReturnedBallPositionR', vectorValue ) # echo back the value of BallPosition to #MotionMonitor mmserver.sendScalarValue('RCOUNT', RCOUNT) #vectorValue[0] is the step length, vectorValue[2] is the forceplate data #update the cursor position every time vector is recieved cursorR.setScale( 0.1, vectorValue[0], 0.01250) #scale cursor according to step time in Z direction #Determine whether or not the cursor should be visible. If the foot of interest is behind the pelvis, it should disappear if (vectorValue[0] < 0) | (vectorValue[2] < 0): cursorR.visible(0) #histballR.visible(0) else: cursorR.visible(1) #histballR.visible(1) #set history at heel strike#################################### if (vectorValue[2] < 0) & (histR == 0.0): HistBallR.setPosition( [0.2, vectorValue[0], 0]) #update yellow history ball when HS happens steplengthR = vectorValue[0] histR = vectorValue[2] else: histR = vectorValue[2] if (abs(steplengthR - targetR) <= targettol): #highlight the target when the target is hit boxR.color(viz.WHITE) else: boxR.color(viz.BLUE) #if successful step was taken, keep track of it if (vectorValue[2] < -20) & (Rforceold == 0.0) & ( abs(steplengthR - targetR) <= targettol): RCOUNT = RCOUNT + 1 #rightcounter.setText(str(RCOUNT)) rightcounter.message(str(RCOUNT)) #see if it is time to calculate the step length if (vectorValue[2] == 0) & (Rforceold < 0): #toe off condition #calculate Toe-Off position Rtop = vectorValue[0] elif (vectorValue[2] < -20) & (Rforceold == 0): #HS condition Rhsp = vectorValue[0] psudoR = psudoR + 1 if (psudoR == 5): boxR.setPosition([0.2, 0.5 * (Rhsp - Rtop), 0]) targetR = 0.5 * (Rhsp - Rtop) psudoR = 1 Rforceold = vectorValue[ 2] #save current force value for next time vector is recieved if (vectorName == 'BallPositionL') and not invalid: mmserver.sendVectorValue('ReturnedBallPositionL', vectorValue) mmserver.sendScalarValue('LCOUNT', LCOUNT) cursorL.setScale( 0.1, vectorValue[0], 0.01250) #scale cursor according to step time in Z direction if (vectorValue[0] < 0) | (vectorValue[2] < 0): cursorL.visible(0) else: cursorL.visible(1) #set history ball based on local maximum relative to anterior pelvic Y direction########################## #if (vectorValue[0] > histL) & (vectorValue[0] > 0): # HistBallL.setPosition([- vectorValue[1], 0, vectorValue[0]])#update yellow history ball when HS happens # steplengthL = histL # histL = vectorValue[0] #else: # histL = vectorValue[0] if (vectorValue[2] < 0) & (histL == 0.0): HistBallL.setPosition([-0.2, vectorValue[0], 0]) steplengthL = vectorValue[0] histL = vectorValue[2] else: histL = vectorValue[2] if (abs(steplengthL - targetL) <= targettol): boxL.color(viz.WHITE) else: boxL.color(viz.BLUE) if (vectorValue[2] < -20) & (Lforceold == 0.0) & ( abs(steplengthL - targetL) <= targettol): LCOUNT = LCOUNT + 1 leftcounter.message(str(LCOUNT)) #see if it is time to calculate the step length if (vectorValue[2] == 0) & (Lforceold < 0): #toe off condition #calculate Toe-Off position Ltop = vectorValue[0] elif (vectorValue[2] < -20) & (Lforceold == 0): #HS condition Lhsp = vectorValue[0] psudoL = psudoL + 1 if (psudoL == 5): boxL.setPosition([-0.2, 0.5 * (Lhsp - Ltop), 0]) targetL = 0.5 * (Lhsp - Ltop) psudoL = 1 Lforceold = vectorValue[2]
def onVectorValueReceived(vectorName, vectorValue, invalid): global ballR global ballL global HistBallR global histR global HistBallL global histL global boxL global boxR global targettol global target global steplengthL global steplengthR global neutralL global neutralR global RCOUNT global LCOUNT global randy #***************************************************************************************************************************************************************************** if (vectorName == 'BallPositionR') and not invalid: # look for the BallPosition variable in the data stream# mmserver.sendVectorValue('ReturnedBallPositionR', vectorValue) # echo back the value of BallPosition to #MotionMonitor mmserver.sendScalarValue('RCOUNT',RCOUNT) #update Cursor ball position to reflect where the foot is in sagittal plane motion cursorR.setScale(0.1,vectorValue[0],0.01250)#scale cursor according to step time in Z direction #hide the cursor ball if the foot is behind the other foot if (vectorValue[0] < 0) | (vectorValue[2] < 0):# | (vectorValue[0] <= psudoR): cursorR.visible(0) neutralR.visible(1) #HistBallR.visible(0)#turn of the history ball so its not confusing else: cursorR.visible(1) neutralR.visible(0) #HistBallR.visible(1) #set history at heel strike if (vectorValue[2] < 0) & (histR == 0): RCOUNT = RCOUNT+1#keep track of how many HS happen rightcounter.message(str(RCOUNT)) if (vectorValue[0] < targettol): HistBallR.visible(0) HistBallR.setPosition([0.2, vectorValue[0], 0])#update yellow history ball when HS happens else: HistBallR.visible(1) HistBallR.setPosition([0.2, vectorValue[0], 0])#update yellow history ball when HS happens steplengthR = vectorValue[0] histR = vectorValue[2] #check which target should be visible next randy = random.randint(1,2)#this generates a new value for randy to say which leg to test next else: histR = vectorValue[2] if (abs(steplengthR-targetR) <= targettol):#highlight the target when the target is hit boxR.color( viz.WHITE ) else: boxR.color( viz.BLUE ) #see if it is time to display the new target if (vectorValue[0] < targetR/2) & (vectorValue[0] > targetR/2-0.01) & (vectorValue[2] < -10):#this changes teh targets when the moving leg is half-way back if (randy == 1): boxR.visible(1) boxL.visible(0) else: boxR.visible(0) boxL.visible(1) #lastly, determine if the right belt needs to move if (vectorValue[2] < 0) & (vectorValue[0] > 0.05):#subject is on forceplate, and foot is away from neutral #print(vectorValue[0]) #time.sleep(0.1) RightBeltSpeed = 0.2 else: RightBeltSpeed = 0 #send speed command as long as there is enough time left in the 30s of capture if ((time.time()-mmserver.starttime) > 158): print('session is ending...') mmserver.sendScalarValue('RightBeltSpeed',0) else: mmserver.sendScalarValue('RightBeltSpeed',RightBeltSpeed) #print('mmserver starttime was:') #print(mmserver.starttime) #***************************************************************************************************************************************************************************** if (vectorName == 'BallPositionL') and not invalid: mmserver.sendVectorValue('ReturnedBallPositionL', vectorValue) mmserver.sendScalarValue('LCOUNT',LCOUNT) cursorL.setScale(0.1,vectorValue[0],0.01250)#scale cursor according to step time in Z direction #hide cursor ball if foot is posterior to pelvis if (vectorValue[0] < 0) | (vectorValue[2] < 0):# | (vectorValue[0] <= psudoL): cursorL.visible(0) neutralL.visible(1) #HistBallL.visible(0) else: cursorL.visible(1) neutralL.visible(0) #HistBallL.visible(1) #detect left HS if (vectorValue[2] < 0) & (histL == 0.0): LCOUNT = LCOUNT+1 leftcounter.message(str(LCOUNT)) if (vectorValue[0] < targettol): HistBallL.visible(0) HistBallL.setPosition([-0.2, vectorValue[0], 0])#update yellow history ball when HS happens else: HistBallL.visible(1) HistBallL.setPosition([-0.2, vectorValue[0], 0])#update yellow history ball when HS happens steplengthL = vectorValue[0] histL = vectorValue[2] #check which target should be visible next randy = random.randint(1,2)#this generates a new value for randy to say which leg to test next else: histL = vectorValue[2] if (abs(steplengthL-targetL) <= targettol): boxL.color( viz.WHITE ) else: boxL.color( viz.BLUE ) #see if it is time to display the new target if (vectorValue[0] < targetL/2) & (vectorValue[0] > targetL/2-0.01) & (vectorValue[2] < -10):#this changes teh targets when the moving leg is half-way back if (randy == 1): boxL.visible(1) boxR.visible(0) else: boxL.visible(0) boxR.visible(1) #lastly, determine if the right belt needs to move************************************************** if (vectorValue[2] < 0) & (vectorValue[0] > 0.05):#subject is on forceplate, and foot is away from neutral #print(vectorValue[0]) #time.sleep(0.5) LeftBeltSpeed = 0.2 else: LeftBeltSpeed = 0 if ((time.time()-mmserver.starttime) > 158): #print('time elapsed is:') #print(time.time()-starttime1) mmserver.sendScalarValue('LeftBeltSpeed',0) else: mmserver.sendScalarValue('LeftBeltSpeed',LeftBeltSpeed)
def onVectorValueReceived(vectorName, vectorValue, invalid): global cursorR global cursorL global HistBallR global histR global HistBallL global histL global boxL global boxR global targettol global targetR global targetL global steplengthL global steplengthR global psudoR global psudoL global RCOUNT global LCOUNT global Rtop global Rhsp global Ltop global Lhsp global catchflag global stridecounter global Rgorb global Lgorb global R global R2 global rsci global lsci if (vectorName == 'BallPositionR') and not invalid: # look for the BallPosition variable in the data stream# # mmserver.sendVectorValue('ReturnedBallPositionR', vectorValue) # echo back the value of BallPosition to #MotionMonitor mmserver.sendScalarValue('RCOUNT',RCOUNT) mmserver.sendScalarValue('Rgorb',Rgorb) mmserver.sendScalarValue('Rstridecount',stridecounter) mmserver.sendScalarValue('targetR',targetR) mmserver.sendScalarValue('Rtop',Rtop) mmserver.sendScalarValue('Rhsp',Rhsp) #vectorValue[0] is the step length (Hip-ankle), vectorValue[2] is the forceplate data #update the cursor position every time vector is recieved # cursorR.setScale(0.1,0.5/Rhsp*(vectorValue[0]+1/(1+R)*(Rtop-R*vectorValue[0])),0.01250)#scale cursor according to modified step length in vertical direction # cursorR.setScale(0.1,0.5/Rhsp*(vectorValue[0]+1/(1+R)*(abs(Rtop)-R*vectorValue[0])),0.01250) cursorR.setScale(0.1,rsci*vectorValue[0],0.01250) #Determine whether or not the cursor should be visible. If the foot of interest is behind the hips, it should disappear if (vectorValue[0] < 0) | (vectorValue[2] < 0): cursorR.visible(0) #histballR.visible(0) else: cursorR.visible(1) #histballR.visible(1) #check for gait events if (vectorValue[2] < -30) & (histR >= -30): #HS condition HistBallR.setPosition([0.2,rsci*vectorValue[0], 0])#update yellow history footprint when HS happens steplengthR = rsci*vectorValue[0] stridecounter = stridecounter+1 #this line of code will not appear in Left foot section, as we want 12 strides after catch for each side if (psudoR == 5): #if it's time to update target alpha value Rhsp = vectorValue[0]#update the alpha value rsci = (1/(Rhsp+1/(1+R)*(abs(Rtop-R*Rhsp)))) #if successful step was taken, keep track of it if (abs(steplengthR-targetR) <= targettol): RCOUNT = RCOUNT+1 rightcounter.message(str(RCOUNT)) Rgorb = 1 #flag this step as good or bad else: Rgorb = 0 if (catchflag == 1) & (stridecounter > 12): boxR.setPosition([0.2,targetR,0]) elif (catchflag == 1) & (stridecounter <= 12): boxR.setPosition([0.2,0.31,0]) else: boxR.setPosition([0.2,targetR,0]) histR = vectorValue[2] elif (vectorValue[2] == 0) & (histR < 0):#toe-off condition #calculate Toe-Off position if (psudoR == 5): Rtop = vectorValue[0]#update beta value psudoR = 1 psudoR = psudoR+1 histR = vectorValue[2] else: histR = vectorValue[2] if (abs(steplengthR-targetR) <= targettol):#highlight the target when the target is hit within tolerance boxR.color( viz.WHITE ) else: boxR.color( viz.BLUE ) if (vectorName == 'BallPositionL') and not invalid: # mmserver.sendVectorValue('ReturnedBallPositionL', vectorValue) mmserver.sendScalarValue('LCOUNT',LCOUNT) mmserver.sendScalarValue('Lgorb',Lgorb) mmserver.sendScalarValue('targetL',targetL) mmserver.sendScalarValue('Ltop',Ltop) mmserver.sendScalarValue('Lhsp',Lhsp) # cursorL.setScale(0.1,0.5/Lhsp*(vectorValue[0]+1/(1+R2)*(abs(Ltop)-R2*vectorValue[0])),0.01250)#scale cursor according to step time in Z direction cursorL.setScale(0.1,lsci*vectorValue[0],0.01250) if (vectorValue[0] < 0) | (vectorValue[2] < 0): cursorL.visible(0) else: cursorL.visible(1) if (vectorValue[2] < -30) & (histL >= -30): #HS condition HistBallL.setPosition([-0.2,lsci*vectorValue[0],0]) steplengthL = lsci*vectorValue[0] if (psudoL == 5): Lhsp = vectorValue[0] lsci = (1/(Lhsp+1/(1+R2)*(abs(Ltop-R2*Lhsp)))) if (catchflag == 1) & (stridecounter > 12): boxL.setPosition([-0.2,targetL,0]) elif (catchflag == 1) & (stridecounter <= 12): boxL.setPosition([-0.2,0.24,0]) else: boxL.setPosition([-0.2,targetL,0]) if (abs(steplengthL-targetL) <= targettol): LCOUNT = LCOUNT+1 leftcounter.message(str(LCOUNT)) Lgorb = 1 else: Lgorb = 0 histL = vectorValue[2] elif (vectorValue[2] >= -30) & (histL < -30):#toe off condition #calculate Toe-Off position if (psudoL ==5): Ltop = vectorValue[0] psudoL = 1 psudoL = psudoL+1 histL = vectorValue[2] else: histL = vectorValue[2] if (abs(steplengthL-targetL) <= targettol): boxL.color( viz.WHITE ) else: boxL.color( viz.BLUE )
def onVectorValueReceived(vectorName, vectorValue, invalid): global cursorR global cursorL global HistBallR global histR global HistBallL global histL global boxL global boxR global targettol global target global steplengthL global steplengthR global psudoR global psudoL global RCOUNT global LCOUNT global Rforceold global Lforceold global Rtop global Rhsp global Ltop global Lhsp if (vectorName == 'BallPositionR') and not invalid: # look for the BallPosition variable in the data stream# mmserver.sendVectorValue('ReturnedBallPositionR', vectorValue) # echo back the value of BallPosition to #MotionMonitor mmserver.sendScalarValue('RCOUNT',RCOUNT) #vectorValue[0] is the step length, vectorValue[2] is the forceplate data #update the cursor position every time vector is recieved cursorR.setScale(0.1,vectorValue[0],0.01250)#scale cursor according to step time in Z direction #Determine whether or not the cursor should be visible. If the foot of interest is behind the pelvis, it should disappear if (vectorValue[0] < 0) | (vectorValue[2] < 0): cursorR.visible(0) #histballR.visible(0) else: cursorR.visible(1) #histballR.visible(1) #set history at heel strike#################################### if (vectorValue[2] < 0) & (histR == 0.0): HistBallR.setPosition([0.2, vectorValue[0], 0])#update yellow history ball when HS happens steplengthR = vectorValue[0] histR = vectorValue[2] else: histR = vectorValue[2] if (abs(steplengthR-targetR) <= targettol):#highlight the target when the target is hit boxR.color( viz.WHITE ) else: boxR.color( viz.BLUE ) #if successful step was taken, keep track of it if (vectorValue[2] < -20) & (Rforceold == 0.0) & (abs(steplengthR-targetR) <= targettol): RCOUNT = RCOUNT+1 #rightcounter.setText(str(RCOUNT)) rightcounter.message(str(RCOUNT)) #see if it is time to calculate the step length if (vectorValue[2] == 0) & (Rforceold < 0):#toe off condition #calculate Toe-Off position Rtop = vectorValue[0] elif (vectorValue[2] < -20) & (Rforceold == 0):#HS condition Rhsp = vectorValue[0] psudoR = psudoR +1 if (psudoR == 4): boxR.setPosition([0.2,0.4*(Rhsp-Rtop)+targettol,0]) targetR = 0.4*(Rhsp-Rtop) psudoR = 1 Rforceold = vectorValue[2]#save current force value for next time vector is recieved if (vectorName == 'BallPositionL') and not invalid: mmserver.sendVectorValue('ReturnedBallPositionL', vectorValue) mmserver.sendScalarValue('LCOUNT',LCOUNT) cursorL.setScale(0.1,vectorValue[0],0.01250)#scale cursor according to step time in Z direction if (vectorValue[0] < 0) | (vectorValue[2] < 0): cursorL.visible(0) else: cursorL.visible(1) #set history ball based on local maximum relative to anterior pelvic Y direction########################## #if (vectorValue[0] > histL) & (vectorValue[0] > 0): # HistBallL.setPosition([- vectorValue[1], 0, vectorValue[0]])#update yellow history ball when HS happens # steplengthL = histL # histL = vectorValue[0] #else: # histL = vectorValue[0] if (vectorValue[2] < 0) & (histL == 0.0): HistBallL.setPosition([-0.2,vectorValue[0],0]) steplengthL = vectorValue[0] histL = vectorValue[2] else: histL = vectorValue[2] if (abs(steplengthL-targetL) <= targettol): boxL.color( viz.WHITE ) else: boxL.color( viz.BLUE ) if (vectorValue[2] < -20) & (Lforceold == 0.0) & (abs(steplengthL-targetL) <= targettol): LCOUNT = LCOUNT+1 leftcounter.message(str(LCOUNT)) #see if it is time to calculate the step length if (vectorValue[2] == 0) & (Lforceold < 0):#toe off condition #calculate Toe-Off position Ltop = vectorValue[0] elif (vectorValue[2] < -20) & (Lforceold == 0):#HS condition Lhsp = vectorValue[0] psudoL = psudoL +1 if (psudoL == 4): boxL.setPosition([-0.2,0.4*(Lhsp-Ltop)+targettol,0]) psudoL = 1 Lforceold = vectorValue[2]
def onVectorValueReceived(vectorName, vectorValue, invalid): global cursorR global cursorL global HistBallR global histR global HistBallL global histL global boxL global boxR global targettol global targetR global targetL global steplengthL global steplengthR global psudoR global psudoL global RCOUNT global LCOUNT global Rtop global Rhsp global Ltop global Lhsp global catchflag global stridecounter global Rgorb global Lgorb if ( vectorName == 'BallPositionR' ) and not invalid: # look for the BallPosition variable in the data stream# mmserver.sendVectorValue( 'ReturnedBallPositionR', vectorValue ) # echo back the value of BallPosition to #MotionMonitor mmserver.sendScalarValue('RCOUNT', RCOUNT) mmserver.sendScalarValue('Rgorb', Rgorb) mmserver.sendScalarValue('Rstridecount', stridecounter) mmserver.sendScalarValue('targetR', targetR) #vectorValue[0] is the step length, vectorValue[2] is the forceplate data #update the cursor position every time vector is recieved cursorR.setScale( 0.1, vectorValue[0], 0.01250) #scale cursor according to step time in Z direction #Determine whether or not the cursor should be visible. If the foot of interest is behind the GT, it should disappear if (vectorValue[0] < 0) | (vectorValue[2] < 0): cursorR.visible(0) #histballR.visible(0) else: cursorR.visible(1) #histballR.visible(1) if (vectorValue[2] < -30) & (histR >= -30): #HS condition HistBallR.setPosition( [0.2, vectorValue[0], 0]) #update yellow history ball when HS happens steplengthR = vectorValue[0] stridecounter = stridecounter + 1 #this line of code will not appear in Left foot section, as we want 12 strides after catch #if successful step was taken, keep track of it if (abs(steplengthR - targetR) <= targettol): RCOUNT = RCOUNT + 1 rightcounter.message(str(RCOUNT)) Rgorb = 1 #flag this step as good or bad else: Rgorb = 0 Rhsp = vectorValue[0] mmserver.sendScalarValue('Rstridelength', Rhsp - Rtop) psudoR = psudoR + 1 if (psudoR == 5): #if it's time to update target value targetR = 0.3766 * (Rhsp - Rtop) print('targetR') print(targetR) psudoR = 1 boxR.setPosition([-0.2, targetR, 0]) if (catchflag == 1) & (stridecounter > 12): boxR.setPosition([0.2, targetR, 0]) elif (catchflag == 1) & (stridecounter <= 12): boxR.setPosition([0.2, 0.31, 0]) else: boxR.setPosition([0.2, targetR, 0]) histR = vectorValue[2] # print(histR) elif (vectorValue[2] == 0) & (histR < 0): #toe off condition #calculate Toe-Off position Rtop = vectorValue[0] histR = vectorValue[2] else: histR = vectorValue[2] if (abs(steplengthR - targetR) <= targettol): #highlight the target when the target is hit boxR.color(viz.WHITE) else: boxR.color(viz.BLUE) if (vectorName == 'BallPositionL') and not invalid: mmserver.sendVectorValue('ReturnedBallPositionL', vectorValue) mmserver.sendScalarValue('LCOUNT', LCOUNT) mmserver.sendScalarValue('Lgorb', Lgorb) mmserver.sendScalarValue('targetL', targetL) cursorL.setScale( 0.1, vectorValue[0], 0.01250) #scale cursor according to step time in Z direction if (vectorValue[0] < 0) | (vectorValue[2] < 0): cursorL.visible(0) else: cursorL.visible(1) if (vectorValue[2] < -30) & (histL >= -30): #HS condition HistBallL.setPosition([-0.2, vectorValue[0], 0]) steplengthL = vectorValue[0] Lhsp = vectorValue[0] mmserver.sendScalarValue('Lstridelength', Lhsp - Ltop) psudoL = psudoL + 1 if (psudoL == 5): targetL = 0.3766 * (Lhsp - Ltop) print('targetL') print(targetL) psudoL = 1 boxL.setPosition([-0.2, targetL, 0]) if (catchflag == 1) & (stridecounter > 12): boxL.setPosition([-0.2, targetL, 0]) elif (catchflag == 1) & (stridecounter <= 12): boxL.setPosition([-0.2, 0.24, 0]) else: boxL.setPosition([-0.2, targetL, 0]) if (abs(steplengthL - targetL) <= targettol): LCOUNT = LCOUNT + 1 leftcounter.message(str(LCOUNT)) Lgorb = 1 else: Lgorb = 0 histL = vectorValue[2] elif (vectorValue[2] >= -30) & (histL < -30): #toe off condition #calculate Toe-Off position Ltop = vectorValue[0] histL = vectorValue[2] else: histL = vectorValue[2] if (abs(steplengthL - targetL) <= targettol): boxL.color(viz.WHITE) else: boxL.color(viz.BLUE)
def onVectorValueReceived(vectorName, vectorValue, invalid): global cursorR global cursorL global HistBallR global histR global HistBallL global histL global boxL global boxR global targettol global target global steplengthL global steplengthR global psudoR global psudoL global RCOUNT global LCOUNT global Rforceold global Lforceold if (vectorName == 'BallPositionR') and not invalid: # look for the BallPosition variable in the data stream# mmserver.sendVectorValue('ReturnedBallPositionR', vectorValue) # echo back the value of BallPosition to #MotionMonitor mmserver.sendScalarValue('RCOUNT',RCOUNT) #vectorValue[0] is the step length, vectorValue[2] is the forceplate data cursorR.setScale(0.1,vectorValue[0],0.01250)#scale cursor according to step time in Z direction if (vectorValue[0] < 0) | (vectorValue[2] < 0): cursorR.visible(0) #histballR.visible(0) else: cursorR.visible(1) #histballR.visible(1) #set history at heel strike#################################### if (vectorValue[2] < 0) & (histR == 0.0): HistBallR.setPosition([0.2, vectorValue[0], 0])#update yellow history ball when HS happens steplengthR = vectorValue[0] histR = vectorValue[2] #if (vectorValue[0] < 0.1):#do not show history when HS is a return to neutral stance # histballR.visible(0) #else: # histballR.visible(1) else: histR = vectorValue[2] if (abs(steplengthR-targetR) <= targettol):#highlight the target when the target is hit boxR.color( viz.WHITE ) else: boxR.color( viz.BLUE ) if (vectorValue[2] < -20) & (Rforceold == 0.0) & (abs(steplengthR-targetR) <= targettol): RCOUNT = RCOUNT+1 #rightcounter.setText(str(RCOUNT)) rightcounter.message(str(RCOUNT)) Rforceold = vectorValue[2] #set a variable up to do a psudo differentiation check psudoR = vectorValue[0] if (vectorName == 'BallPositionL') and not invalid: mmserver.sendVectorValue('ReturnedBallPositionL', vectorValue) mmserver.sendScalarValue('LCOUNT',LCOUNT) cursorL.setScale(0.1,vectorValue[0],0.01250)#scale cursor according to step time in Z direction if (vectorValue[0] < 0) | (vectorValue[2] < 0): cursorL.visible(0) else: cursorL.visible(1) #set history ball based on local maximum relative to anterior pelvic Y direction########################## #if (vectorValue[0] > histL) & (vectorValue[0] > 0): # HistBallL.setPosition([- vectorValue[1], 0, vectorValue[0]])#update yellow history ball when HS happens # steplengthL = histL # histL = vectorValue[0] #else: # histL = vectorValue[0] if (vectorValue[2] < 0) & (histL == 0.0): HistBallL.setPosition([-0.2,vectorValue[0],0]) steplengthL = vectorValue[0] histL = vectorValue[2] else: histL = vectorValue[2] if (abs(steplengthL-targetL) <= targettol): boxL.color( viz.WHITE ) else: boxL.color( viz.BLUE ) if (vectorValue[2] < -20) & (Lforceold == 0.0) & (abs(steplengthL-targetL) <= targettol): LCOUNT = LCOUNT+1 leftcounter.message(str(LCOUNT)) Lforceold = vectorValue[2] psudoL = vectorValue[0]
def onVectorValueReceived(vectorName, vectorValue, invalid): global cursorR global cursorL global HistBallR global histR global HistBallL global histL global boxL global boxR global targettol global targetR global targetL global steplengthL global steplengthR global psudoR global psudoL global RCOUNT global LCOUNT global Rtop global Rhsp global Ltop global Lhsp global catchflag global stridecounter global Rgorb global Lgorb if (vectorName == 'BallPositionR') and not invalid: # look for the BallPosition variable in the data stream# mmserver.sendVectorValue('ReturnedBallPositionR', vectorValue) # echo back the value of BallPosition to #MotionMonitor mmserver.sendScalarValue('RCOUNT',RCOUNT) mmserver.sendScalarValue('Rgorb',Rgorb) mmserver.sendScalarValue('Rstridecount',stridecounter) mmserver.sendScalarValue('targetR',targetR) #vectorValue[0] is the step length, vectorValue[2] is the forceplate data #update the cursor position every time vector is recieved cursorR.setScale(0.1,vectorValue[0],0.01250)#scale cursor according to step time in Z direction #Determine whether or not the cursor should be visible. If the foot of interest is behind the GT, it should disappear if (vectorValue[0] < 0) | (vectorValue[2] < 0): cursorR.visible(0) #histballR.visible(0) else: cursorR.visible(1) #histballR.visible(1) if (vectorValue[2] < -30) & (histR >= -30): #HS condition HistBallR.setPosition([0.2,vectorValue[0], 0])#update yellow history ball when HS happens steplengthR = vectorValue[0] stridecounter = stridecounter+1 #this line of code will not appear in Left foot section, as we want 12 strides after catch #if successful step was taken, keep track of it if (abs(steplengthR-targetR) <= targettol): RCOUNT = RCOUNT+1 rightcounter.message(str(RCOUNT)) Rgorb = 1 #flag this step as good or bad else: Rgorb = 0 Rhsp = vectorValue[0] psudoR = psudoR +1 if (psudoR == 5): #if it's time to update target value targetR = 0.3766*(Rhsp-Rtop) print('targetR') print(targetR) psudoR = 1 boxR.setPosition([-0.2,targetR,0]) if (catchflag == 1) & (stridecounter > 12): boxR.setPosition([0.2,targetR,0]) elif (catchflag == 1) & (stridecounter <= 12): boxR.setPosition([0.2,0.31,0]) else: boxR.setPosition([0.2,targetR,0]) histR = vectorValue[2] # print(histR) elif (vectorValue[2] == 0) & (histR < 0):#toe off condition #calculate Toe-Off position Rtop = vectorValue[0] histR = vectorValue[2] else: histR = vectorValue[2] if (abs(steplengthR-targetR) <= targettol):#highlight the target when the target is hit boxR.color( viz.WHITE ) else: boxR.color( viz.BLUE ) if (vectorName == 'BallPositionL') and not invalid: mmserver.sendVectorValue('ReturnedBallPositionL', vectorValue) mmserver.sendScalarValue('LCOUNT',LCOUNT) mmserver.sendScalarValue('Lgorb',Lgorb) mmserver.sendScalarValue('targetL',targetL) cursorL.setScale(0.1,vectorValue[0],0.01250)#scale cursor according to step time in Z direction if (vectorValue[0] < 0) | (vectorValue[2] < 0): cursorL.visible(0) else: cursorL.visible(1) if (vectorValue[2] < -30) & (histL >= -30): #HS condition HistBallL.setPosition([-0.2,vectorValue[0],0]) steplengthL = vectorValue[0] Lhsp = vectorValue[0] psudoL = psudoL +1 if (psudoL == 5): targetL = 0.3766*(Lhsp-Ltop) print('targetL') print(targetL) psudoL = 1 boxL.setPosition([-0.2,targetL,0]) if (catchflag == 1) & (stridecounter > 12): boxL.setPosition([-0.2,targetL,0]) elif (catchflag == 1) & (stridecounter <= 12): boxL.setPosition([-0.2,0.24,0]) else: boxL.setPosition([-0.2,targetL,0]) if (abs(steplengthL-targetL) <= targettol): LCOUNT = LCOUNT+1 leftcounter.message(str(LCOUNT)) Lgorb = 1 else: Lgorb = 0 histL = vectorValue[2] elif (vectorValue[2] >= -30) & (histL < -30):#toe off condition #calculate Toe-Off position Ltop = vectorValue[0] histL = vectorValue[2] else: histL = vectorValue[2] if (abs(steplengthL-targetL) <= targettol): boxL.color( viz.WHITE ) else: boxL.color( viz.BLUE )
def onVectorValueReceived(vectorName, vectorValue, invalid): global cursorR global cursorL global HistBallR global histR global HistBallL global histL global boxL global boxR global targettol global targetR global targetL global steplengthL global steplengthR global psudoR global psudoL global RCOUNT global LCOUNT global Rtop global Rhsp global Ltop global Lhsp global catchflag global stridecounter global Rgorb global Lgorb global R global R2 global rsci global lsci if ( vectorName == 'BallPositionR' ) and not invalid: # look for the BallPosition variable in the data stream# # mmserver.sendVectorValue('ReturnedBallPositionR', vectorValue) # echo back the value of BallPosition to #MotionMonitor mmserver.sendScalarValue('RCOUNT', RCOUNT) mmserver.sendScalarValue('Rgorb', Rgorb) mmserver.sendScalarValue('Rstridecount', stridecounter) mmserver.sendScalarValue('targetR', targetR) mmserver.sendScalarValue('Rtop', Rtop) mmserver.sendScalarValue('Rhsp', Rhsp) #vectorValue[0] is the step length (Hip-ankle), vectorValue[2] is the forceplate data #update the cursor position every time vector is recieved # cursorR.setScale(0.1,0.5/Rhsp*(vectorValue[0]+1/(1+R)*(Rtop-R*vectorValue[0])),0.01250)#scale cursor according to modified step length in vertical direction # cursorR.setScale(0.1,0.5/Rhsp*(vectorValue[0]+1/(1+R)*(abs(Rtop)-R*vectorValue[0])),0.01250) cursorR.setScale(0.1, rsci * vectorValue[0], 0.01250) #Determine whether or not the cursor should be visible. If the foot of interest is behind the hips, it should disappear if (vectorValue[0] < 0) | (vectorValue[2] < 0): cursorR.visible(0) #histballR.visible(0) else: cursorR.visible(1) #histballR.visible(1) #check for gait events if (vectorValue[2] < -30) & (histR >= -30): #HS condition HistBallR.setPosition( [0.2, rsci * vectorValue[0], 0]) #update yellow history footprint when HS happens steplengthR = rsci * vectorValue[0] stridecounter = stridecounter + 1 #this line of code will not appear in Left foot section, as we want 12 strides after catch for each side if (psudoR == 5): #if it's time to update target alpha value Rhsp = vectorValue[0] #update the alpha value rsci = (1 / (Rhsp + 1 / (1 + R) * (abs(Rtop - R * Rhsp)))) #if successful step was taken, keep track of it if (abs(steplengthR - targetR) <= targettol): RCOUNT = RCOUNT + 1 rightcounter.message(str(RCOUNT)) Rgorb = 1 #flag this step as good or bad else: Rgorb = 0 if (catchflag == 1) & (stridecounter > 12): boxR.setPosition([0.2, targetR, 0]) elif (catchflag == 1) & (stridecounter <= 12): boxR.setPosition([0.2, 0.31, 0]) else: boxR.setPosition([0.2, targetR, 0]) histR = vectorValue[2] elif (vectorValue[2] == 0) & (histR < 0): #toe-off condition #calculate Toe-Off position if (psudoR == 5): Rtop = vectorValue[0] #update beta value psudoR = 1 psudoR = psudoR + 1 histR = vectorValue[2] else: histR = vectorValue[2] if (abs(steplengthR - targetR) <= targettol ): #highlight the target when the target is hit within tolerance boxR.color(viz.WHITE) else: boxR.color(viz.BLUE) if (vectorName == 'BallPositionL') and not invalid: # mmserver.sendVectorValue('ReturnedBallPositionL', vectorValue) mmserver.sendScalarValue('LCOUNT', LCOUNT) mmserver.sendScalarValue('Lgorb', Lgorb) mmserver.sendScalarValue('targetL', targetL) mmserver.sendScalarValue('Ltop', Ltop) mmserver.sendScalarValue('Lhsp', Lhsp) # cursorL.setScale(0.1,0.5/Lhsp*(vectorValue[0]+1/(1+R2)*(abs(Ltop)-R2*vectorValue[0])),0.01250)#scale cursor according to step time in Z direction cursorL.setScale(0.1, lsci * vectorValue[0], 0.01250) if (vectorValue[0] < 0) | (vectorValue[2] < 0): cursorL.visible(0) else: cursorL.visible(1) if (vectorValue[2] < -30) & (histL >= -30): #HS condition HistBallL.setPosition([-0.2, lsci * vectorValue[0], 0]) steplengthL = lsci * vectorValue[0] if (psudoL == 5): Lhsp = vectorValue[0] lsci = (1 / (Lhsp + 1 / (1 + R2) * (abs(Ltop - R2 * Lhsp)))) if (catchflag == 1) & (stridecounter > 12): boxL.setPosition([-0.2, targetL, 0]) elif (catchflag == 1) & (stridecounter <= 12): boxL.setPosition([-0.2, 0.24, 0]) else: boxL.setPosition([-0.2, targetL, 0]) if (abs(steplengthL - targetL) <= targettol): LCOUNT = LCOUNT + 1 leftcounter.message(str(LCOUNT)) Lgorb = 1 else: Lgorb = 0 histL = vectorValue[2] elif (vectorValue[2] >= -30) & (histL < -30): #toe off condition #calculate Toe-Off position if (psudoL == 5): Ltop = vectorValue[0] psudoL = 1 psudoL = psudoL + 1 histL = vectorValue[2] else: histL = vectorValue[2] if (abs(steplengthL - targetL) <= targettol): boxL.color(viz.WHITE) else: boxL.color(viz.BLUE)
def onVectorValueReceived(vectorName, vectorValue, invalid): global cursorR global cursorL global HistBallR global histR global HistBallL global histL global boxL global boxR global targettol global target global steplengthL global steplengthR global psudoR global psudoL global RCOUNT global LCOUNT global Rforceold global Lforceold if ( vectorName == 'BallPositionR' ) and not invalid: # look for the BallPosition variable in the data stream# mmserver.sendVectorValue( 'ReturnedBallPositionR', vectorValue ) # echo back the value of BallPosition to #MotionMonitor mmserver.sendScalarValue('RCOUNT', RCOUNT) #vectorValue[0] is the step length, vectorValue[2] is the forceplate data cursorR.setScale( 0.1, vectorValue[0], 0.01250) #scale cursor according to step time in Z direction if (vectorValue[0] < 0) | (vectorValue[2] < 0): cursorR.visible(0) #histballR.visible(0) else: cursorR.visible(1) #histballR.visible(1) #set history at heel strike#################################### if (vectorValue[2] < 0) & (histR == 0.0): HistBallR.setPosition( [0.2, vectorValue[0], 0]) #update yellow history ball when HS happens steplengthR = vectorValue[0] histR = vectorValue[2] #if (vectorValue[0] < 0.1):#do not show history when HS is a return to neutral stance # histballR.visible(0) #else: # histballR.visible(1) else: histR = vectorValue[2] if (abs(steplengthR - targetR) <= targettol): #highlight the target when the target is hit boxR.color(viz.WHITE) else: boxR.color(viz.BLUE) if (vectorValue[2] < -20) & (Rforceold == 0.0) & ( abs(steplengthR - targetR) <= targettol): RCOUNT = RCOUNT + 1 #rightcounter.setText(str(RCOUNT)) rightcounter.message(str(RCOUNT)) Rforceold = vectorValue[2] #set a variable up to do a psudo differentiation check psudoR = vectorValue[0] if (vectorName == 'BallPositionL') and not invalid: mmserver.sendVectorValue('ReturnedBallPositionL', vectorValue) mmserver.sendScalarValue('LCOUNT', LCOUNT) cursorL.setScale( 0.1, vectorValue[0], 0.01250) #scale cursor according to step time in Z direction if (vectorValue[0] < 0) | (vectorValue[2] < 0): cursorL.visible(0) else: cursorL.visible(1) #set history ball based on local maximum relative to anterior pelvic Y direction########################## #if (vectorValue[0] > histL) & (vectorValue[0] > 0): # HistBallL.setPosition([- vectorValue[1], 0, vectorValue[0]])#update yellow history ball when HS happens # steplengthL = histL # histL = vectorValue[0] #else: # histL = vectorValue[0] if (vectorValue[2] < 0) & (histL == 0.0): HistBallL.setPosition([-0.2, vectorValue[0], 0]) steplengthL = vectorValue[0] histL = vectorValue[2] else: histL = vectorValue[2] if (abs(steplengthL - targetL) <= targettol): boxL.color(viz.WHITE) else: boxL.color(viz.BLUE) if (vectorValue[2] < -20) & (Lforceold == 0.0) & ( abs(steplengthL - targetL) <= targettol): LCOUNT = LCOUNT + 1 leftcounter.message(str(LCOUNT)) Lforceold = vectorValue[2] psudoL = vectorValue[0]