Difference between revisions of "4. AHAS Buttons and BHand Library Motions"
Alexalspach (Talk | contribs) (→AHAS Buttons) |
Alexalspach (Talk | contribs) (→AHAS Buttons) |
||
Line 31: | Line 31: | ||
</syntaxhighlight > | </syntaxhighlight > | ||
− | This button | + | This button, when pressed, will cause the hand to assume its ''Home'' position. As mentioned in the comments, the arguments of ''GUIButtons()'' specify the button's location and the string displayed on the button. |
+ | |||
+ | '''x-pos:''' button's distance from the left side of the AHAS window (pixels) | ||
+ | '''y-pos:''' button's distance from the top of the AHAS window (pixels) | ||
+ | '''width:''' button width (pixels) | ||
+ | '''height:''' button height (pixels) | ||
+ | |||
+ | The function ''sendCommand'' is used to forward a command to the hand controller, the DLL plug-in, ''control_AllegroHand.dll''. | ||
+ | |||
+ | <syntaxhighlight lang="lua"> | ||
+ | ... | ||
+ | |||
+ | -- "HandController", name assigned to controller plugin control_AllegroHand.dll (linked through control_AllegroHand.xdl) | ||
+ | -- code from function Awake() | ||
+ | -- createController("HandController", "hand") --, 1, "controls/control_AllegroHand.xdl", "") | ||
+ | -- setControlAlgorithm("HandController", "controls/control_AllegroHand.xdl") | ||
+ | |||
+ | -- RCMD_GO_HOME, command value recognized by switch statement within control_AllegroHand.dll's command() function. | ||
+ | |||
+ | sendCommand("HandController", RCMD_GO_HOME) | ||
+ | |||
+ | ... | ||
+ | </syntaxhighlight > |
Revision as of 16:02, 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, when pressed, will cause the hand to assume its Home position. As mentioned in the comments, the arguments of GUIButtons() specify the button's location and the string displayed on the button.
x-pos: button's distance from the left side of the AHAS window (pixels) y-pos: button's distance from the top of the AHAS window (pixels) width: button width (pixels) height: button height (pixels)
The function sendCommand is used to forward a command to the hand controller, the DLL plug-in, control_AllegroHand.dll.
... -- "HandController", name assigned to controller plugin control_AllegroHand.dll (linked through control_AllegroHand.xdl) -- code from function Awake() -- createController("HandController", "hand") --, 1, "controls/control_AllegroHand.xdl", "") -- setControlAlgorithm("HandController", "controls/control_AllegroHand.xdl") -- RCMD_GO_HOME, command value recognized by switch statement within control_AllegroHand.dll's command() function. sendCommand("HandController", RCMD_GO_HOME) ...
Whos here now: Members 0 Guests 0 Bots & Crawlers 2 |