Shop OBEX P1 Docs P2 Docs Learn Events
Joystick contorlled what?? — Parallax Forums

Joystick contorlled what??

KC9RXBKC9RXB Posts: 15
edited 2011-08-14 14:00 in Robotics
Hi all,
I haven't been very active in the robotics scene lately and im looking to get back into it.
i want to build a robot using a laptop, BOE, 2x HB25's, USB joy stick, 2 xbees, etc.
i want to have a visual basic or java program to get data from the joystick and send them via the "flash fly XBEE kit" to the robot to control movement, pan/tilt camera, robotic arm, etc.

Please help!
Miles

Comments

  • tobdectobdec Posts: 267
    edited 2011-08-13 07:19
    This should get u well on your way. You can download it and run it independant of the internet connection too.

    http://myrobotlab.org/
  • Matt GillilandMatt Gilliland Posts: 1,406
    edited 2011-08-13 07:22
    Hello Miles- Welcome to the Forums!

    Sounds like you're looking for some fun!?

    I always think it's best that our Customer/Forumistas here take the lead in advising each other what the best components are for a particular project. Hopefully they recommend our products mostly, but often they don't because another mfr's part may be more well suited to your application.

    That being said, and for the sake of getting the flow of information started, take a look at Madeusa. In fact, here's a thread with some videos on how we make "her" right here in Rocklin, CA.

    So with that, I'll step aside for a bit and let our customers (and long time friends) give you ideas about how to use some of the things we make to accomplish your goals!

    What about it erco? Gordon? Maxwin? Vanmunch? Whit? Phil? Amanda? and all you other Robot Developer Extradonairs (you know who you are) - Speak Up! and help get Miles going!

    -Matt
  • KC9RXBKC9RXB Posts: 15
    edited 2011-08-13 07:35
    Thank you Matt. I think my next purchase from parallax will be the flash fly programming kit with the RS232 adapter, 2 XBEE pro's, ping sensor and all the parts needed to make Madeusa's chassis to start. I all ready own 2 HB25's, a BOE. I really cant wait to back in to robotics on my own. during the school year i am HEAVILY involved with are schools FRC robotics team (#1652), but we use CRIO's programmed in java. and wireless networks to control them.
    Thanks again,
    Miles
  • ratronicratronic Posts: 1,451
    edited 2011-08-13 08:05
    Miles, I have used RobotBasic to interface my laptop and it's usb joystick to my different Parallax robots. It's available free from robotbasic.org This is an example of the RobotBasic program I use on the laptop to read it's usb joystick and send it out a com port with a transmitter interfaced to it.
    'joystick transmitter program "rfbot3" by Dave Ratcliff 'ratronic' 7/17/11
    'for use with rf3.spin
    'use either parallax #27980 transmitter or #27982 transceiver
     
    SetCommPort 8,br9600   'set com port # where transmitter or transceiver hooked to
    loop:
      Joysticke 1,j
      x = round(j[0,0]/257)           
      y = round(j[1,0]/257)
      z = round(j[3,0]/257)
      s = round(j[2,0]/257)
      b = j[6,0]
      cs = (x+y+z+s+b) & 255
      serialout "!~#}",x,y,z,s,b,cs
    goto loop:
    
  • KC9RXBKC9RXB Posts: 15
    edited 2011-08-13 09:57
    Thanks for the idea of "robotbasic" i downloaded it and looked at some of the demo's along with your program and i see that your program is for a prop chip and a parallax RF module but i am looking to use a BS2 and a XBEE with the flash fly kit. is there any way i could interface that somehow?

    Thanks,
    Miles
  • UnsoundcodeUnsoundcode Posts: 1,532
    edited 2011-08-13 13:06
    There is no reason why you should not be able to control your bot wirelessly it is just another form of transmitting and receiving serial data.

    Here are two links you may wish to look at, both contain examples for VB Express. The first discusses a joystick interface and the second discusses various serial routines between a PC and BS2. There should be enough information to help you get started quickly.

    http://forums.parallax.com/showthread.php?111312-Game-Controller-Interface

    http://forums.parallax.com/showthread.php?96973-VB-Express-to-Stamp-Template

    Jeff T.
  • ratronicratronic Posts: 1,451
    edited 2011-08-13 14:18
    @KC9RXB - Yes I use a Propeller Spin program to decipher that, but I posted that RobotBasic example to show how easy it is to grab each axis of the joystick and the buttons convert them to bytes to send out a comport in RS232. You don't have to use my RobotBasic program, you can write one to match with your BS2 program. With the BS2 you might want to send only one axis at a time. Also the program I posted above sends out an 4 character i.d. flag, all of the joystick axis "x,y,z" the slider "s", the buttons "b" and a checksum on the end "cs". You can write your RB program to use whatever flag/s you want. This example sends out the usb joysticks x axis with an i.d. flag of "!". It's been along time since I've used a BS2 and I can't quite remember it's serial capabilties.
    SetCommPort 8,br9600   'set com port # where transmitter or transceiver hooked to
    loop:
      Joysticke 1,j
      x = round(j[0,0]/257)           
      serialout "!",x
    goto loop:
    
  • ratronicratronic Posts: 1,451
    edited 2011-08-14 14:00
    Miles you kind of peeked my curiosity of whether the stamp was able to keep up with joystick values from the computer and it is! I wrote a small joystick receiver demo program for the BS2 that displays checksum verified joystick data on the debug screen and a matching RobotBasic program for the computer. I have never used xbee's before but as long as it is properly setup and interfaced to your computer and your robot you will achieve serial communication. These 2 examples will show the joystick values in RobotBasic and on the debug screen for the BS2. I have implemented error checking with a checksum in both programs, but maybe error checking is already achieved in the xbee's?

    This is really for all the people out there that have the cheaper 9600 baud transmitters and receivers and are using a BS2, but maybe you can use with the xbee's.
    These 2 examples use a computer with a usb joystick and transmit the joystick values to the BS2. Make sure to properly interface your transmitter/receiver to your computer/robot.
    ' {$STAMP BS2}
    ' {$PBASIC 2.5}
    'constants
    rcvpin CON 5   'P5 - pin where receiver(xbee?) attached
    baud   CON 84  '9600baud - 8bit,no parity,true(non-inverted) for bs2
    'variables
    array  VAR Byte(2)   'checksumed variables x,y,b
    array1 VAR Byte(3)   'received variables x,y,b,cs
    i      VAR Nib       'index counter
    'program
    DO                   'execute until LOOP then come back and run again continuously
    GOSUB joystick       'get x axis,y axis,buttons value and checksum from receiver(xbee?)
    DEBUG HOME                                 'home cursor
    DEBUG "X      = ",DEC array(0),"  ",CR     'show x axis array(0)
    DEBUG "Y      = ",DEC array(1),"  ",CR     'show y axis array(1)
    DEBUG "Button = ",DEC array(2),"  ",CR     'show buttons value array(2)
    LOOP
    joystick:    'joystick receiver subroutine
    SERIN rcvpin, baud,[WAIT("!~#}"), array1(0),array1(1),array1(2),array1(3)]  'wait for flag then receive x,y,b, and checksum
    IF (array1(0)+array1(1)+array1(2))&255 = array1(3) THEN GOSUB transfer   'if received checksum matches calculated checksum then transfer array1 to array
    RETURN
    transfer:    'transfer array1 to array
    FOR i = 0 TO 2
    array(i) = array1(i)
    NEXT
    RETURN
    
    'joystick transmitter program "rfbot4" by Dave Ratcliff 'ratronic' 8/14/11
    'can use either parallax #27980 transmitter or #27982 transceiver
    SetCommPort 8,br9600   'set comport#,baudrate where transmitter or transceiver interfaced to
    loop:
      Joysticke 1,j              'get usb joystick info into array j
      x = round(j[0,0]/257)      'get x axis and round to a byte 0-255    
      y = round(j[1,0]/257)      'get y axis and round to a byte 0-255
      b = j[6,0]                 'get buttons value
      cs = (x+y+b) & 255         'calculate checksum
      serialout "!~#}",x,y,b,cs  'send out x,y,b and cs(checksum)
      xystring 0,0,"X Axis   =  ",x,spaces(20)  'display joystick values on computer screen
      xystring 0,40,"Y Axis  =  ",y,spaces(20)
      xystring 0,80,"Buttons =  ",b,spaces(20)
    goto loop:
    
Sign In or Register to comment.