A heartfelt thanks to Grog for MRL and a good morning to you all. 
I just installed and started trying MRL with the following configuration: 
MRL, 
1 Arduino Uno R3, 
Logitech Force 3D Pro Joystick 1, 
1 Servo Hitec HS-5585MH (Programmable Digital Amplifier whit MOSFET Drive 
and this python sketch:
 
from org.myrobotlab.service import Arduino
from org.myrobotlab.service import Servo
from org.myrobotlab.service import Joystick
from org.myrobotlab.service import Runtime
from time import sleep
# create the services
arduino = Runtime.createAndStart("arduino","Arduino")
pan  = Runtime.createAndStart("pan","Servo")
joystick = Runtime.createAndStart("joystick","Joystick")
arduino.connect("COM6", 57600, 8, 1, 0)
sleep(2)
# attach servos to Arduino
pan.attach(arduino.getName(), 9)
# attach joystick to servos
joystick.attach(pan, Joystick.Z_AXIS)
joystick.setController(5);
joystick.startPolling();
 
After starting the sketch, the joystick is detected in the window controller, if I move the slider in the "servo window" the servo moves, but the servo does not move if i want to drive it with the joystick, what am I wrong? Thanks for the reply! Have a nice day! :)

GroG

10 years 2 months ago

Hello And Welcome Frank !

My guess is that the axis is not expected - you can confirm this by opening the myrobotlab.log

if there are a bunch of "unknown axis ..."  errors - then that would be the problem.

Please familiarize yourself with the ubiquitous noWorky, this will send us your myrobotlab.log so we may further assist you. (How to do a noWorky - http://myrobotlab.org/content/helpful-myrobotlab-tips-and-tricks-0#noWorky)

Cheers,
GroG

Grog Good evening, thank you for reply. I gave it a look-see at the log and I do not think there are strange voices like "axis unknown", I also tried to connect an x-box controller, but even this fails to move the servo. 
I did what you said about the noWorky and I sent two log files, do not take into account the first, it is a mistake due to inexperience :) 
Let me know! regards :)

Ok Frank,
Got the log you sent (that part works ;)
It looks strange - huge amount of non-printable characters.. and then I can see the joystick_polling thread overloaded someone's queue..

I'll need to check this out with some "real" hardware - tonight I'll get the joystick connected and see what's going on ...

 

Hello Frank,

with the folloing modified script I can send the data to python, if you convert it to the appropriate range (from -1.0 <--> 1.0  to  0 <---> 180 and change the type to in I believe you can call pan.moveTo(newValue) and it will work for you. 

I haven't looked at the Joystick service for a long time - there are a few modifications which I could do, which  would make the python code more clean.

At the very minimum this script will show you the value of the joystick in the python output tab

from org.myrobotlab.service import Arduino
from org.myrobotlab.service import Servo
from org.myrobotlab.service import Joystick
from org.myrobotlab.service import Runtime
from time import sleep
 
# create the services
arduino = Runtime.createAndStart("arduino","Arduino")
pan  = Runtime.createAndStart("pan","Servo")
joystick = Runtime.createAndStart("joystick","Joystick")
 
# don't need to specify parameters - default will be 57600 8 1 0
arduino.connect("COM15")
# I don't think you need the sleep anymore
#sleep(2)
# attach servos to Arduino
pan.attach(arduino.getName(), 4)
# attach joystick to servos
joystick.attach(pan, Joystick.Z_AXIS)
joystick.setController(2);
joystick.startPolling(); 
 
pan.map(-1.0, 1.0, 0, 180)
 
# added this line to route the data from the joystick to python
# joystick invokes a method named ZAxisRaw which will send data
# to the "python" service into a function called "onZAxis"
joystick.addListener("ZAxisRaw", "python", "onZAxis")
#pan.addListener("ZAxisRaw", "pan", "moveTo")
 
def onZAxis(data):
    print data
 

Grog Hello, I tried the new scketch python, java window shows a series of warning such as "460 336 [joystick_polling] WARN org.myrobotlab.framework.Outbox - joystick outbox BUFFER OVERRUN size 1537", the python window is empty, the slider pan moves the servo in three positions -1, 0, +1, the joystick is detected, but does not move the servo .... Ideas on this? Regards :)