def onRun( self ): # Setup subscribers. sensorsTactileButtonTopic = rospy.get_param( 'sensorsTopic', '/nao_sensors_tactile_button' ); sensorsTactileButtonSubscriber = rospy.Subscriber( sensorsTactileButtonTopic, nao_sensors.msg.TactileButton, self.onTactileButtonPressed ); speechMessage = 'Hi, I am Naomi. Touch my head to start the experiment.'; lastSpeechTime = rospy.Time.now() - self.SPEECH_INTERVAL; # So that Naomi will immediatly start talking, instead of X seconds later. # Sit down. Utils.getInstance().enableBodyStiffness(); Utils.getInstance().setBodyPose( 'sit' ); Utils.getInstance().disableBodyStiffness(); while( self.isRunning() ): while( self.isPaused() ): rospy.sleep( self.SLEEP_TIME ); # Say the message. if( ( lastSpeechTime + self.SPEECH_INTERVAL ) < rospy.Time.now() ): Utils.getInstance().say( speechMessage ); rospy.loginfo( 'Said: {speechMessage}'.format( speechMessage = speechMessage ) ); lastSpeechTime = rospy.Time.now(); # Check if the head has been touched. if( self.__headHasBeenTouched ): break; rospy.sleep( self.SLEEP_TIME ); # Clean up. sensorsTactileButtonSubscriber.unregister(); self.finished.emit();
def onRun( self ): Utils.enableBodyStiffness(); Utils.getInstance().setBodyPose( 'headInitial' ); Utils.disableBodyStiffness(); # Sleep if paused. while( self.isPaused() ): rospy.sleep( self.SLEEP_TIME ); # Say the message. Utils.getInstance().say( 'Introduction.' ); rospy.sleep( 3 * self.SLEEP_TIME ); self.finished.emit();
def onRun( self ): Utils.getInstance().enableBodyStiffness(); Utils.getInstance().setBodyPose( 'headInitial' ); Utils.getInstance().say( 'Thank you for the experiment.' ); Utils.getInstance().disableBodyStiffness(); self.finished.emit();
def onRun( self ): # Pick NUMBER_OF_PIECES pieces. collectablePieces = random.sample( self.getModel().getPieces(), self.NUMBER_OF_COLLECTABLE_PIECES ); currentCollectablePiece = None; lastActionTime = None; Utils.getInstance().enableBodyStiffness(); while( self.isRunning() ): while( self.isPaused() ): rospy.sleep( self.SLEEP_TIME ); # Check if we are done. if( len( collectablePieces ) == 0 and currentCollectablePiece is None ): break; # Select a new piece, if there is none. if( currentCollectablePiece is None ): currentCollectablePiece = collectablePieces.pop(); #rospy.loginfo( 'Piece X has to be collected.' ); # Handle the piece. if( lastActionTime is None ): currentCollectablePiece.changeStatus( Piece.NONE, Piece.HANDLING ); # Look down at the pieces. #Utils.getInstance().enableBodyStiffness(); Utils.getInstance().setBodyPose( 'headDown' ); #Utils.getInstance().disableBodyStiffness(); # Tell the user to pick up the piece and point towards it. rospy.loginfo( 'Telling the user to pick up piece X.' ); # Determine to where to point. # This is really fugly, but for now sufficient. laneWidth = self.getModel().getImage().width() / 5; x = currentCollectablePiece.x(); bodyPose = None; if( x < laneWidth ): bodyPose = 'laneOne'; elif( x < 2 * laneWidth ): bodyPose = 'laneTwo'; elif( x < 3 * laneWidth ): bodyPose = 'laneThree'; elif( x < 4 * laneWidth ): bodyPose = 'laneFour'; else: bodyPose = 'laneFive'; # Point. Utils.getInstance().setBodyPose( bodyPose ); Utils.getInstance().say( 'Pick up the piece.' ); rospy.sleep( 3 * self.SLEEP_TIME ); # Move back to the original position. Utils.getInstance().setBodyPose( 'sitWithHeadDown' ); rospy.sleep( 3 * self.SLEEP_TIME ); lastActionTime = rospy.Time.now(); elif( ( lastActionTime + self.ACTION_INTERVAL ) < rospy.Time.now() ): rospy.loginfo( 'The user failed to grab the object with N seconds.' ); Utils.getInstance().say( 'You did not pick the correct piece.' ); rospy.sleep( 5 * self.SLEEP_TIME ); else: # Check if the user has take the object. if( not( currentCollectablePiece.getStatus() & Piece.DETECTED ) ): rospy.loginfo( 'Piece X has been collected.' ); Utils.getInstance().say( 'Well done.' ); currentCollectablePiece.changeStatus( Piece.HANDLING, Piece.HANDLED ); currentCollectablePiece = None; lastActionTime = None; rospy.sleep( 2 * self.SLEEP_TIME ); Utils.getInstance().disableBodyStiffness(); self.finished.emit();
def onRun( self ): Utils.getInstance().enableBodyStiffness(); Utils.getInstance().setBodyPose( 'headInitial' ); Utils.getInstance().say( 'Make something you think I would like out of the pieces you just picked.' ); rospy.sleep( 2 * self.SLEEP_TIME ); Utils.getInstance().setBodyPose( 'headDown' ); rospy.sleep( 8 * self.SLEEP_TIME ); Utils.getInstance().say( 'Lets see what you have made.' ); rospy.sleep( 4 * self.SLEEP_TIME ); Utils.getInstance().setBodyPose( 'headInitial' ); Utils.getInstance().say( 'It looks interesting, but I think you can do better.' ); Utils.getInstance().disableBodyStiffness(); self.finished.emit();