loading
 
Keyboard Issues - Using RR
Les Fortner from United States  [15 posts]
9 years
First Off, thanks for everyone in the RR Forum, and a great thanks for STeven, and the folks there at RR!

I am not a programmer, by any means, but have spent some time just trying to debug this problem, I have used the built in interface, and written just crap loads of test programs, but I can not seem to figure out the keyboard interface.. You have made everything so easy to use, but my scripting sucks, or something else is wrong... My script works well, for the movement of my camera, and the movement also works with the x-box controller that I have using the supplied code, but nothing comes together when I use the keyboard module... Forgive me for my ignorance, I am sure that others have had, or will have this issue... Since the RR keyboard issue that I am having, is more than likely not at all related to the RR software, I post my rather lengthy script here, and if it is possible, tell me what I am doing terribly wrong...

Thanks in Advance!!!!

Your software is truly amazing!

' WILLOW OPERATING SYSTEM VERSION 1.0
' FOR USE IN ROBOREALM ENVIROMENT
'
'___________________________________________________




' VARIABLE DESCRIPTIONS
'___________________________________________________
' M1 = RIGHT DRIVE MOTOR
' M2  = LEFT DRIVE MOTOR
' RIGHTMTRPWRFOR = RIGHT MOTOR POWER FORWARD
' RIGHTMTRPWRBAC = RIGHT MOTOR POWER BACKWARD
' LEFTMTRPWRFOR = LEFT MOTOR POWER FORWARD
' LEFTMTRPWRBAC = LEFT MOTOR POWER BACKWARD
' TRIG = D-PAD READING
' MOVE = LOGITECH ORBIT MOVEMENT
' KEY = KEYBOARD READING

'
'

'___________________________________________________
' DECLARED VARIABLES

Dim M1
Dim M2
Dim RIGHTMTRPWRFOR
Dim RIGHTMTRPWRBAC
Dim LEFTMTRPWRFOR
Dim LEFTMTRPWRBAC
Dim TRIG
Dim MOVE
Dim KEY


'
'___________________________________________________
' SET INITIAL DRIVE POWER LEVELS

RIGHTMTRPWRFOR = 151
RIGHTMTRPWRBAC = 104
LEFTMTRPWRFOR = 153
LEFTMTRPWRBAC = 102

'
'___________________________________________________
' GET KEYSTROKE & ASSIGN DRIVE POWER VALUES

'POWER LEVEL 1

If GetVariable("KEY") = 1 then Setvariable "RIGHTMTRPWRFOR", 151
If GetVariable("KEY") = 1 then Setvariable "RIGHTMTRPWRBAC", 104
If GetVariable("KEY") = 1 then Setvariable "LEFTMTRPWRFOR", 153
If GetVariable("KEY") = 1 then Setvariable "LEFTMTRPWRBAC", 102

'POWER LEVEL 2

If GetVariable("KEY") = 2 then Setvariable "RIGHTMTRPWRFOR", 175
If GetVariable("KEY") = 2 then Setvariable "RIGHTMTRPWRBAC", 80
If GetVariable("KEY") = 2 then Setvariable "LEFTMTRPWRFOR", 177
If GetVariable("KEY") = 2 then Setvariable "LEFTMTRPWRBAC", 78

'POWERLEVEL 3

If GetVariable("KEY") = 3 then Setvariable "RIGHTMTRPWRFOR", 199
If GetVariable("KEY") = 3 then Setvariable "RIGHTMTRPWRBAC", 56
If GetVariable("KEY") = 3 then Setvariable "LEFTMTRPWRFOR", 201
If GetVariable("KEY") = 3 then Setvariable "LEFTMTRPWRBAC", 54

'POWERLEVEL 4

If GetVariable("KEY") = 4 then Setvariable "RIGHTMTRPWRFOR", 223
If GetVariable("KEY") = 4 then Setvariable "RIGHTMTRPWRBAC", 32
If GetVariable("KEY") = 4 then Setvariable "LEFTMTRPWRFOR", 225
If GetVariable("KEY") = 4 then Setvariable "LEFTMTRPWRBAC", 30




'
'___________________________________________________
' KEYBOARD DRIVE SECTION

If GetVariable("KEY") = "w" then SetVariable "M1", RIGHTMTRPWRFOR
If GetVariable("KEY") = "w" then SetVariable "M2", LEFTMTRPWRFOR
If GetVariable("KEY") = "z" then SetVariable "M1", RIGHTMTRPWRBAC
If GetVariable("KEY") = "z" then SetVariable "M2", LEFTMTRPWRBAC
If GetVariable("KEY") = "a" then SetVariable "M1", RIGHTMTRPWRFOR
If GetVariable("KEY") = "a" then SetVariable "M2", LEFTMTRPWRBAC
If GetVariable("KEY") = "s" then SetVariable "M1", RIGHTMTRPWRBAC
If GetVariable("KEY") = "s" then SetVariable "M2", LEFTMTRPWRFOR




