Hello,
Killerstinck is having problems with a script, he wants to close the hand a finger at a time, but there is a problem of (not sleeping long enough ?) and one of the servos appears to run in reverse ?

 

below is the script running

#file : InMoov3.minimal.py

# this will run with versions of MRL above 1695
# a very minimal script for InMoov
# although this script is very short you can still
# do voice control of a right hand or finger box
# It uses WebkitSpeechRecognition, so you need to use Chrome as your default browser for this script to work

# Start the webgui service without starting the browser
webgui = Runtime.create("WebGui","WebGui")
webgui.autoStartBrowser(False)
webgui.startService()
# Then start the browsers and show the WebkitSpeechRecognition service named i01.ear
webgui.startBrowser("http://localhost:8888/#/service/i01.ear")

# As an alternative you can use the line below to show all services in the browser. In that case you should comment out all lines above that starts with webgui. 
# webgui = Runtime.createAndStart("webgui","WebGui")

# Change to the port that you use
rightPort = "COM4"

#to tweak the default voice
Voice="cmu-slt-hsmm" # Default female for MarySpeech 
#Voice="cmu-bdl" #Male US voice.You need to add the necessary file.jar to myrobotlab.1.0.XXXX/library/jar
#https://github.com/MyRobotLab/pyrobotlab/blob/ff6e2cef4d0642e47ee15e353ef934ac6701e713/home/hairygael/voice-cmu-bdl-5.2.jar
voiceType = Voice
mouth = Runtime.createAndStart("i01.mouth", "MarySpeech")
mouth.setVoice(voiceType)
##############
# starting parts
i01 = Runtime.createAndStart("i01", "InMoov")
i01.startEar()
i01.startMouth()
##############
i01.startRightHand(rightPort)
# tweaking defaults settings of right hand
#i01.rightHand.thumb.setMinMax(55,135)
#i01.rightHand.index.setMinMax(0,160)
#i01.rightHand.majeure.setMinMax(0,140)
#i01.rightHand.ringFinger.setMinMax(48,145)
#i01.rightHand.pinky.setMinMax(45,146)
#i01.rightHand.thumb.map(0,180,55,135)
#i01.rightHand.index.map(0,180,0,160)
#i01.rightHand.majeure.map(0,180,0,140)
#i01.rightHand.ringFinger.map(0,180,48,145)
#i01.rightHand.pinky.map(0,180,45,146)
#################

# verbal commands
ear = i01.ear

ear.addCommand("attach your right hand", "i01.rightHand", "attach")
ear.addCommand("disconnect your right hand", "i01.rightHand", "detach")
ear.addCommand("rest", i01.getName(), "rest")
ear.addCommand("open your hand", "python", "handopen")
ear.addCommand("close your hand", "python", "handclose")
ear.addCommand("capture gesture", ear.getName(), "captureGesture")
ear.addCommand("manual", ear.getName(), "lockOutAllGrammarExcept", "voice control")
ear.addCommand("voice control", ear.getName(), "clearLock")

# Confirmations and Negations are not supported yet in WebkitSpeechRecognition
# So commands will execute immediatley
ear.addComfirmations("yes","correct","yeah","ya")
ear.addNegations("no","wrong","nope","nah")

ear.startListening()


def handopen():
  i01.moveHand("right",0,0,0,0,0)
  i01.mouth.speak("ok I open my hand")

def handclose():
    i01.moveHand("right", 180, 0, 0, 0, 0)
    sleep(1)
    i01.moveHand("right", 180, 180, 0, 0, 0)
    sleep(1)
    i01.moveHand("right", 180, 180, 180, 0, 0)
    sleep(1)
    i01.moveHand("right", 180, 180, 180, 180, 0)
    sleep(1)
    i01.moveHand("right", 180, 180, 180, 180, 180)
    sleep(1)
    i01.mouth.speak("a nice and wide open hand that is")

GroG

4 years 12 months ago

The strangest problem to me seems like the 2 servos run in reverse for a short time?

GroG

4 years 12 months ago

What happens when you move one of the servos which moved in reverse, with the gui ?

kwatters

4 years 12 months ago

Ok.. so looking at the no-worky you sent.  It would apear that the inmoov thought it heard the command  "close your hand" two times in a row.  

I think the result is, that it executes the python method for closehand()  2 times in parallel.  

So, you basically have 2 threads that are both executing the method closehand()..  this is why about 1/2 way through, the hand briefly tries to open up to full open position again before starting to fully close correctly.

 

