This script is a work in progress:
# 4PID + PIR Sensor script
#for inmoov2.0 service
headPort = "COM7"
#leftPort = "COM7"
#rightPort= "COM8"
#select the pin where to start polling ( we can connect a PIR to this pin to see his state HIGH/LOW)
readDigitalPin = 28
i01 = Runtime.createAndStart("i01", "InMoov")
#leftArm = i01.startLeftArm(leftPort)
#leftHand = i01.startLeftHand(leftPort)
#rightArm = i01.startRightArm(rightPort)
#rightHand = i01.startRightHand(rightPort)
head = i01.startHead(headPort)
neck = i01.getHeadTracking()
neck.faceDetect()
############################################################
#if needed we can tweak the default settings with these lines
i01.head.eyeY.setMinMax(80,100)
i01.head.eyeY.setRest(78)
i01.head.eyeX.setMinMax(75,100)
i01.head.eyeX.setRest(78)
i01.head.neck.setRest(80)
i01.head.jaw.setMinMax(9,25)
i01.head.mouthControl.setmouth(9,25)
############################################################
i01.head.headTracking.xpid.setPID(10.0,5.0,0.1)
i01.head.headTracking.ypid.setPID(15.0,5.0,0.1)
i01.head.eyesTracking.xpid.setPID(15.0,5.0,0.1)
i01.head.eyesTracking.ypid.setPID(20.0,5.0,0.1)
eyes = i01.getEyesTracking()
eyes.faceDetect()
sleep(3)
i01.getHead().getArduino().setSampleRate(8000)
i01.getHead().getArduino().digitalDebounceOn(10000)
#start polling data from the digital pin
i01.getHead().getArduino().digitalReadPollingStart(readDigitalPin)
#add python as listener of the arduino service, each time arduino publish the value of the pin
i01.getHead().getArduino().addListener("publishPin", "python", "publishPin")
#define a function which is called every time arduino publish the value of the pin
def publishPin():
pin = msg_i01_getHead_getArduino_publishPin.data[0]
print pin.pin, pin.value,pin.type,pin.source
#if an HIGH state is read, PIR is detecting something so start face tracking
if (pin.value == 1):
if i01.getHead().getHeadTracking().isIdle():
i01.getHead().getHeadTracking().faceDetect()
i01.getHead().getEyesTracking().faceDetect()
#i01.getHead().getArduino().digitalDebounceOn(10000)
#if a LOW state is read , stop tracking.. there is no human there !
elif (pin.value == 0):
if not i01.getHead().getHeadTracking().isIdle():
i01.getHead().getHeadTracking().stopTracking()
i01.getHead().getEyesTracking().stopTracking()
#i01.head.mouthControl.mouth.setGoogleURI("http://tts-api.com/tts.mp3?q=")
i01.head.mouthControl.mouth.setGoogleURI("http://tts-api.com/tts.mp3?q=")
ear = runtime.createAndStart("ear","Sphinx")
ear.attach(i01.head.mouthControl.mouth)
ear.addCommand("attach head", "i01.head", "attach")
ear.addCommand("disconnect head", "i01.head", "detach")
ear.addCommand("search humans", "i01.head.headTracking", "findFace")
ear.addCommand("stop searching", "i01.head.headTracking", "stopScan")
ear.addCommand("rest", "i01.head", "rest")
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")
# all commands MUST be before startListening
ear.startListening()
PIR sensor
What PIR sensor are you using? I haven't got InMoov 2.0 working yet, will this work with1695?
Hi Bob, I use this PIR sensor
Hi Bob,
I use this PIR sensor , it is Borsaci that recomended that one. But for now I haven't been able to use correctly, although I did get some results.
Hopefully with the corrected script by Grog it will work.
This one is Syntactically correct in InMoov 2.0
Here's a short script - where
Here's a short script - where you can see what's happening -
The numbers in order mean - the pin number = 28, its value = 1, its type = 1 (which is digital) & its source is i0.left = name of the Arduino it came from.
The recent version of MRLComm.ino has the capability of sending a value to the debounce delay. Debouncing is ignoring signal change until a certain time after the initial trigger. In the example the debouce delay was set to 10,000 ms or 10 seconds. The sample rate is the fractional rate at which the pin is read. Currently the lower the value, the higher the rate :P