(Created page with "In the last few tutorials, we verified created a control algorithm project and verified our setup by performing a simple user-defined motion on both the virtual and actual All...")
 
(AHAS Buttons)
Line 14: Line 14:
  
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
 +
...
 
     -- if button is pressed
 
     -- if button is pressed
 
     -- GUIButton(x-pos, y-pos, width, height, "name")
 
     -- GUIButton(x-pos, y-pos, width, height, "name")
Line 23: Line 24:
 
       print("Home button pressed")
 
       print("Home button pressed")
 
     end
 
     end
 +
...
 
</syntaxhighlight >
 
</syntaxhighlight >
  
 
This button
 
This button

Revision as of 15:38, 8 November 2012

In the last few tutorials, we verified created a control algorithm project and verified our setup by performing a simple user-defined motion on both the virtual and actual Allegro Hands. We did all this ignoring the features of Allegro Hand Application Studio (AHAS) as a robust GUI interface for controlling the hand and visualizing certain data.

In this tutorial, we will take advantage of buttons in AHAS and use them to invoke our own algorithms and those supplied along with AHAS in the BHand Library.

AHAS Buttons

In your AHAS bin/controls directory, locate the file ALLEGROHAND1.lua. This is the file that we made in Tutorial 1 which links to out new controller. Copy this file to your Desktop.

Note: Once again, we must copy this file to the desktop for editing then move it back to the controls folder when we are finished.

From the Desktop, let's open up ALLEGROHAND1.lua and take a look.

The function OnGUI() is the area of interest. This function contains the buttons and joint angle sliders we seen on the AHAS GUI. To create a button and link its press to a command is as simple as follows:

...
    -- if button is pressed
    -- GUIButton(x-pos, y-pos, width, height, "name")
    if (GUIButton(5, 35, 120, 25, "Home")) then
      -- command to be send to controller:
      -- RCMD_GO_HOME, RCMD_GO_READY or RCMD_USER + #
      sendCommand("HandController", RCMD_GO_HOME, VK_H)
      -- command prompt output
      print("Home button pressed")
    end
...

This button





Whos here now:   Members 0   Guests 1   Bots & Crawlers 1