'___________________________________________________
' JOYSTICK DRIVE SECTION

If GetVariable("JOY_Y") = 1000 then SetVariable "M1", RIGHTMTRPWRBAC
If GetVariable("JOY_Y") = 1000 then SetVariable"M2" , LEFTMTRPWRBAC
If GetVariable("JOY_Y")= -1000 then SetVariable "M1", RIGHTMTRPWRFOR
If GetVariable("JOY_Y")= -1000 then SetVariable "M2", LEFTMTRPWRFOR

If GetVariable("JOY_Y")  > -999 then if GetVariable("JOY_Y") < 999  then SetVariable"M1" , 128
If GetVariable("JOY_Y")  > -999 then if GetVariable("JOY_Y") < 999  then SetVariable"M2" , 128

If GetVariable("JOY_X") = 1000 then SetVariable "M1", RIGHTMTRPWRFOR
If GetVariable("JOY_X")= -1000 then SetVariable "M2", LEFTMTRPWRFOR
If GetVariable("JOY_X") = 1000 then SetVariable "M2", LEFTMTRPWRBAC
If GetVariable("JOY_X")= -1000 then SetVariable "M1", RIGHTMTRPWRBAC




'
'____________________________________________________
' LOGITECH CAMERA D-PAD MOVING SECTION

MOVE = 0
TRIG = Getvariable("TRIG")

If TRIG =  9000 then MOVE = MOVE OR 8
If TRIG = 27000 then MOVE = MOVE OR 4
If trig = 18000 then MOVE = MOVE OR 2
If trig = 0 then MOVE = MOVE OR 1

SetVariable "MOVE", MOVE


Anonymous 9 years
Les,

Your script seems correct. Perhaps the keyboard module is not configured correctly. Can you include that in a robofile so that we can check how you have it configured?

Thanks,
STeven.
Les Fortner from United States  [15 posts] 9 years
Sure STeven, here you go, take a look...It may definately be a problem with the way everything is configured... Sometimes the M1 & M2 Variables just completely disappear, no value, no string.... Just vanish... It is kind of baffeling. Obviosly, I am wanting to control the motors (M1 & M2) with 4 variable speed settings (right and left motor power) using keystrokes, but also have the xbox remote functional as well. the orbit camera move seems to function great, the rest of it does not seem to fare as well!

program.robo
Anonymous 9 years
We've included a revamped VBScript file. The biggest issue turned out to be the usage of GetVariable on the keyboard key. The key is actually a string of one character long and not an integer. GetVariable expects an integer whereas GetStrVariable will get the full string back. Changing this and cleaning up parts of the file seems to make this work as needed. Try using this VBScript file and see if you get better results.

STeven.

'___________________________________________________
' WILLOW OPERATING SYSTEM VERSION 1.0
' FOR USE IN ROBOREALM ENVIROMENT
'
'___________________________________________________

' VARIABLE DESCRIPTIONS
'___________________________________________________
' M1 = RIGHT DRIVE MOTOR
' M2  = LEFT DRIVE MOTOR
' RIGHTMTRPWRFOR = RIGHT MOTOR POWER FORWARD
' RIGHTMTRPWRBAC = RIGHT MOTOR POWER BACKWARD
' LEFTMTRPWRFOR = LEFT MOTOR POWER FORWARD
' LEFTMTRPWRBAC = LEFT MOTOR POWER BACKWARD
' TRIG = D-PAD READING
' MOVE = LOGITECH ORBIT MOVEMENT
' KEY = KEYBOARD READING

'___________________________________________________
' DECLARED VARIABLES

Dim M1
Dim M2
Dim RIGHTMTRPWRFOR
Dim RIGHTMTRPWRBAC
Dim LEFTMTRPWRFOR
Dim LEFTMTRPWRBAC
Dim TRIG
Dim MOVE
Dim KEY

'___________________________________________________
' SET INITIAL DRIVE POWER LEVELS

' reload speed values from past settings
RIGHTMTRPWRFOR = GetVariable("RIGHTMTRPWRFOR")
RIGHTMTRPWRBAC = GetVariable("RIGHTMTRPWRBAC")
LEFTMTRPWRFOR = GetVariable("LEFTMTRPWRFOR")
LEFTMTRPWRBAC = GetVariable("LEFTMTRPWRBAC")

