In Python we get to call Java Service methods directly (Yay!) ...

But the going the other way, when a Java service wan'ts to call a Python method - the method was always a bit convoluted.

First there was only the "input()" method..
and all Java could only call this one method on a Python script :(

def input():

Then this was enhanced so that at least the method name could be something besides "input", but the parameters were a challenge to get with convoluted array structure.  E.g.

def heard():
    data = msg_i01_ear_recognized.data[0]
 

BUT NOW !...  boys and girls, ladies & gentlemen .. We have real function names with REAL Parameters.
So , the previous example will now be 

def heard(words):
    print words
 

YAY ! - bigger better stronger faster .. (and now with parameters!) :)

mehtaatur

10 years 4 months ago

This is Awsome Grog!

In my starting days I always had doubts how a java service called python but slowly learned seeing the examples. This answers many of my questions and now the function calls are more easier... Yipee!!!

Will I have to make changes in my old script? or will that work fine?

Regarding the documentation of services, Is there a page which describes a list of functions which python can call and use for that service? It would be much easier to read that and use the functions available instead of checking out example codes when you use a service for the first time.

If any such page dosent exist then I guess you could initiate it and we all could add in our examples and list of fuctions whcih we use in a given service, slowly this would give us an exhaustive documentation of every service.

P.S. I am sorry if such a thing already existed for each service of MRL ( I guess I didnt search proerly then) cheeky

bhouston

10 years 4 months ago

I changed the;

def heard():

      data = msg_i01_ear_recognized.data[0]

     ( i commented it )

to;

def heard(words);

      print words

and then all of my commands after "if (data == "command"):

Now it prints the word (i can see that in the python tab) but it doesn't recognize it.

What am I missing or is there something wrong with the program?

Doesn't recognize it? - Speech must have recognized it .. otherwise it wouldn't have printed ?

Hmmm .. little confused by that statement - give a description of how you "expect it to work" - then send a noWorky !

bhouston

10 years 4 months ago

I sent you a no worky,

on line 246 I have all of my def heard scripts, so when I say for example, "want to play a game" it should say "sure I like games" and when I say "rock paper scissors" it should say "ready " and them do the script.

I have tried it the way I've always had it prior to 1.0.36 and then the way you describe in this post, neither way works. The No Worky I sent you was before I made any changes.

 

bhouston

10 years 4 months ago

This is working now. I put in the following;

def heard(data);

       if (data == "command"):

All good now.