#file : InMoov2Head with voice control.py
# this will run with versions of MRL NIXIE
# a very minimal script for InMoov
# although this script is very short you can still
# do voice control of a head servos
# InMoov head default LEFT Arduino pins:
# jaw pin 26
# neck pin 12
# rothead pin 13
# eyeX pin 22
# eyeY pin 24
# InMoov head default RIGHT Arduino pins:
# rollneck pin 12
# eyelidLeft pin 22
# eyelidRight pin 24
i01_right = runtime.start('i01.right', 'Arduino')
# Change the COM port according to yours:
i01_right.connect("COM9")
i01_left = runtime.start('i01.left', 'Arduino')
# Change the COM port according to yours:
i01_left.connect("COM10")
#################
i01 = Runtime.start("i01", "InMoov2")
i01.startEar()
#################
i01_mouth = runtime.create('i01.mouth', 'MarySpeech')
i01_mouth.setVoice('Mark')
i01.startMouth()
##############
i01_head = Runtime.start("i01.head", "InMoov2Head")
##############
# Tweaking defaults settings of left head servos:
# Servo Config : i01_head_jaw
# sets initial position of servo before moving
i01_head_jaw.setPosition(0)
i01_head_jaw.map(0.0,180.0,10.0,25.0)
i01_head_jaw.setInverted(False)
i01_head_jaw.setSpeed(100.0)
i01_head_jaw.setRest(0.0)
i01_head_jaw.setPin(26)
i01_head_jaw.setAutoDisable(True)
# Servo Config : i01_head_eyeX
# sets initial position of servo before moving
i01_head_eyeX.setPosition(90)
i01_head_eyeX.map(0.0,180.0,60.0,120.0)
i01_head_eyeX.setInverted(False)
i01_head_eyeX.setSpeed(50.0)
i01_head_eyeX.setRest(90.0)
i01_head_eyeX.setPin(22)
i01_head_eyeX.setAutoDisable(True)
# Servo Config : i01_head_eyeY
# sets initial position of servo before moving
i01_head_eyeY.setPosition(90)
i01_head_eyeY.map(0.0,180.0,60.0,120.0)
i01_head_eyeY.setInverted(False)
i01_head_eyeY.setSpeed(50.0)
i01_head_eyeY.setRest(90.0)
i01_head_eyeY.setPin(24)
i01_head_eyeY.setAutoDisable(True)
# Servo Config : i01_head_rothead
# sets initial position of servo before moving
i01_head_rothead.setPosition(90)
i01_head_rothead.map(0.0,180.0,30.0,150.0)
i01_head_rothead.setInverted(False)
i01_head_rothead.setSpeed(50.0)
i01_head_rothead.setRest(90.0)
i01_head_rothead.setPin(13)
i01_head_rothead.setAutoDisable(True)
# Servo Config : i01_head_neck
# sets initial position of servo before moving
i01_head_neck.setPosition(90)
i01_head_neck.map(0.0,180.0,20.0,160.0)
i01_head_neck.setInverted(False)
i01_head_neck.setSpeed(50.0)
i01_head_neck.setRest(90.0)
i01_head_neck.setPin(12)
i01_head_neck.setAutoDisable(True)
###############
# Tweaking defaults settings of right head servos:
# Servo Config : i01_head_rollNeck
# sets initial position of servo before moving
i01_head_rollNeck.setPosition(90)
i01_head_rollNeck.map(0.0,180.0,60.0,130.0)
i01_head_rollNeck.setInverted(False)
i01_head_rollNeck.setSpeed(50.0)
i01_head_rollNeck.setRest(90.0)
i01_head_rollNeck.setPin(12)
i01_head_rollNeck.setAutoDisable(True)
# Servo Config : i01_head_eyelidLeft
# sets initial position of servo before moving
i01_head_eyelidLeft.setPosition(90)
i01_head_eyelidLeft.map(0.0,180.0,60.0,120.0)
i01_head_eyelidLeft.setInverted(False)
i01_head_eyelidLeft.setSpeed(50.0)
i01_head_eyelidLeft.setRest(0.0)
i01_head_eyelidLeft.setPin(22)
i01_head_eyelidLeft.setAutoDisable(True)
# Servo Config : i01_head_eyelidRight
# sets initial position of servo before moving
i01_head_eyelidRight.setPosition(90)
i01_head_eyelidRight.map(0.0,180.0,60.0,120.0)
i01_head_eyelidRight.setInverted(False)
i01_head_eyelidRight.setSpeed(50.0)
i01_head_eyelidRight.setRest(0.0)
i01_head_eyelidRight.setPin(24)
i01_head_eyelidRight.setAutoDisable(True)
##############
i01_left.attach("i01.head.jaw")
i01_left.attach("i01.head.neck")
i01_left.attach("i01.head.rothead")
i01_left.attach("i01.head.eyeX")
i01_left.attach("i01.head.eyeY")
##############
i01_right.attach("i01.head.rollNeck")
i01_right.attach("i01.head.eyelidLeft")
i01_right.attach("i01.head.eyelidRight")
##############
i01.startChatBot()
##############
# verbal commands set in the chatbot
##############
# HELP
# HELP GESTURES
# LOOK ON YOUR RIGHT SIDE.
# LOOK ON YOUR LEFT SIDE.
# LOOK IN THE MIDDLE.
# LOOK UP.
# LOOK DOWN.
# TILT YOUR HEAD ON THE RIGHT SIDE.
# TILT YOUR HEAD ON THE LEFT SIDE.
# CHECK YOUR NECK.
# RELAX.
# REST.
def lookup():
i01.setHeadSpeed(80, 80, 50, 50, 100.0)
i01.moveHead(160,90,90,170,0,90)
sleep(1)
i01.finishedGesture()
relax()