' but if they have never been set ensure they
' have reasonable default values
if RIGHTMTRPWRFOR = 0 then
  RIGHTMTRPWRFOR = 151
  RIGHTMTRPWRBAC = 104
  LEFTMTRPWRFOR = 153
  LEFTMTRPWRBAC = 102
end if

'___________________________________________________
' GET KEYSTROKE & ASSIGN DRIVE POWER VALUES

'POWER LEVEL 1

KEY = GetStrVariable("KEY")

write Key

If KEY <> "" then

  ' determine if we have a new speed setting
  If KEY = "1" then
    RIGHTMTRPWRFOR = 151
    RIGHTMTRPWRBAC = 104
    LEFTMTRPWRFOR = 153
    LEFTMTRPWRBAC = 102
  End If

  'POWER LEVEL 2

  If KEY = "2" then
    RIGHTMTRPWRFOR = 175
    RIGHTMTRPWRBAC = 80
    LEFTMTRPWRFOR = 177
    LEFTMTRPWRBAC = 78
  End If

  'POWERLEVEL 3

  If KEY = "3" then
    RIGHTMTRPWRFOR = 199
    RIGHTMTRPWRBAC = 56
    LEFTMTRPWRFOR = 201
    LEFTMTRPWRBAC = 54
  End If

  'POWERLEVEL 4

  If KEY = "4" then
    RIGHTMTRPWRFOR = 223
    RIGHTMTRPWRBAC = 32
    LEFTMTRPWRFOR = 225
    LEFTMTRPWRBAC = 30
  End If

  ' and don't forget to save them for next time use
  If KEY = "1" or KEY = "2" or KEY = "3" or KEY = "4" then
    SetVariable "RIGHTMTRPWRFOR", RIGHTMTRPWRFOR
    SetVariable "RIGHTMTRPWRBAC", RIGHTMTRPWRBAC
    SetVariable "LEFTMTRPWRFOR", LEFTMTRPWRFOR
    SetVariable "LEFTMTRPWRBAC", LEFTMTRPWRBAC
  end if

  '
  '___________________________________________________
  ' KEYBOARD DRIVE SECTION

  If KEY = "w" then
    SetVariable "M1", RIGHTMTRPWRFOR
    SetVariable "M2", LEFTMTRPWRFOR
  End If
  
  If KEY = "z" then
    SetVariable "M1", RIGHTMTRPWRBAC
    SetVariable "M2", LEFTMTRPWRBAC
  End If
  
  If KEY = "a" then
    SetVariable "M1", RIGHTMTRPWRFOR
    SetVariable "M2", LEFTMTRPWRBAC
  End If
  
  If KEY = "s" then
    SetVariable "M1", RIGHTMTRPWRBAC
    SetVariable "M2", LEFTMTRPWRFOR
  End If

end if

'___________________________________________________
' JOYSTICK DRIVE SECTION

JOY_Y = GetVariable("JOY_Y")
JOY_X = GetVariable("JOY_X")

if JOY_Y <> 0 or JOY_X <> 0 then

  If JOY_Y = 1000 then
    SetVariable "M1", RIGHTMTRPWRBAC
    SetVariable"M2" , LEFTMTRPWRBAC
  End If
  
  If JOY_Y= -1000 then
    SetVariable "M1", RIGHTMTRPWRFOR
    SetVariable "M2", LEFTMTRPWRFOR
  End If

  If JOY_Y  > -999 and JOY_Y < 999  then
    SetVariable"M1" , 128
    SetVariable"M2" , 128
  End If

  If JOY_X = 1000 then
    SetVariable "M1", RIGHTMTRPWRFOR
    SetVariable "M2", LEFTMTRPWRFOR
  End If
  
  If JOY_X = 1000 then
    SetVariable "M2", LEFTMTRPWRBAC
    SetVariable "M1", RIGHTMTRPWRBAC
  End If

end if

'
'____________________________________________________
' LOGITECH CAMERA D-PAD MOVING SECTION

MOVE = 0
TRIG = Getvariable("TRIG")

If TRIG =  9000 then MOVE = MOVE OR 8
If TRIG = 27000 then MOVE = MOVE OR 4
If trig = 18000 then MOVE = MOVE OR 2
If trig = 0 then MOVE = MOVE OR 1

SetVariable "MOVE", MOVE
Les Fortner from United States  [15 posts] 9 years
STeven,

  Thanks so much for the major script upgrade, but I still have the same issue, that the joystick functions, but the keyboard still does not, however the WRITE command is working properly, and displaying the correct keystroke in the interface area of the script, but the M1 & M2 variables stay set at 128... I then checked my version of RR and I have 1.8.18.10, so that shouldn't be the problem. So I am still baffled, I do not see any area, where the keyboard value should be lost before arriving at the keyboard drive section of the code. Perhaps I still need to revamp something that I have set in the keyboard module??
