Skip to content

Update InMoov2.full3.byGael.Langevin.1.py #140

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
87 changes: 52 additions & 35 deletions home/hairygael/InMoov2.FingerStarter.with.voice.control.py
Original file line number Diff line number Diff line change
@@ -1,53 +1,70 @@
#file : InMoov2.FingerStarter with voice control.py

# this will run with versions of MRL 1.0.107
# 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 finger box
# for any command which you say - you will be required to say a confirmation
# e.g. you say -> open finger, InMoov will ask -> "Did you say open finger?", you will need to
# respond with a confirmation ("yes","correct","yeah","ya")
#The "finger" is the index of the hand
# do voice control of a finger servo
#The "finger" is the index finger of the hand
#index Arduino connection pin 3

rightPort = "COM7"
i01_right = runtime.start('i01.right', 'Arduino')
i01_right.connect("COM9")

i01 = Runtime.createAndStart("i01", "InMoov")
i01 = Runtime.start("i01", "InMoov2")
i01.startEar()
#################
i01_mouth = runtime.create('i01.mouth', 'MarySpeech')
i01_mouth.setVoice('Mark')
i01.startMouth()
i01.mouth.setGoogleURI("http://thehackettfamily.org/Voice_api/api2.php?voice=Ryan&txt=")
##############
i01.startRightHand(rightPort)
i01_rightHand = Runtime.start("i01.rightHand", "InMoov2Hand")
# tweaking defaults settings of right hand index
i01.rightHand.index.setMinMax(0,180)
i01.rightHand.index.map(0,180,35,140)

# verbal commands
ear = i01.ear

ear.addCommand("attach right hand", "i01.rightHand", "attach")
ear.addCommand("disconnect right hand", "i01.rightHand", "detach")
ear.addCommand("attach finger", "i01.rightHand.index", "attach")
ear.addCommand("disconnect finger", "i01.rightHand.index", "detach")
ear.addCommand("open finger", "python", "fingeropen")
ear.addCommand("close finger", "python", "fingerclose")
ear.addCommand("finger to the middle", "python", "fingermiddle")
ear.addCommand("rest", i01.getName(), "rest")
ear.addCommand("capture gesture", ear.getName(), "captureGesture")
ear.addCommand("manual", ear.getName(), "lockOutAllGrammarExcept", "voice control")
ear.addCommand("voice control", ear.getName(), "clearLock")

ear.addComfirmations("yes","correct","yeah","ya")
ear.addNegations("no","wrong","nope","nah")

ear.startListening()
i01_rightHand_index.map(0,180,35,140)
i01_right.attach("i01.rightHand")
##############
i01.startChatBot()
##############
# verbal commands set in the chatbot
##############
# OPEN YOUR FINGER.
# CLOSE YOUR FINGER.
# FINGER TO THE MIDDLE.
# ACTION YOUR FINGER.
# OPEN HAND.
# CLOSE HAND.
# OPEN HANDS.
# CLOSE HANDS.
# OPEN YOUR RIGHT HAND.
# OPEN YOUR LEFT HAND.
# CLOSE YOUR RIGHT HAND.
# CLOSE YOUR LEFT HAND.
# SLOWLY CLOSE YOUR RIGHT HAND.


def fingeropen():
i01.moveHand("right",0,0,0,0,0,0)
#i01.moveHand("right",0,0,0,0,0,0)
i01_rightHand_index.moveTo(0)

def fingerclose():
i01.moveHand("right",0,180,0,0,0,0)
#i01.moveHand("right",0,180,0,0,0,0)
i01_rightHand_index.moveTo(180)

def fingermiddle():
i01.moveHand("right",0,90,0,0,0,0)
#i01.moveHand("right",0,90,0,0,0,0)
i01_rightHand_index.moveTo(90)

def fingeraction():
i01_rightHand_index.setSpeed(500)## High speed
i01_rightHand_index.moveTo(0)
sleep(1)
i01_rightHand_index.moveTo(180)
sleep(1)
i01_rightHand_index.moveTo(0)
sleep(1)
i01_rightHand_index.moveTo(180)
sleep(1)
i01_rightHand_index.moveTo(0)
sleep(1)
i01_rightHand_index.moveTo(180)
sleep(1)
i01_rightHand_index.moveTo(0)
Loading