Just an exemple on how to give some human moovement like

 

Main script i have 

randomGesture = True
 
if randomGesture:
    randomEyeLid = True

 

in gesture python scripts i got:

###EYE LID RANDOM GESTURES#####
def reyelid():
    eyelid.attach()
    eyelid.moveTo(0)
    sleep(0.2)
    eyelid.moveTo(180)
    sleep(0.5)
    eyelid.detach() 
    
def reyelida():
    sleep(5) 
def reyelidb():
    sleep(0.5) 
def reyelidc():
    sleep(1.5) 
    
if randomEyeLid:    
    while True:
        random.choice([reyelid,reyelida,reyelida,reyelidb,reyelidc])()

hairygael

7 years 11 months ago

Thanks Pedro,

here is what I try to do:

I start random live:

def VieAleatoire():
    MoveHeadTimer.startClock()
    global MoveHeadRandom
    MoveHeadRandom=1
    MoveBodyTimer.startClock()
    global MoveBodyRandom
    MoveBodyRandom=1

Each parts are using this script:

MoveBodyTimer = Runtime.start("MoveBodyTimer","Clock")
MoveBodyTimer.setInterval(10)

def MoveBody(timedata):
    i01.setHandSpeed("left", 0.8, 0.8, 0.8, 0.8, 0.8, 0.8)
    i01.setHandSpeed("right", 0.8, 0.8, 0.8, 0.8, 0.8, 0.8)
    i01.setArmSpeed("right", 0.5, 0.5, 0.5, 0.5)
    i01.setArmSpeed("left", 0.5, 0.5, 0.5, 0.5)
    i01.setHeadSpeed(0.5, 0.5)
    rollneck.setSpeed(0.5)
    i01.setTorsoSpeed(0.5, 0.35, 0.5)
    i01.moveHead(random.randint(70,100), random.randint(60,110))
    rollneck.moveTo(random.randint(50,130))
    i01.moveArm("left",random.randint(0,6),random.randint(78,90),random.randint(20,28),random.randint(12,17))
    i01.moveArm("right",random.randint(0,6),random.randint(78,90),random.randint(20,28),random.randint(12,17))
    i01.moveHand("left",random.randint(50,92),random.randint(28,130),random.randint(28,100),random.randint(28,110),random.randint(28,110),random.randint(20,40))
    i01.moveHand("right",random.randint(50,92),random.randint(20,100),random.randint(28,110),random.randint(28,110),random.randint(28,110),random.randint(120,160))
    i01.moveTorso(random.randint(85,95),random.randint(85,95),random.randint(85,95))
    MoveBodyTimer.setInterval(random.randint(10000,20000))

MoveBodyTimer.addListener("pulse", python.name, "MoveBody")

Then if I call "s"earch humans it automatically stops the random:

def trackHumans():
    global MoveHeadRandom
    MoveHeadRandom=0
    i01.headTracking.faceDetect()
    i01.eyesTracking.faceDetect()
    fullspeed()

Mozar says this kind of loops i did can give some problems lagging the main script and i should use instead a clock, do u guys have any toughts on this?

hairygael

7 years 11 months ago

In reply to by pedro

Three scripts.

VieAleatoire calls the two second scripts:

######################################

def VieAleatoire():
    #if MoveBodyRandom==1 and MoveHeadRandom==1:
    global MoveBodyRandom
    global MoveHeadRandom
    MoveBodyRandomize()
    MoveHeadRandomize()
    MoveHeadTimer.startClock()
    MoveBodyTimer.startClock()
    MoveBodyRandom=1
    MoveHeadRandom=1

#######################################

def MoveBodyRandomize():
    if MoveBodyRandom==1:
        i01.setHandSpeed("left", 0.8, 0.8, 0.8, 0.8, 0.8, 0.8)
        i01.setHandSpeed("right", 0.8, 0.8, 0.8, 0.8, 0.8, 0.8)
        i01.setArmSpeed("right", 0.5, 0.5, 0.5, 0.5)
        i01.setArmSpeed("left", 0.5, 0.5, 0.5, 0.5)
        i01.setHeadSpeed(0.5, 0.5)
        rollneck.setSpeed(0.5)
        i01.setTorsoSpeed(0.5, 0.35, 0.5)
        i01.moveHead(random.randint(70,100), random.randint(60,110))
        rollneck.moveTo(random.randint(50,130))
        i01.moveArm("left",random.randint(0,6),random.randint(78,90),random.randint(20,28),random.randint(12,17))
        i01.moveArm("right",random.randint(0,6),random.randint(78,90),random.randint(20,28),random.randint(12,17))
        i01.moveHand("left",random.randint(50,92),random.randint(28,130),random.randint(28,100),random.randint(28,110),random.randint(28,110),random.randint(20,40))
        i01.moveHand("right",random.randint(50,92),random.randint(20,100),random.randint(28,110),random.randint(28,110),random.randint(28,110),random.randint(120,160))
        i01.moveTorso(random.randint(85,95),random.randint(85,95),random.randint(85,95))

MoveBodyTimer = Runtime.start("MoveBodyTimer","Clock")
MoveBodyTimer.setInterval(random.randint(600,1200))

def MoveBody(timedata):
   MoveBodyRandomize()
MoveBodyTimer.setInterval(random.randint(5000,20000))

def MoveBodyStopped():
    if MoveBodyRandom==1:
        MoveBodyTimer.addListener("pulse", python.name, "MoveBody")
        MoveBodyTimer.addListener("clockStopped", python.name, "MoveBodyStopped")

def MoveBodyStart():
    MoveBodyRandomize()

MoveBodyTimer.addListener("pulse", python.name, "MoveBody")
MoveBodyTimer.addListener("clockStopped", python.name, "MoveBodyStopped")        
MoveBodyTimer.addListener("clockStarted", python.name, "MoveBodyStart")

###################################

 

def MoveHeadRandomize():
    if MoveHeadRandom==1:
        i01.setHeadSpeed(0.5, 0.5)
        rollneck.setSpeed(0.5)
        i01.moveHead(random.randint(70,100), random.randint(60,90))
        rollneck.moveTo(random.randint(50,130))
    

MoveHeadTimer = Runtime.start("MoveHeadTimer","Clock")
MoveHeadTimer.setInterval(random.randint(600,1200))

def MoveHead(timedata):
   MoveHeadRandomize()
MoveHeadTimer.setInterval(random.randint(5000,20000))

def MoveHeadStopped():
    if MoveHeadRandom==1:
        MoveHeadTimer.addListener("pulse", python.name, "MoveHead")
        MoveHeadTimer.addListener("clockStopped", python.name, "MoveHeadStopped")

def MoveHeadStart():
    MoveHeadRandomize()
    
MoveHeadTimer.addListener("pulse", python.name, "MoveHead")
MoveHeadTimer.addListener("clockStopped", python.name, "MoveHeadStopped")        
MoveHeadTimer.addListener("clockStarted", python.name, "MoveHeadStart")    
 

 

##############################