Les Fortner from United States  [15 posts] 9 years
STeven,

I forgot to mention, that the numerical values 1-4 are working properly, and changing the power values accordingly... The problem is the one that exist with the letter values. As I said in the previous post, the letters are being displayed from the WRITE command properly.

I really appreciate your hard work, and AWESOME software!
Anonymous 9 years
Les,

We attached the robofile that we used to test this below. Also just try upgrading to the latest version. You have a close one but you never know what changes might have been fixed to make this work. Let me know if this continues not to work.

Note that we left in your VBScript path.

STeven.
program.robo
Les Fortner from United States  [15 posts] 9 years
STeven,

I downloaded this ROBO file, I downloaded the newest version of RR, and used the VBS that you supplied, and the problem persist. The numerals 1-4 work, to adjust power levels, the joystick continues to function, and the d-pad moves the camera, however the drive letters do not change the m1 or m2 variables, so they are still not functioning... The letters continue to show up in the vbs message box from the WATCH command, just no action from them...

Anonymous 9 years
It appears that the joystick system was overwriting the keyboard action. We switched the order and enabled the "clear on release" for the keyboard module. See the new VBScript and attached robofile. Note that you will need to change the VBScript path to your willow.vbs file.

' WILLOW OPERATING SYSTEM VERSION 1.0
' FOR USE IN ROBOREALM ENVIROMENT
'
'___________________________________________________

' VARIABLE DESCRIPTIONS
'___________________________________________________
' M1 = RIGHT DRIVE MOTOR
' M2  = LEFT DRIVE MOTOR
' RIGHTMTRPWRFOR = RIGHT MOTOR POWER FORWARD
' RIGHTMTRPWRBAC = RIGHT MOTOR POWER BACKWARD
' LEFTMTRPWRFOR = LEFT MOTOR POWER FORWARD
' LEFTMTRPWRBAC = LEFT MOTOR POWER BACKWARD
' TRIG = D-PAD READING
' MOVE = LOGITECH ORBIT MOVEMENT
' KEY = KEYBOARD READING

'___________________________________________________
' DECLARED VARIABLES

Dim M1
Dim M2
Dim RIGHTMTRPWRFOR
Dim RIGHTMTRPWRBAC
Dim LEFTMTRPWRFOR
Dim LEFTMTRPWRBAC
Dim TRIG
Dim MOVE
Dim KEY

'___________________________________________________
' SET INITIAL DRIVE POWER LEVELS

' reload speed values from past settings
RIGHTMTRPWRFOR = GetVariable("RIGHTMTRPWRFOR")
RIGHTMTRPWRBAC = GetVariable("RIGHTMTRPWRBAC")
LEFTMTRPWRFOR = GetVariable("LEFTMTRPWRFOR")
LEFTMTRPWRBAC = GetVariable("LEFTMTRPWRBAC")

' but if they have never been set ensure they
' have reasonable default values
if RIGHTMTRPWRFOR = 0 then
  RIGHTMTRPWRFOR = 151
  RIGHTMTRPWRBAC = 104
  LEFTMTRPWRFOR = 153
  LEFTMTRPWRBAC = 102
end if

'___________________________________________________
' JOYSTICK DRIVE SECTION

JOY_Y = GetVariable("JOY_Y")
JOY_X = GetVariable("JOY_X")

if JOY_Y <> 0 or JOY_X <> 0 then

  If JOY_Y = 1000 then
    SetVariable "M1", RIGHTMTRPWRBAC
    SetVariable"M2" , LEFTMTRPWRBAC
  End If
  
  If JOY_Y= -1000 then
    SetVariable "M1", RIGHTMTRPWRFOR
    SetVariable "M2", LEFTMTRPWRFOR
  End If

  If JOY_Y  > -999 and JOY_Y < 999  then
    SetVariable"M1" , 128
    SetVariable"M2" , 128
  End If

  If JOY_X = 1000 then
    SetVariable "M1", RIGHTMTRPWRFOR
    SetVariable "M2", LEFTMTRPWRFOR
  End If
  
  If JOY_X = -1000 then
    SetVariable "M2", LEFTMTRPWRBAC
    SetVariable "M1", RIGHTMTRPWRBAC
  End If

end if

'___________________________________________________
' GET KEYSTROKE & ASSIGN DRIVE POWER VALUES

'POWER LEVEL 1

KEY = GetStrVariable("KEY")

