Hello,

Right now I have it so that if Jython receives a call to "input", it will send a message back to MRLClient.  Is there a way to generate a message in Jython and send it to MRLClient without MRLClient sending a message first?

Thanks.

admin

11 years 10 months ago

Certainly..  

You can do it in global space or in a loop

from org.myrobotlab.service import Logging
from org.myrobotlab.service import RemoteAdapter
from org.myrobotlab.service import Runtime
from org.myrobotlab.framework import Service
from org.myrobotlab.framework import Message
from time import sleep

remote = Runtime.createAndStart("remote","RemoteAdapter")
logger = Runtime.createAndStart("logger","Logging")
jython = Runtime.createAndStart("jython","Jython")

# this will send a single message to the myApp MRLClient
msg = jython.createMessage("myApp","receive", 0.52)
jython.out(msg)

# this will send many
count = 0
while (count < 9):
   msg = jython.createMessage("myApp","receive", 0.52)
   jython.out(msg)
   sleep(0.05)
   count = count + 1

KegFloater

11 years 10 months ago

Hi,

The code you pasted didn't work.  It compiles so it is syntactically correct; however, it just doesn't seem to get executed.  It isn't being sent to the MRL Client.

Any ideas?

Thanks.

admin

11 years 10 months ago

In reply to by KegFloater

1. hopefully your using 14.7 - earlier versions would stop executing any script if a Jython error occurred.

2.  I'm guessing your MRLClient isn't named "myApp" - so the endpoint destination name would need to change.

3. Whenever you start up a new instance of MRL, you have to register the MRLClient.  Otherwise, the new MRL doesn't know about the client.

If it's none of these I might need to look at the logs.

Sed

11 years 9 months ago

And how do I register the MRLClient. All I did was take the project as a default with name myrobotlab and when I ran the Debuger and it runs. I ran the speech samples on Jython. TTS works fine but sphinx is the one making hard to do.

Sed

11 years 9 months ago

Here is the log output:

41268 [gui_outbox_0] INFO  org.myrobotlab.framework.Outbox  - configured to RELAY Jython
41274 [gui_outbox_0] INFO  org.myrobotlab.framework.Outbox  - configured to RELAY Jython
41275 [Jython] INFO  class org.myrobotlab.framework.Service  - invoking Jython.attachJythonConsole(null) 20120623032525872
44608 [Jython_outbox_0] INFO  org.myrobotlab.framework.Outbox  - no static route for Jython.attachJythonConsole
44612 [Jython] INFO  class org.myrobotlab.framework.Service  - invoking Jython.exec(String) 20120623032525875
44745 [Jython] INFO  org.myrobotlab.service.Runtime  - loader for this class sun.misc.Launcher.AppClassLoader
44746 [Jython] INFO  org.myrobotlab.service.Runtime  - parent sun.misc.Launcher.ExtClassLoader
44746 [Jython] INFO  org.myrobotlab.service.Runtime  - system class loader sun.misc.Launcher$AppClassLoader@df6ccd
44748 [Jython] INFO  org.myrobotlab.service.Runtime  - parent should be nullsun.misc.Launcher.ExtClassLoader
44778 [Jython] INFO  org.myrobotlab.service.Runtime  - thread context sun.misc.Launcher.AppClassLoader
44778 [Jython] INFO  org.myrobotlab.service.Runtime  - thread context parent sun.misc.Launcher.ExtClassLoader
44778 [Jython] INFO  org.myrobotlab.service.Runtime  - refreshing classloader
44782 [Jython] WARN  class org.myrobotlab.framework.ConfigurationManager  - file sed-MacBook.ear.properties not found
44787 [Jython] INFO  class org.myrobotlab.net.CommunicationManager  - instanciating a org.myrobotlab.net.CommObjectStreamOverUDP
44791 [Jython] INFO  org.myrobotlab.service.Runtime  - returning org.myrobotlab.service.Sphinx
44845 [Jython] INFO  org.myrobotlab.service.Runtime  - loader for this class sun.misc.Launcher.AppClassLoader
44846 [Jython] INFO  org.myrobotlab.service.Runtime  - parent sun.misc.Launcher.ExtClassLoader
44846 [Jython] INFO  org.myrobotlab.service.Runtime  - system class loader sun.misc.Launcher$AppClassLoader@df6ccd
44846 [Jython] INFO  org.myrobotlab.service.Runtime  - parent should be nullsun.misc.Launcher.ExtClassLoader
44847 [Jython] INFO  org.myrobotlab.service.Runtime  - thread context sun.misc.Launcher.AppClassLoader
44847 [Jython] INFO  org.myrobotlab.service.Runtime  - thread context parent sun.misc.Launcher.ExtClassLoader
44847 [Jython] INFO  org.myrobotlab.service.Runtime  - refreshing classloader
44860 [Jython] WARN  class org.myrobotlab.framework.ConfigurationManager  - file sed-MacBook.mouth.properties not found
44860 [Jython] INFO  class org.myrobotlab.net.CommunicationManager  - instanciating a org.myrobotlab.net.CommObjectStreamOverUDP
44862 [Jython] INFO  org.myrobotlab.service.Speech  - Using voice: audrey
44863 [Jython] INFO  org.myrobotlab.service.Runtime  - returning org.myrobotlab.service.Speech
44891 [Jython] INFO  class org.myrobotlab.framework.Service  - adding notify from earrecognized to Jython.heard
44892 [Jython] INFO  class org.myrobotlab.framework.Service  - adding notify from mouthisSpeaking to Jython.isSpeaking
44906 [Jython] ERROR class org.myrobotlab.framework.Service  - ------
Traceback (most recent call last):
  File "<string>", line 63, in <module>
