while(runEpisode == 1): ## Reset / Update episodeTime = episodeTime + 1 simulationTime = simulationTime + 1 motherWrist = [] motherShoulder = [] motherElbow = [] motherHead = [] babyWrist = [] babyShoulder = [] babyElbow = [] babyHead = [] ## Receive / Parse message animMessage = win32file.ReadFile(p, 4096)[1] uf.parseMessage(animMessage, motherWrist, motherShoulder, motherElbow, motherHead, babyWrist, babyShoulder, babyElbow, babyHead) uf.writeReceivedCoordinatesToFile(babyFile, motherWrist, motherShoulder, motherElbow, motherHead, babyWrist, babyShoulder, babyElbow, babyHead, simulationTime) ## Manages decisions if(babyEpisodeStatus == 'TO_START'): messageToSend = 'INIT ' babyEpisodeStatus = 'INITIALIZED' print "BABY TO_START" elif(babyEpisodeStatus == 'INITIALIZED'): print "BABY INITIALIZED" #makes so baby always must walk at least a little if(motherHead[0] - babyHead[0] > GESTURE_THRESHOLD): babyEpisodeStatus = 'WALK' messageToSend = 'DO_NOTHING' moWristInit = np.array([motherWrist[0],motherWrist[1],motherWrist[2]]) elif(babyEpisodeStatus == 'WALK'): print "BABY WALK"
motherFile = open('trainer_motherTrajectory.txt', 'w') while(runSimulation == 1): motherWrist = [] motherShoulder = [] motherElbow = [] motherHead = [] babyWrist = [] babyShoulder = [] babyElbow = [] babyHead = [] animMessage = win32file.ReadFile(p, 4096)[1] uf.parseMessage(animMessage, motherWrist, motherShoulder, motherElbow, motherHead, babyWrist, babyShoulder, babyElbow, babyHead) uf.writeReceivedCoordinatesToFile(motherFile, motherWrist, motherShoulder, motherElbow, motherHead, babyWrist, babyShoulder, babyElbow, babyHead, episodeTime) episodeTime = episodeTime + 1 if(simulationStatus == 'TRAIN'): messageToSend = 'MOVE_HEAD ' + str(MOTHER_INITIAL_POSITION[0]) + ' ' + str(MOTHER_INITIAL_POSITION[1]) + ' ' + str(MOTHER_INITIAL_POSITION[2]) + ' ' + str(episodeTime) simulationStatus = 'INITIALIZED' print "Initialized mother at initial position" elif (simulationStatus == 'INITIALIZED'): babyReachTarget = motherWrist messageToSend = 'DO_NOTHING' simulationStatus = 'WATCHING' elif(simulationStatus == 'WATCHING'): if episodeTime < 30: messageToSend = 'DO_NOTHING' else: