|
Joystick control of servos Riley [7 posts] |
13 year
|
I am very new to RoboRealm and am really loving it.
I am controlling a mini maestro 12 servo controller and am wondering if anyone has put together a tutorial to precisely control a servo with joystick mapping (RC remote style)?
I am using a Logitech attack 3 joystick which RR interfaces with seamlessly.
The whole code/mapping thing seems to be kicking my behind.
Any direction for begginers would be greatly appreciated.
Thank You!
-Riley
|
|
|
Anonymous |
13 year
|
Riley,
The issue in mapping is just converting from one range of number to another. For your specific example the joystick values will range from -1000 to 1000 whilst the servo controller needs values from 500 to 2500. So we'd like to convert the entire joystick range of 2000 to the servo controller range of also 2000. So as we don't need to change the range (they are both the same for the Maestro) we just need to tweak the joystick value by adding to it.
So if we take -1000 and add 1500 to it that makes it 500. Similar if we take 1000 and add 1500 to it it becomes 2500 which is the range we need. So the forumla is simply
servo_value = joystick_value + 1500
but we need to pick one axis (i.e. servo) at a time so you formula will look more like
servo_1_value = joy_x + 1500
if you have placed the joy_x in the x axis of the joystick and selected servo_1_value in the servo channel dropdown.
Now that we know the formula we need some way of actually performing that calculation. We can use either the Set_variable or one of the scripting languages (VB, Phython) to do this. For VB, add in the VBScript module between the joystick and Maestro module and type in
SetVariable "servo_1_value", GetVariable("joy_x") + 1500
which will create our needed servo_1_value from the joy_x value simply by adding 1500.
Make sense?
STeven.
|
|
|
Riley [7 posts] |
13 year
|
Thanks STeven,
I was using Info from a post in the forums and was changing the values of my joystick from 1000 to 255 (needless to say that doesn't work). I wasn't paying attention to the value perameters of my servo controller (duh).
Once I saw your reply, I have to admit I was a little ashamed that I wasn't paying closer attention.
Needles to say, Thanks for the great software and thanks for the excellent support.
I'll try to be good and not bother you for at least a few days (maybe).
-Riley
|
|