There may be a bug here that webkitspeech is double-publishing what it hears.  That could cause this issue.  Though, I'm not sure yet.   I've highlighted some key things in the log file that lead me to this conclusion.

 

1.  I see 2 log messages from webkit that recognize "close your hand"

2. I notice the servoMoveToMicroseconds log message that shows how each finger gets set to 0, then 180, and then to 0 and to 180 again.  

 

 

 

12:31:22.798 [New I/O worker #16] WARN c.m.c.ApiFactory [ApiFactory.java:115] msg . --> runtime.getEnvironments() - 1553355082798
12:31:22.799 [New I/O worker #16] INFO c.m.f.Service [WebkitSpeechRecognition.java:68] Recognized : >close your hand<
12:31:22.799 [New I/O worker #16] WARN c.m.c.ApiFactory [ApiFactory.java:115] msg . --> runtime.getEnvironments() - 1553355082799
12:31:22.800 [New I/O worker #16] INFO c.m.f.Service [WebkitSpeechRecognition.java:68] Recognized : >close your hand<
12:31:22.808 [python.input] INFO c.m.f.Service [Arduino.java:1749] servoMoveToMicroseconds servo i01.rightHand.thumb id 1 180.0->2194 us
12:31:22.808 [python.input] INFO c.m.f.Service [Arduino.java:1749] servoMoveToMicroseconds servo i01.rightHand.index id 2 0.0->544 us
12:31:22.811 [python.input] INFO c.m.f.Service [Arduino.java:1749] servoMoveToMicroseconds servo i01.rightHand.majeure id 3 0.0->544 us
12:31:22.815 [python.input] INFO c.m.f.Service [Arduino.java:1749] servoMoveToMicroseconds servo i01.rightHand.ringFinger id 4 0.0->544 us
12:31:22.820 [python.input] INFO c.m.f.Service [Arduino.java:1749] servoMoveToMicroseconds servo i01.rightHand.pinky id 5 0.0->544 us
12:31:23.825 [python.input] INFO c.m.f.Service [Arduino.java:1749] servoMoveToMicroseconds servo i01.rightHand.index id 2 180.0->2400 us
12:31:24.826 [python.input] INFO c.m.f.Service [Arduino.java:1749] servoMoveToMicroseconds servo i01.rightHand.majeure id 3 180.0->2400 us
12:31:25.827 [python.input] INFO c.m.f.Service [Arduino.java:1749] servoMoveToMicroseconds servo i01.rightHand.ringFinger id 4 180.0->2400 us
12:31:26.828 [python.input] INFO c.m.f.Service [Arduino.java:1749] servoMoveToMicroseconds servo i01.rightHand.pinky id 5 180.0->2400 us
12:31:27.828 [python.input] INFO c.m.s.MarySpeech [MarySpeech.java:140] speakInternal Blocking false Text: a nice and wide open hand that is
12:31:27.880 [Thread-19] INFO c.m.s.MarySpeech [MarySpeech.java:246] Starting to speak: a nice and wide open hand that is
12:31:27.880 [python.input] INFO c.m.f.Service [Arduino.java:1749] servoMoveToMicroseconds servo i01.rightHand.index id 2 0.0->544 us
12:31:27.881 [i01.ear] INFO c.m.f.Service [WebkitSpeechRecognition.java:117] Stop listening event seen.
12:31:27.881 [i01.ear] INFO c.m.f.Service [WebkitSpeechRecognition.java:131] micNotListening
12:31:27.881 [python.input] INFO c.m.f.Service [Arduino.java:1749] servoMoveToMicroseconds servo i01.rightHand.majeure id 3 0.0->544 us
12:31:27.887 [python.input] INFO c.m.f.Service [Arduino.java:1749] servoMoveToMicroseconds servo i01.rightHand.ringFinger id 4 0.0->544 us
12:31:27.896 [python.input] INFO c.m.f.Service [Arduino.java:1749] servoMoveToMicroseconds servo i01.rightHand.pinky id 5 0.0->544 us
12:31:27.971 [New I/O worker #16] WARN c.m.c.ApiFactory [ApiFactory.java:115] msg . --> runtime.getEnvironments() - 1553355087971
12:31:27.972 [New I/O worker #16] INFO c.m.f.Service [WebkitSpeechRecognition.java:117] Stop listening event seen.
12:31:27.972 [New I/O worker #16] INFO c.m.f.Service [WebkitSpeechRecognition.java:131] micNotListening
12:31:27.981 [Thread-19] INFO c.m.s.MarySpeech [MarySpeech.java:115] Ok.. here we go.
12:31:28.905 [python.input] INFO c.m.f.Service [Arduino.java:1749] servoMoveToMicroseconds servo i01.rightHand.index id 2 180.0->2400 us
12:31:29.906 [python.input] INFO c.m.f.Service [Arduino.java:1749] servoMoveToMicroseconds servo i01.rightHand.majeure id 3 180.0->2400 us
12:31:30.907 [python.input] INFO c.m.f.Service [Arduino.java:1749] servoMoveToMicroseconds servo i01.rightHand.ringFinger id 4 180.0->2400 us
12:31:31.642 [Thread-19] INFO c.m.s.MarySpeech [MarySpeech.java:253] End speaking: a nice and wide open hand that is
12:31:31.642 [i01.ear] INFO c.m.f.Service [WebkitSpeechRecognition.java:110] Start listening event seen.
12:31:31.646 [New I/O worker #16] WARN c.m.c.ApiFactory [ApiFactory.java:115] msg . --> runtime.getEnvironments() - 1553355091646
12:31:31.907 [python.input] INFO c.m.f.Service [Arduino.java:1749] servoMoveToMicroseconds servo i01.rightHand.pinky id 5 180.0->2400 us
12:31:32.908 [python.input] INFO c.m.s.MarySpeech [MarySpeech.java:140] speakInternal Blocking false Text: a nice and wide open hand that is
12:31:32.944 [Thread-21] INFO c.m.s.MarySpeech [MarySpeech.java:246] Starting to speak: a nice and wide open hand that is
12:31:32.944 [i01.ear] INFO c.m.f.Service [WebkitSpeechRecognition.java:117] Stop listening event seen.
12:31:32.944 [i01.ear] INFO c.m.f.Service [WebkitSpeechRecognition.java:131] micNotListening
12:31:33.026 [New I/O worker #16] WARN c.m.c.ApiFactory [ApiFactory.java:115] msg . --> runtime.getEnvironments() - 1553355093026
12:31:33.026 [New I/O worker #16] INFO c.m.f.Service [WebkitSpeechRecognition.java:117] Stop listening event seen.
12:31:33.026 [New I/O worker #16] INFO c.m.f.Service [WebkitSpeechRecognition.java:131] micNotListening
12:31:33.045 [Thread-21] INFO c.m.s.MarySpeech [MarySpeech.java:115] Ok.. here we go.
12:31:36.704 [Thread-21] INFO c.m.s.MarySpeech [MarySpeech.java:253] End speaking: a nice and wide open hand that is
12:31:36.704 [i01.ear] INFO c.m.f.Service [WebkitSpeechRecognition.java:110] Start listening event seen.

Killerstinck

4 years 12 months ago

In reply to by kwatters

I understand perfectly, I just lack knowledge for such repair, I also noticed it in the LOG, attention to open the hand it does too

kwatters

4 years 12 months ago

In reply to by Killerstinck

At a glance,  I'm not seeing, in the logs, anything that would explain the double publishing of the recognized text "close hand"...

Is it possible that you ran the minimal scripts 2 times ?  Perhaps running the script more than once will cause webkit to be subscribed to 2 times.. hence the publishing twice..    This is just a guess..

I would recommend trying out the "latest"..   and let us know if it's still hapening in the pre-nixie release.

I see this is adding commands with ear.addCommand AND using InMoov ... I don't have experience with all the auto-gesture InMoov files stuff, but I suspect perhaps maybe its double posting because InMoov is trying to do it and so is your raw ear.addCommand entries in your script ..

Just a guess

hairygael

4 years 11 months ago

Hello,

I wonder if your breedboard can supply enough amps for all the servos which are all powered at once.

The script you are using is adapted to a older version of MRL, and was not very safe because it doesn't disable the servos after usage.

Try with this, it should be better:

def handclose():
    i01.rightHand.thumb.moveTo(180)
    sleep(0.5)
    i01.rightHand.index.moveTo(180)
    sleep(0.5)
    i01.rightHand.majeure.moveTo(180)
    sleep(0.5)
    i01.rightHand.ringFinger.moveTo(180)
    sleep(0.5)
    i01.rightHand.pinky.moveTo(180)
    sleep(0.5)
    i01.mouth.speak("a nice and closed hand that is")