Stuck with MouthControl

I'm writing a service based on InMoov and I'm a little stuck with MouthControl.

An Arduino and jaw Servo get created in InMoovHead. But then when MouthControl starts it too creates an Arduino on the same port and creates a jaw servo.

Could someone help explain how this works please? I can't get the jaw to move Myrobotlab complains the "jaw" does not exist.

Andrew

GroG's picture

Hi rekabuk, I'd recommend

Hi rekabuk, I'd recommend sending a noWorky as I mentioned in your last post.  
Within the InMoov service, several service share the same Arduino.

rekabuk's picture

NoWorky submitted

Thanks GroG,

I'm not quite sure how to connect the jaw, I have found a couple of different ways - there was also some chatter about min/max not working, I guess that is fixed :0)

 

     {
    mouthControl = (MouthControl) Runtime.start("mouthControl", "MouthControl");
     // OLD WAY
     //mouthControl.jaw.setPin(26);
     //mouthControl.arduino.connect(port);
     // NEW WAY
     mouthControl.arduino.servoAttach(mouthControl.jaw, 3);
     arduinos.put(port, mouthControl.arduino);
     String p = mouthControl.getArduino().getSerial().getPortName();
     if (p != null) {
       arduinos.put(p, mouthControl.arduino);
     }
     mouthControl.setmouth(130, 80);
 
Happy New Year
Rekabuk
rekabuk's picture

A little more progress

Another check of my code and I noticed an error, my code is now...

          mouthControl = (MouthControl) Runtime.start("mouthControl", "MouthControl");
          mouthControl.arduino.connect(port);
          mouthControl.jaw.attach(mouthControl.arduino, 3);
          arduinos.put(port, mouthControl.arduino);
         
          String p = mouthControl.getArduino().getSerial().getPortName();
          if (p != null) {
            arduinos.put(p, mouthControl.arduino);
          }
          mouthControl.setmouth(130, 80); // Closed,Open
 

This seemes to run, but there are two problems;

1. When the bot speaks, the jaw does not move

2. It doesn't matter which way round I enter the Closed/Open parameters, the jaw always goes to the "open" position, (my mouth works the oposite way round to a standard InMoov mouth).

Rekabuk

rekabuk's picture

Another issue is...

Another issue is that, once everything has started my jaw servo chatters and seems to be drawing 2A :0(

I could remove MouthControl, but my 4yr old is not happy "Eric" is speaking to him without moving his mouth :0(

Rekabuk

rekabuk's picture

On the plus side

On the plus side - I have added a brain (ProgramAB) and WebkitSpeechRecognition into my new serivce and my bot is now talking to me again :0)

But whenever I start MouthControl the jaw servo starts drawing far too much current :0(

rekabuk's picture

Bad servo - Why?

I had to replace my jaw servo, because even without MouthControl, it was still drawing 2A.

My new servo works well, if I just run the Jaw servo. If I run MouthControl it seems to open the mouth too far - well past the limit set by setMouth() - maybe this is what burnt my servo?

Has anyone else had similar issues?

Any advice greatly received..... :0)

rekabuk's picture

I'm thinking about moving the

I'm thinking about moving the "clever" bit of MouthControl into my head class so that the jaw servo is local, I then just need to subscribe to the mouth start and end speaking functions, which I think I can do???? :0|

My problem could be (and probably is) that I don't understand enough about Java...

In MouthControl when it creates a "peer" service, i.e. createPeer("mouth"), does the text string "mouth" have to match the mouth in the super class? does it create a local copy to the super class? and likewise the "jaw" and "arduino"? Maybe I am using different names which is why I am having trouble?

Sorry if that is *SO* obvious to everyone else - like I say I'm playing in the dark a bit :0)

Rekabuk

rekabuk's picture

YES YESY YES

Having moved the jaw movement code and fighting some statc vs non-static functions (I wish I understood this) Eric's jaw now moves as he speaks and it looks quite good - I'm using mats' head (not literally) and jaw which is non-standard InMoov and has been a learning experience!

Also had a few issues with servo.setSpeed and setVelocity - wasn't sure which to use - documentation was a little vauge/missing (I couldn't find it)?? :0)

Now to fix the aiml and gestures, thanks for your help.

Rekabuk