write Key

If KEY <> "" then

  ' determine if we have a new speed setting
  If KEY = "1" then
    RIGHTMTRPWRFOR = 151
    RIGHTMTRPWRBAC = 104
    LEFTMTRPWRFOR = 153
    LEFTMTRPWRBAC = 102
  End If

  'POWER LEVEL 2

  If KEY = "2" then
    RIGHTMTRPWRFOR = 175
    RIGHTMTRPWRBAC = 80
    LEFTMTRPWRFOR = 177
    LEFTMTRPWRBAC = 78
  End If

  'POWERLEVEL 3

  If KEY = "3" then
    RIGHTMTRPWRFOR = 199
    RIGHTMTRPWRBAC = 56
    LEFTMTRPWRFOR = 201
    LEFTMTRPWRBAC = 54
  End If

  'POWERLEVEL 4

  If KEY = "4" then
    RIGHTMTRPWRFOR = 223
    RIGHTMTRPWRBAC = 32
    LEFTMTRPWRFOR = 225
    LEFTMTRPWRBAC = 30
  End If

  ' and don't forget to save them for next time use
  If KEY = "1" or KEY = "2" or KEY = "3" or KEY = "4" then
    SetVariable "RIGHTMTRPWRFOR", RIGHTMTRPWRFOR
    SetVariable "RIGHTMTRPWRBAC", RIGHTMTRPWRBAC
    SetVariable "LEFTMTRPWRFOR", LEFTMTRPWRFOR
    SetVariable "LEFTMTRPWRBAC", LEFTMTRPWRBAC
  end if

  '
  '___________________________________________________
  ' KEYBOARD DRIVE SECTION

  If KEY = "w" then
    SetVariable "M1", RIGHTMTRPWRFOR
    SetVariable "M2", LEFTMTRPWRFOR
  End If
  
  If KEY = "z" then
    SetVariable "M1", RIGHTMTRPWRBAC
    SetVariable "M2", LEFTMTRPWRBAC
  End If
  
  If KEY = "a" then
    SetVariable "M1", RIGHTMTRPWRFOR
    SetVariable "M2", LEFTMTRPWRBAC
  End If
  
  If KEY = "s" then
    SetVariable "M1", RIGHTMTRPWRBAC
    SetVariable "M2", LEFTMTRPWRFOR
  End If

end if

'
'____________________________________________________
' LOGITECH CAMERA D-PAD MOVING SECTION

MOVE = 0
TRIG = Getvariable("TRIG")

If TRIG =  9000 then MOVE = MOVE OR 8
If TRIG = 27000 then MOVE = MOVE OR 4
If trig = 18000 then MOVE = MOVE OR 2
If trig = 0 then MOVE = MOVE OR 1

SetVariable "MOVE", MOVE
program.robo
Les Fortner from United States  [15 posts] 9 years
STeven,

I am sure that you are really getting tired of dealing with this thread, but I appreciate your patience.... :) First off, I am glad that you figured out that there needs to be a hierarchy to the controls, I need to make a note of that for future use. I am glad to say, that the keyboard control is now working!! :) But now, the negative values in the joystick control, are not working. I looked at everything, and it is coded out basically the same as it was in the very first post on this thread, only it looks much better. However, when the JOY_Y or the JOY_X values are a -1000 the M1 and M2 values remain unchanged. I am wondering if the problem is in the <>0 portion of the code. I was starting to change that around there to see if that was indeed the problem, but I have not had any luck, and it was working before in the beginning scripts. If you could just take one last looksee, and see if I am needing to just change out the <> for both the JOY_Y and JOY_X to something else, (It looks to me like it should work the way it is...) or if there is a bigger problem at hand I would be most grateful!

Sorry about all of the difficulties...
Anonymous 9 years
Les,

Sorry ... we didn't mention that you need to download the latest version of RR which should fix the negative value problem ... we noticed that in the last version and made a fix but didn't make a note of it.

STeven.
Les Fortner from United States  [15 posts] 9 years
STeven!!!

  THAT WAS THE TICKET!!! WOO!!!

  Everything seems to be functioning fine now. It may be worth mentioning the Hierarchy of controls in the documentation section of RR, it may be handy for others to know in the future. I really appreciate the help, and maybe we have made RR a little better...

Thanks Guys, your awesome as always!
Anonymous 9 years
That's great! Good to hear its working. Thanks for the reply!

We'll see how we can update the documentation to reflect that control hierarchy.

STeven.

This forum thread has been closed due to inactivity (more than 4 months) or number of replies (more than 50 messages). Please start a New Post and enter a new forum thread with the appropriate title.

 New Post   Forum Index