Idle-Random

 

 

: Main

   

    //{ "Main/Startup(once)"

      PLAY ACTION STAND

      WAIT

    //}

    // clear globals and sensors

    CLR SENSORS

 

    LOCAL idleCount 0

 

    // Main Loop

    WHILE 1 = 1

        ADD idleCount 1

        IF idleCount > 50 THEN

            // 50 ticks (approx 5 seconds) with nothing happening

                CALL DoSomethingRandom_Stand

            LET idleCount 0

        ENDIF

 

        WAIT 100

    WEND // end of main loop

 

/////////////////////////////////////////////////////////////

// Random skits after 10 seconds of idleness

 

:DoSomethingRandom_Stand

    LOCAL randVal

    RND randVal 1 5

    IF randVal == 1 THEN

   //{ "Idle/Stand Random#1"

          PLAY ACTION WALK 0 500

          WAIT

          CALL Swinhead

        //}

    ENDIF

    IF randVal == 2 THEN

        //{ "Idle/Stand Random#2"

          PLAY ACTION TURN 90 // Turn Left

          WAIT

          CALL Swinhead

        //}

    ENDIF

    IF randVal == 3 THEN

        //{ "Idle/Stand Random#3"

          PLAY ACTION TURN -90 // Turn Right

          WAIT

          CALL Swinhead

        //}

    ENDIF

    IF randVal == 4 THEN

        //{ "Idle/Stand Random#4"

          PLAY ACTION SIT // I'm tired of standing around

          WAIT

          CALL Swinhead

        //}

    ENDIF

 

 IF randVal == 5 THEN

        //{ "Idle/Stand Random#5"

          PLAY ACTION LIE // I'm tired of standing around

          WAIT

          CALL Swinhead

        //}

    ENDIF

RETURN

 

:Swinhead

 

PLAY:ACTION:MOVE_HEAD:90:0

// Move head to the left for 90 degrees

WAIT

PLAY:ACTION:MOVE_HEAD:-90:0

// Move head to the right for 90 degrees

WAIT

PLAY:ACTION:MOVE_HEAD:0:0

// Move head back to original position (Calibration)

WAIT

         

RETURN

 

 

Description::

 

   If AIBO idles for 5 seconds, he will walk for 500 mm or Turn Left or Turn Right or Sit down or lie down randomly. AIBO looks like autonomously, having his own will.