AttributeError: 'org.myrobotlab.service.Jython' object has no attribute 'console'

    at org.python.core.PyException.fillInStackTrace(PyException.java:70)
    at java.lang.Throwable.<init>(Throwable.java:198)
    at java.lang.Exception.<init>(Exception.java:46)
    at java.lang.RuntimeException.<init>(RuntimeException.java:49)
    at org.python.core.PyException.<init>(PyException.java:46)
    at org.python.core.PyException.<init>(PyException.java:43)
    at org.python.core.PyException.<init>(PyException.java:61)
    at org.python.core.Py.AttributeError(Py.java:166)
    at org.python.core.PyObject.noAttributeError(PyObject.java:930)
    at org.python.core.PyObject.__getattr__(PyObject.java:925)
    at org.python.pycode._pyx2.f$0(<string>:63)
    at org.python.pycode._pyx2.call_function(<string>)
    at org.python.core.PyTableCode.call(PyTableCode.java:165)
    at org.python.core.PyCode.call(PyCode.java:18)
    at org.python.core.Py.runCode(Py.java:1261)
    at org.python.core.Py.exec(Py.java:1305)
    at org.python.util.PythonInterpreter.exec(PythonInterpreter.java:206)
    at org.myrobotlab.service.Jython.exec(Jython.java:154)
    at org.myrobotlab.service.Jython.exec(Jython.java:132)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:616)
    at org.myrobotlab.framework.Service.invoke(Service.java:1169)
    at org.myrobotlab.framework.Service.invoke(Service.java:1107)
    at org.myrobotlab.framework.Service.invoke(Service.java:997)
    at org.myrobotlab.framework.Service.run(Service.java:576)
    at java.lang.Thread.run(Thread.java:679)
------

44911 [gui] INFO  org.myrobotlab.control.ServiceGUI  - buildGraph
44925 [gui] INFO  org.myrobotlab.control.ServiceGUI  - service count 5
44925 [Jython_outbox_0] INFO  org.myrobotlab.framework.Outbox  - no static route for Jython.exec
45275 [gui] INFO  org.myrobotlab.control.ServiceGUI  - buildGraph
45288 [gui] INFO  org.myrobotlab.control.ServiceGUI  - service count 5

Sed

11 years 9 months ago

this are my variables in the Debuger:

                cause:   File Not Found

detailMessege:  .\\.myrobotlab/ear.gram (No such file or directory)

       stackTrace: null