I've been reading up on MRL this weekend, in parcticular the MRL tracking service and the Virtual Arduino:
 
 
I have my Inmoov working well so far with MRL 
 
My setup is Raspberry Pi 3 > I2C > 3 daisy chained AdaFruit PCA9685 servo controllers 
 
I've read the articles and trawled the source code for the MRL tracking service but am facing a challenge getting things worky
 
@Mats, thanks for the heads-up on tracking performance with the Pi 3.
I have ideas to put a beefier, alternative SBC in the InMoov :)
 
 
Here's my Python code so far:
 
xServoPin = 2
yServoPin = 3
 
# start the virtual arduino service
varduino = Runtime.start("varduino","VirtualArduino")
sleep(1)
tracker = Runtime.createAndStart("tracker","Tracking")
sleep(1)
servodriver = Runtime.create("servodriver","Adafruit16CServoDriver")
sleep(1)
 
# "connect" - creates a virtual COM port with 2 ends
# one called "COM6" the other "COM6.UART"
# the virtual arduino connects to the COM6.UART end,
# and an arduino service can connect to the "COM6" end
varduino.connect("COM6")
 
# Runtime.start("webgui","WebGui")
varduino = Runtime.start("varduino","VirtualArduino")
 
# start the Arduino service
arduino = Runtime.start("arduino","Arduino")
# connect it to the emulator
arduino.connect("COM6")
 
servoX = tracker.getX()
servoY = tracker.getY() 
 
servodriver.attach(tracker.arduino)
servodriver.startService()
#servodriver.arduino.connect("COM6")
servodriver.setController("arduino","1","0x40")
 
servoX = tracker.getX()
servoY = tracker.getY() 
 
 
 
When I execute the Python code above, I get the following below:
 
Things break as soon as I try to get a servo object from eth tracker srevice
 
Any advice?
 
 
12:46:01.766 [python.interpreter.3] INFO c.m.f.Service [Arduino.java:468] waited 17 ms for Arduino arduino to say hello
12:46:01.766 [python.interpreter.3] INFO c.m.f.Status [Status.java:83] arduino.serial connected on COM6 responded version 55 ... goodtimes...
12:46:01.782 [python.interpreter.3] ERROR c.m.f.Service [Service.java:2032] python error PyException - null Traceback (most recent call last):
  File "<string>", line 26, in <module>
at org.myrobotlab.service.Tracking.getX(Tracking.java:258)
 
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
 
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
 
at java.lang.reflect.Method.invoke(Unknown Source)
 
 
java.lang.NullPointerException: java.lang.NullPointerException
 
at org.python.core.Py.JavaError(Py.java:546)
at org.python.core.Py.JavaError(Py.java:537)
at org.python.core.PyReflectedFunction.__call__(PyReflectedFunction.java:188)
at org.python.core.PyReflectedFunction.__call__(PyReflectedFunction.java:204)
at org.python.core.PyObject.__call__(PyObject.java:461)
at org.python.core.PyObject.__call__(PyObject.java:465)
at org.python.core.PyMethod.__call__(PyMethod.java:126)
at org.python.pycode._pyx3.f$0(<string>:35)
at org.python.pycode._pyx3.call_function(<string>)
at org.python.core.PyTableCode.call(PyTableCode.java:167)
at org.python.core.PyCode.call(PyCode.java:18)
at org.python.core.Py.runCode(Py.java:1386)
at org.python.core.Py.exec(Py.java:1430)
at org.python.util.PythonInterpreter.exec(PythonInterpreter.java:267)
at org.myrobotlab.service.Python$PIThread.run(Python.java:160)
Caused by: java.lang.NullPointerException
at org.myrobotlab.service.Tracking.getX(Tracking.java:258)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.python.core.PyReflectedFunction.__call__(PyReflectedFunction.java:186)
... 12 more
 
12:46:01.854 [python.interpreter.3] ERROR c.m.l.Logging [Logging.java:19] ------
Traceback (most recent call last):
  File "<string>", line 26, in <module>
at org.myrobotlab.service.Tracking.getX(Tracking.java:258)
 
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
 
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
 
at java.lang.reflect.Method.invoke(Unknown Source)
 
 
java.lang.NullPointerException: java.lang.NullPointerException
 
at org.python.core.Py.JavaError(Py.java:546)
at org.python.core.Py.JavaError(Py.java:537)
at org.python.core.PyReflectedFunction.__call__(PyReflectedFunction.java:188)
at org.python.core.PyReflectedFunction.__call__(PyReflectedFunction.java:204)
at org.python.core.PyObject.__call__(PyObject.java:461)
at org.python.core.PyObject.__call__(PyObject.java:465)
at org.python.core.PyMethod.__call__(PyMethod.java:126)
at org.python.pycode._pyx3.f$0(<string>:35)
at org.python.pycode._pyx3.call_function(<string>)
at org.python.core.PyTableCode.call(PyTableCode.java:167)
at org.python.core.PyCode.call(PyCode.java:18)
at org.python.core.Py.runCode(Py.java:1386)
at org.python.core.Py.exec(Py.java:1430)
at org.python.util.PythonInterpreter.exec(PythonInterpreter.java:267)
at org.myrobotlab.service.Python$PIThread.run(Python.java:160)
Caused by: java.lang.NullPointerException
at org.myrobotlab.service.Tracking.getX(Tracking.java:258)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.python.core.PyReflectedFunction.__call__(PyReflectedFunction.java:186)
... 12 more
------
 

 

Mats

7 years 3 months ago

To get the tracking to work you also need to connect the Arduino ( that I guess that you don't use ) and the servos using

tracking.connect("COM3",1,2)

Then it will connect to the Arduino at port COM3 and start two Servo services using ports 1 and 2

The two servos will be called tracking.x and tracking.y

So if you start and configure them to use the Adafruit16CServoDriver and call the two servos tracking.x and tracking.y, then I think you can get a handle to the servos.

If you use the VirtualArduino, perhaps you can use it without a real Arduino.

/Mats