#file : InMoov2Arm 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 the arm servos
# InMoov arm default Arduino pins:
# bicep pin 8
# rotate pin 9
# shoulder pin 10
# omoplate pin 11

i01_right = runtime.start('i01.right', 'Arduino')
# Change the COM port according to yours:
i01_right.connect("COM9")

i01 = Runtime.start("i01", "InMoov2")
i01.startEar()
#################
i01_mouth = runtime.create('i01.mouth', 'MarySpeech')
i01_mouth.setVoice('Mark')
i01.startMouth()
##############
i01_rightArm = Runtime.start("i01.rightArm", "InMoov2Arm")
# Tweaking defaults settings of right arm servos:

# Servo Config : i01_rightArm_bicep
# sets initial position of servo before moving
i01_rightArm_bicep.setPosition(0)
i01_rightArm_bicep.map(0.0,90.0,0.0,90.0)
i01_rightArm_bicep.setInverted(False)
i01_rightArm_bicep.setSpeed(50.0)
i01_rightArm_bicep.setRest(0.0)
i01_rightArm_bicep.setPin(8)
i01_rightArm_bicep.setAutoDisable(True)

# Servo Config : i01_rightArm_rotate
# sets initial position of servo before moving
i01_rightArm_rotate.setPosition(90)
i01_rightArm_rotate.map(40.0,180.0,40.0,180.0)
i01_rightArm_rotate.setInverted(False)
i01_rightArm_rotate.setSpeed(50.0)
i01_rightArm_rotate.setRest(90.0)
i01_rightArm_rotate.setPin(9)
i01_rightArm_rotate.setAutoDisable(True)

# Servo Config : i01_rightArm_shoulder
# sets initial position of servo before moving
i01_rightArm_shoulder.setPosition(30)
i01_rightArm_shoulder.map(0.0,180.0,0.0,180.0)
i01_rightArm_shoulder.setInverted(False)
i01_rightArm_shoulder.setSpeed(50.0)
i01_rightArm_shoulder.setRest(30.0)
i01_rightArm_shoulder.setPin(10)
i01_rightArm_shoulder.setAutoDisable(True)

# Servo Config : i01_rightArm_omoplate
# sets initial position of servo before moving
i01_rightArm_omoplate.setPosition(10)
i01_rightArm_omoplate.map(10.0,80.0,10.0,80.0)
i01_rightArm_omoplate.setInverted(False)
i01_rightArm_omoplate.setSpeed(50.0)
i01_rightArm_omoplate.setRest(10.0)
i01_rightArm_omoplate.setPin(11)
i01_rightArm_omoplate.setAutoDisable(True)

##############
i01_right.attach("i01.rightArm.bicep")
i01_right.attach("i01.rightArm.shoulder")
i01_right.attach("i01.rightArm.rotate")
i01_right.attach("i01.rightArm.omoplate")
##############
i01.startChatBot()
##############
# verbal commands set in the chatbot
##############
# HELP
# HELP GESTURES
# DA VINCI.
# ARMS UP.
# ARMS FRONT.
# LIFT YOUR RIGHT ARM.
# RAISE YOUR ARM.
# SHOW YOUR MUSCLES.
# RELAX.
# GIVING.
# REST.

def raiserightarm():
  #i01.moveArm("left",5.00,90.00,30.00,12.00)
  i01.moveArm("right",57.00,51.00,30.00,33.00)
  #i01.moveHand("left",0.00,0.00,0.00,0.00,0.00,90.00)
  #i01.moveHand("right",0.00,0.00,0.00,0.00,0.00,177.00)
  #i01.moveTorso(90.00,90.00,90.00)