PC Based Robosapien Controller

Related posts:

Robosapien Rocks! - Robosapien under computer control

Progress With A Robosapien Control Application

Robosapien Choreography Program - Some Thoughts

Sometimes you just get lucky. There doesn't seem to be any other reasonable explanation for it. Just luck - plain and simple.

I had pretty much given up on doing a full remote control application - primarily because I had visions of trying to write and debug the code necessary to handle the 62+ Robosapien functions. I just knew that at some point - probably around the 20th button or so, I would either get totally frustrated, or extremely bored. The result would be yet another interesting software project that wound up on the shelf gathering dust.

Still, I needed a simple test program to send IR codes from my PC USBUIRT interface to my Robosapien. I had the basic code transmission worked out using Girder, so I knew that part was working. My short term goal was to get a choreography program up and running using Visual Basic 6.0. I chose VB for several reasons-

  • I've used VB for years, and know it fairly well [I'm basically lazy]
  • I already have the VB development environment setup on my primary systems. [I'm basically cheap]
  • The design and syntax should be close enough so that other people can port it to the language of their own choice.

I seriously considered other language development environments, but the thought of having spend the $$$ for another development platform and to learn yet another programming language quickly discouraged me from going down that path.

I started off by just putting a couple of command buttons on a form, and labeling them with Robosapien IR code command names. I wrote some code to read a modified version of the Girder Robosapien commands and codes, and store them in a series of arrays. Then I thought it would be cute to have a picture of the robot on the form..., then I added a few more buttons..., and a few more...

By the time I got to the sixth or seventh command button I could tell that this approach wasn't going to be very practical. So, I started to think about alternative ways to skin this cat. It turns out that every time you cut and paste a command object, VB tells you that you already have one with the same name, and asks if you want to create an array. Suddenly the mental light bulb went on in my head, and within a couple of minutes I had populated the entire form with enough buttons to handle all the existing codes plus a number of empty buttons set aside to use with my special choreography commands.

The next step was to sort the command buttons into groups of similar functions, and place them in some sort of logical, easy to use, order on the form. I'm sure that after I use it for a while I will want to change some of the layout, but for now, this is what it looks like-

050224-robocontrol-01

Taking a closer look at the form layout, you can see that each command button has a sequentially numbered caption. All of the buttons on this form, with the sole exception of the one labeled 'Refresh', are elements in a single command control array. I also added some status boxes at the bottom of the form to display the current command, which group it belongs to, the function it performs, and the actual USBUIRT IR code to be transmitted. These will probably be replaced later with just some simple indicators.

050224-robocontrol-01

When the program first runs, it opens a text file containing the list of groups, commands, functions, and codes then stores them in string arrays. The command array is then used to update the captions and ToolTipText on each of the buttons. Later, if I need to change any of the captions or commands it can be done by editing the text file without having to rebuild or recode the application.

Private Sub Titles_Click()
'
' Sets the caption for each command button to
' match the command in the indexed array.
'
  For i = 0 To 64
    Cmd(i).Caption = cmdarray(i)
    Cmd(i).ToolTipText = functionarray(i)
  Next i
 
End Sub

The coding that handles the button clicks is extremely simple and straight forward. The button click generates a corresponding Index which is used as a pointer to the correct elements in the arrays.

Private Sub Cmd_Click(Index As Integer)
'
' Updates the display and selects the appropriate IR code
' whenever a command button is clicked
'
' Used for all of the individual command buttons as
' a command array. The array index determines which button
' was clicked

Group.Caption = grouparray(Index)
Command.Caption = cmdarray(Index)
Function1.Caption = functionarray(Index)
Code.Caption = codearray(Index)

'
' add call to USBUIRT transmit routine

End Sub

The result is a clean, hopefully easy to understand and use, layout that can be modified and expanded with a minimum of effort as time goes on.

050224-robocontrol-03

Just to make it look a little more professional, I added an About page, and a browser page that automatically links to my robotics website.

050224-robocontrol-01

Next steps:

  • Incorporate the already tested USBUIRT code
  • Add command timing (time that the Robosapien actually takes to execute each command)
  • Draft a specification for additional functionality including -
      1. Command strings
      2. Elapsed time
      3. Graphical time line
      4. Programmable delays
      5. Variable command repeats
      6. Subroutines

You might also enjoy:

  1. Robosapien Rocks! – Robosapien under computer control
  2. Progress With A Robosapien Control Application
  3. Robosapien Choreography Program – Some Thoughts
  4. Robosapien USBUIRT IR Control Codes
  5. Robosapien in Japan – Good News/Bad News
Share and Enjoy:
  • Facebook
  • Twitter
  • Reddit
  • email
  • LinkedIn
  • Slashdot
  • StumbleUpon
  • Google Bookmarks
  • Digg
  • del.icio.us

Leave a Reply