(Finally, the Controller!)
 
(45 intermediate revisions by one user not shown)
Line 1: Line 1:
To implement your own control algorithm for the Allegro Hand is relatively simple once the intial framework has been established. This tutorial will guide you through the steps necessary to create you own controller plugin and access it via Allegro Application Studio.
+
'''We do not support AHAS Tutorials anymore. Please try Windows Projects or Linux Projects.'''
 +
 
 +
To implement your own control algorithm for the Allegro Hand is relatively simple once the intial framework has been established. This tutorial will guide you through the steps necessary to create your own controller plugin and access it via Allegro Application Studio.
  
 
'''''Note:''' This tutorial assumes you have Allegro Application Studio and Visual Studio 2008 (Service Pack 1) installed. If you have not yet installed Allegro Application Studio, please see the pages [[Allegro Application Studio (Installation)]] and Allegro Application Studio (User Manual).''
 
'''''Note:''' This tutorial assumes you have Allegro Application Studio and Visual Studio 2008 (Service Pack 1) installed. If you have not yet installed Allegro Application Studio, please see the pages [[Allegro Application Studio (Installation)]] and Allegro Application Studio (User Manual).''
Line 9: Line 11:
 
<pre>Allegro Hand Application Studio\userControllers</pre>
 
<pre>Allegro Hand Application Studio\userControllers</pre>
  
Within this folder, we will create a new Visual Studio DLL project.
+
Within this folder, we will create a new Visual Studio DLL project.<br>
  
 
==Create New DLL Project==
 
==Create New DLL Project==
  
Open up Visual Studio (VS) 2008. Again, it is necessary to have Service Pack 1 installed to use SimLab products.
+
Open up Visual Studio (VS) 2008. Again, it is necessary to have Service Pack 1 installed to use SimLab products.<br>
 +
It is necessary to open VS 2008 with Administrator Privilege.
  
 
===Create Project===
 
===Create Project===
Line 21: Line 24:
 
<pre>File > New > Project</pre>
 
<pre>File > New > Project</pre>
  
In the ''New Project'' window, select ''Win32'' under ''Project types'' and choose the ''Win32 Console Application'' template. In the ''Name'' field, choose a name for the controller. It will be most convenient to match the tutorial and choose '''''control_AllegroHand''''' for the project name. In the ''Location'' field, choose the newly created ''userControllers'' folder in the ''Allegro Hand Application Studio'' directory. You might need the Administrator Privilege.
+
In the ''New Project'' window, select ''Win32'' under ''Project types'' and choose the ''Win32 Console Application'' template. In the ''Name'' field, choose a name for the controller. We recommend Its name as '''''myAHController''''' for the project name. In the ''Location'' field, choose the newly created ''userControllers'' folder in the ''Allegro Hand Application Studio'' directory.
  
 
<pre>C:\Program Files (x86)\SimLab\Allegro Hand Application Studio\userControllers</pre>
 
<pre>C:\Program Files (x86)\SimLab\Allegro Hand Application Studio\userControllers</pre>
Line 27: Line 30:
 
<br>[[image:newProject.jpg|400px]]<br><br>
 
<br>[[image:newProject.jpg|400px]]<br><br>
  
Click ''OK'' to continue.
+
'''Create directory for solution''' should be unchecked. Click ''OK'' to continue.
  
 
When greeted by the ''Win32 Application Wizard'', click ''Next >'' to configure the new project.
 
When greeted by the ''Win32 Application Wizard'', click ''Next >'' to configure the new project.
Line 41: Line 44:
 
===Add Files===
 
===Add Files===
  
In the ''Solution Explorer'' (likely in a pane on the left side of VS) you should see your new project, ''control_AllegroHand''. Right click the '''bold''' project name (not Solution 'control_AllegroHand' (1 project)) to add a new item to the project.
+
In the ''Solution Explorer'' (likely in a pane on the left side of VS) you should see your new project, ''myAHController''.<br>
 +
Right click the '''bold''' project name (not Solution 'myAHController' to add a new item to the project.
  
<pre>control_AllegroHand (right click) > Add > New Item...</pre>
+
<pre>myAHController (right click) > Add > New Item...</pre>
  
 
<br>[[image:addFile.jpg|400px]]<br><br>
 
<br>[[image:addFile.jpg|400px]]<br><br>
  
If you click ''Visual C++'' under in the ''Categories'' pane, you will all of the available templates. Choose the template ''C++ File (.cpp)'' and name is '''''control_AllegroHand'''''. Leave the location as the default. Click ''Add'' to add the file to your project.
+
If you click ''Visual C++'' under in the ''Categories'' pane, you will all of the available templates. Choose the template ''C++ File (.cpp)'' and name is '''''myAHController'''''.<br>
 +
Leave the location as the default. Click ''Add'' to add the file to your project.
  
 
<br>[[image:addCpp.jpg|400px]]<br><br>
 
<br>[[image:addCpp.jpg|400px]]<br><br>
  
Repeat the ''Add New Item'' process two more times to add two ''Header Files (.h)'' to the project titled '''''control_AllegroHand''''' and '''''control_AllegroHandCmd'''''.
+
Repeat the ''Add New Item'' process two more times to add two ''Header Files (.h)'' to the project titled '''''myAHController''''' and '''''myAHControllerCmd'''''.<br>
 +
By this time you should have added three files to the project:<br>
  
By this time you should have added three files to the project:
 
 
<pre>
 
<pre>
control_AllegroHand.cpp
+
myAHController.cpp
control_AllegroHand.h
+
myAHController.h
control_AllegroHandCmd.h
+
myAHControllerCmd.h
 
</pre>
 
</pre>
  
Line 68: Line 73:
 
To compile the project with all the proper dependencies and behaviors, the several properties must be set prior.
 
To compile the project with all the proper dependencies and behaviors, the several properties must be set prior.
  
In the ''Solution Explorer'' (likely in a pane on the left side of VS), right click the '''bold''' project name (not Solution 'control_AllegroHand' (1 project)), and select ''Properties''.
+
In the ''Solution Explorer'' (likely in a pane on the left side of VS), right click the '''bold''' project name (not Solution 'myAHController' (1 project)), and select ''Properties''.
  
<pre>control_AllegroHand (right click) > Properties</pre>
+
<pre>myAHController (right click) > Properties</pre>
  
 
<br>[[image:Properties.jpg|400px]]<br><br>
 
<br>[[image:Properties.jpg|400px]]<br><br>
Line 79: Line 84:
 
<pre>
 
<pre>
 
Configuration Properties > C/C++ >
 
Configuration Properties > C/C++ >
   1. General > Additional Include Directories: ..\..\..\include;
+
   1. General > Additional Include Directories: ..\..\include;
   2. Preprocessor > Preprocessor Definitions: WIN32;_DEBUG;_WINDOWS;_USRDLL;CONTROL_ALLEGROHAND_EXPORTS;R_EXPORTS
+
   2. Preprocessor > Preprocessor Definitions: WIN32;_DEBUG;_WINDOWS;_USRDLL;MYAHCONTROLLER_EXPORTS;R_EXPORTS
 
   
 
   
 
Configuration Properties > Linker >
 
Configuration Properties > Linker >
   3. General > Output File: ..\..\..\bin\controls\$(ProjectName).dll;
+
   3. General > Output File: ..\..\bin\controls\$(ProjectName).dll
   4. General > Additional Library Directories: ..\..\..\lib;..\..\..\lib\BHand;
+
   4. General > Additional Library Directories: ..\..\lib;..\..\lib\BHand;
   5. Input > Additional Dependencies: rMath_9.lib rxControlSDK_9.lib libBHand.lib
+
   5. Input > Additional Dependencies: rMath_9d.lib rxControlSDK_9d.lib libBHand.lib
 
</pre>
 
</pre>
  
Line 91: Line 96:
 
<pre>
 
<pre>
 
Configuration Properties > C/C++ >
 
Configuration Properties > C/C++ >
   1. General > Additional Include Directories: ..\..\..\include;
+
   1. General > Additional Include Directories: ..\..\include;
 
   2. Preprocessor > Preprocessor Definitions: WIN32;NDEBUG;_WINDOWS;_USRDLL;CONTROL_ALLEGROHAND_EXPORTS;R_EXPORTS
 
   2. Preprocessor > Preprocessor Definitions: WIN32;NDEBUG;_WINDOWS;_USRDLL;CONTROL_ALLEGROHAND_EXPORTS;R_EXPORTS
 
   
 
   
 
Configuration Properties > Linker >
 
Configuration Properties > Linker >
   3. General > Output File: ..\..\..\bin\controls\$(ProjectName).dll;
+
   3. General > Output File: ..\..\bin\controls\$(ProjectName).dll
   4. General > Additional Library Directories: ..\..\..\lib;..\..\..\lib\BHand;
+
   4. General > Additional Library Directories: ..\..\lib;..\..\lib\BHand;
 
   5. Input > Additional Dependencies: rMath_9.lib rxControlSDK_9.lib libBHand.lib
 
   5. Input > Additional Dependencies: rMath_9.lib rxControlSDK_9.lib libBHand.lib
 
</pre>
 
</pre>
 
'''''Note:''' At the top of the ''Project Properties'' window, there is a drop down menu labeled ''Configuration''. Within this menu, please select ''All Configurations'' so that the properties are set for release and debug configurations alike. you must be careful about different properties for release and debug configurations.''
 
 
<br>[[image:Configs.jpg|400px]]<br><br>
 
 
The additional include directory added contains all of the header files installed with Allegro Application Studio.
 
  
 
<br>[[image:Props1.jpg|400px]]<br><br>
 
<br>[[image:Props1.jpg|400px]]<br><br>
  
The only new preprocessor definition should be ''R_EXPORTS''. This allows the DLL file to be exported properly for use with Allegro Hand Application Studio.
+
The only new preprocessor definition should be ''R_EXPORTS''.<br>
 +
This allows the DLL file to be exported properly for use with Allegro Hand Application Studio.
  
 
<br>[[image:Props2.jpg|400px]]<br><br>
 
<br>[[image:Props2.jpg|400px]]<br><br>
Line 137: Line 137:
 
<pre>C:\Program Files (x86)\SimLab\Allegro Hand Application Studio\bin\controls</pre>
 
<pre>C:\Program Files (x86)\SimLab\Allegro Hand Application Studio\bin\controls</pre>
  
In this folder you will find a file entitled ''control_AllegroHand_L.xdl''. Copy and paste the file in the same folder and rename it ''new_XDL.xdl''
+
In this folder you will find a file entitled ''control_AllegroHand_L.xdl''.<br>
 
+
Copy and paste the file in the same folder and rename it ''myAHController.xdl''
===Edit with RoboticsLab===
+
 
+
If you have ''SimLab's RoboticsLab'' software, you can edit the XDL file using ''rBuilder''. When opened, you will see multiple entries on the left, including ''Name'', the controller name, and ''Path'', the path to the DLL file exported by our control_AllegroHand VS project.
+
 
+
'''''Reminder:''' The path is just the name of the DLL file because the DLL will export to the same folder as the XDL file, controls.''
+
 
+
Last, we will check the field titles ''whichHand''. This field is referenced by the controller to determine whether to control a left or right hand. If you are using an Allegro RIGHT Hand, this field should say '''''Right'''''. If using a LEFT hand, this field should say '''''Left'''''. Save the changes and close ''rBuilder''.
+
 
+
<br>[[image:rBuilderXDL.jpg|400px]]<br><br>
+
 
+
===Edit without RoboticsLab===
+
  
If you do not have RoboticsLab, then you must edit the XDL text file directly. The contents of the file can be edited in any text editor but an editor meant for html editing, like Notepad++, is suggested.
+
===Edit myAHController.xdl file===
  
'''''Note:''' A 30-day free trial of RoboticsLab can be downloaded at http://www.simlab.co.kr/Download.htm''
+
The contents of the file can be edited in any text editor but an editor meant for html editing, like Notepad++, is suggested.
  
 
Open the XDL file in whatever text editor you choose and you will see the following.
 
Open the XDL file in whatever text editor you choose and you will see the following.
Line 172: Line 161:
 
</syntaxhighlight>
 
</syntaxhighlight>
  
In this XML code, the fields of interest are set apart from the rest of the code. In your XML file, there will likely be one long line with most of the information in it. In this XML file we must change the fields ''Name'', the controller name, and ''Path'', the path to the DLL file exported by our control_AllegroHand VS project.
+
In this XML code, the fields of interest are set apart from the rest of the code. In your XML file, there will likely be one long line with most of the information in it. In this XML file we must change the fields ''Name'', the controller name(myAHController), and ''Path'', the path to the DLL file(myAHController.dll) exported by myAHController VS project.
  
 
'''''Reminder:''' The path is just the name of the DLL file because the DLL will export to the same folder as the XDL file, controls.''
 
'''''Reminder:''' The path is just the name of the DLL file because the DLL will export to the same folder as the XDL file, controls.''
Line 182: Line 171:
 
The AHAS environment is created using a ''Lua'' file located in the ''bin\controls'' directory of the AHAS installation directory. To take advantage of the new controller that we will create, we will create a new Lua file. This allows us to roll back to the stock AHAS environment if we encounter any problems.
 
The AHAS environment is created using a ''Lua'' file located in the ''bin\controls'' directory of the AHAS installation directory. To take advantage of the new controller that we will create, we will create a new Lua file. This allows us to roll back to the stock AHAS environment if we encounter any problems.
  
Find the ''Lua'' file called ''AHAS_L.lua'' and copy and paste it to the same folder. Rename the file '''''ALLEGROHAND1.lua'''''. Open ''ALLEGROHAND1.lua'' to see the following code.
+
Find the ''Lua'' file called ''AHAS_L.lua'' and copy and paste it to the same folder. Rename the file '''''myAHController.lua'''''. Open ''myAHController.lua'' to see the following code.
  
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
Line 193: Line 182:
 
T0 = HTransform.new(Rotation.new(), Vector3D.new(0, 0, 0))
 
T0 = HTransform.new(Rotation.new(), Vector3D.new(0, 0, 0))
 
hand = RoboticsLab.createSystem(aml, sysname, T0)
 
hand = RoboticsLab.createSystem(aml, sysname, T0)
 
+
...
apple = RoboticsLab.createStaticSystem("models/Etc/Objects/apple.aml", "apple", HTransform.new(Rotation.new(), Vector3D.new(0.03, -0.03, .03)))
+
 
+
step = 1
+
deltaT = 0.003
+
controller = RoboticsLab.createController("controller", hand, step)
+
controller:setAlgorithm(controlXDL)
+
controller:setPeriod(deltaT)
+
controller:setNominalSystem(aml, sysname)
+
 
+
function Update()
+
-- Can be used do draw graphic elements in AHAS
+
end
+
 
+
BH_READY = RCMD_USER + 2
+
BH_GRASP_3 = RCMD_USER + 3
+
BH_GRASP_4 = RCMD_USER + 4
+
BH_PINCH_IT = RCMD_USER + 5
+
BH_PINCH_MT = RCMD_USER + 6
+
BH_ENVELOP = RCMD_USER + 8
+
BH_SHOWOFF = RCMD_USER + 50
+
BH_GRAVITY_COMP = RCMD_USER + 9
+
BH_TEST = RCMD_USER + 100
+
+
CAN_CMD_RESET_ENC = 4
+
+
isConnected = true
+
 
+
function allMotionsFalse()
+
  isHome = false
+
  isReady = false
+
  isGrasp3 = false
+
  isGrasp4 = false
+
  isPinchIT = false
+
  isPinchMT = false
+
  isEnvelop = false
+
  isShowOff = false
+
  isGravity = false
+
end
+
 
+
allMotionsFalse()
+
 
+
function button (row,col)
+
-- local buttonWidth = 128
+
-- local horizontalPadding = 10
+
-- local buttonHeight = 128
+
-- local verticalPadding = 10
+
local button_array = {}
+
button_array[1] = leftPadding + horizontalPadding*col + buttonWidth*(col-1)
+
button_array[2] = topPadding + verticalPadding*row + buttonHeight*(row-1)
+
button_array[3] = buttonWidth
+
button_array[4] = buttonHeight
+
return button_array
+
end 
+
 
+
rowsTotal = 6
+
maxButtonSize = 100
+
 
+
function OnGUI()
+
 
+
 
+
topPadding_percent = 02/100
+
topPadding = Screen.height*topPadding_percent
+
leftPadding = topPadding
+
buttonSize_plusPadding = (Screen.height-topPadding*3)/rowsTotal
+
 
+
button_percent = 93/100
+
buttonHeight = buttonSize_plusPadding*button_percent
+
buttonWidth = buttonHeight
+
verticalPadding = buttonSize_plusPadding - buttonHeight
+
horizontalPadding = verticalPadding
+
 
+
 
+
if (buttonHeight > maxButtonSize) then
+
buttonHeight = maxButtonSize
+
buttonWidth = buttonHeight
+
verticalPadding = 10
+
horizontalPadding = 10
+
leftPadding = 10
+
topPadding = 10
+
end
+
 
+
AllegroLogoWidth_max = 512
+
AllegroLogoHeight_max = AllegroLogoWidth_max/8
+
 
+
 
+
AllegroLogoHeight = AllegroLogoHeight_max
+
AllegroLogoWidth = AllegroLogoWidth_max
+
+
+
if (Screen.width > 0.8*AllegroLogoWidth_max) then
+
  x = Screen.width - AllegroLogoWidth - leftPadding
+
  y = topPadding
+
  GUI.DrawTexture(Rect.new(x, y, AllegroLogoWidth, AllegroLogoHeight), Image.new("buttonImages/AllegroHandLogo.png"), 0.0)
+
end
+
+
-- ROW 1
+
--[[
+
row = 1
+
col = 1
+
button_image = Image.new("buttonImages/on.png")
+
if (isConnected) then
+
button_image = Image.new("buttonImages/off.png")
+
end
+
--if (GUI.Button(Rect.new(hLocation(col), vLocation(row), buttonWidth, buttonHeight),  Image.new(button_image))) then
+
if (GUI.Button(Rect.new(button(row,col)[1], button(row,col)[2], button(row,col)[3], button(row,col)[4]),  button_image)) then
+
if (isConnected) then
+
comm:off()
+
controller:command(RESERVED_CMD_SERVO_OFF)
+
isConnected = false
+
  allMotionsFalse()
+
else
+
  controller:command(RCMD_USER + 0)
+
  comm:on()
+
  controller:command(RESERVED_CMD_SERVO_ON)
+
  isConnected = true
+
    allMotionsFalse()
+
end
+
end
+
]]--
+
+
-- ROW 1
+
row = 1
+
col = 1
+
button_image = Image.new("buttonImages/home_off.png")
+
if (isHome) then
+
button_image = Image.new("buttonImages/home_on.png")
+
end
+
if (GUI.Button(Rect.new(button(row,col)[1], button(row,col)[2], button(row,col)[3], button(row,col)[4]),  button_image)) then
+
controller:command(RCMD_GO_HOME, VK_H)
+
print("Home button pressed")
+
allMotionsFalse()
+
if (isConnected) then isHome = true end
+
end
+
+
col = 2
+
button_image = Image.new("buttonImages/ready_off.png")
+
if (isReady) then
+
button_image = Image.new("buttonImages/ready_on.png")
+
end
+
if (GUI.Button(Rect.new(button(row,col)[1], button(row,col)[2], button(row,col)[3], button(row,col)[4]),  button_image)) then
+
controller:command(BH_READY, VK_R)
+
print("Ready button pressed")
+
allMotionsFalse()
+
if (isConnected) then isReady = true end
+
end
+
+
-- ROW 3
+
row = 2
+
col = 1
+
button_image = Image.new("buttonImages/grasp3fingers_off.png")
+
if (isGrasp3) then
+
button_image = Image.new("buttonImages/grasp3fingers_on.png")
+
end 
+
if (GUI.Button(Rect.new(button(row,col)[1], button(row,col)[2], button(row,col)[3], button(row,col)[4]),  button_image)) then
+
controller:command(BH_GRASP_3)
+
print("Grasp 3 button pressed")
+
allMotionsFalse()
+
if (isConnected) then isGrasp3 = true end
+
end
+
+
col = 2
+
button_image = Image.new("buttonImages/grasp4fingers_off.png")
+
if (isGrasp4) then
+
button_image = Image.new("buttonImages/grasp4fingers_on.png")
+
end 
+
if (GUI.Button(Rect.new(button(row,col)[1], button(row,col)[2], button(row,col)[3], button(row,col)[4]),  button_image)) then
+
controller:command(BH_GRASP_4)
+
print("Grasp 4 button pressed")
+
allMotionsFalse()
+
if (isConnected) then isGrasp4 = true end
+
end
+
+
-- ROW 4
+
row = 3
+
col = 1
+
button_image = Image.new("buttonImages/pinchIndex_off.png")
+
if (isPinchIT) then
+
button_image = Image.new("buttonImages/pinchIndex_on.png")
+
end 
+
if (GUI.Button(Rect.new(button(row,col)[1], button(row,col)[2], button(row,col)[3], button(row,col)[4]),  button_image)) then
+
controller:command(BH_PINCH_IT)
+
print("Pinch (IT) button pressed")
+
allMotionsFalse()
+
if (isConnected) then isPinchIT = true end
+
end
+
+
col = 2
+
button_image = Image.new("buttonImages/pinchMiddle_off.png")
+
if (isPinchMT) then
+
button_image = Image.new("buttonImages/pinchMiddle_on.png")
+
end 
+
if (GUI.Button(Rect.new(button(row,col)[1], button(row,col)[2], button(row,col)[3], button(row,col)[4]),  button_image)) then
+
controller:command(BH_PINCH_MT)
+
print("Pinch (MT) button pressed")
+
allMotionsFalse()
+
if (isConnected) then isPinchMT = true end
+
end
+
+
+
-- ROW 5
+
row = 4
+
col = 1
+
button_image = Image.new("buttonImages/envelop_off.png")
+
if (isEnvelop) then
+
button_image = Image.new("buttonImages/envelop_on.png")
+
end 
+
if (GUI.Button(Rect.new(button(row,col)[1], button(row,col)[2], button(row,col)[3], button(row,col)[4]),  button_image)) then
+
controller:command(BH_ENVELOP)
+
print("Envelop button pressed")
+
allMotionsFalse()
+
if (isConnected) then isEnvelop = true end
+
end
+
+
--[[
+
col = 2
+
button_image = Image.new("buttonImages/gravityCompensation_off.png")
+
if (isGravity) then
+
button_image = Image.new("buttonImages/gravityCompensation_on.png")
+
end 
+
if (GUI.Button(Rect.new(button(row,col)[1], button(row,col)[2], button(row,col)[3], button(row,col)[4]),  button_image)) then
+
controller:command(BH_GRAVITY_COMP)
+
print("Gravity Compensation button pressed")
+
allMotionsFalse()
+
if (isConnected) then isGravity = true end
+
end
+
 
+
-- ROW 6
+
row = 5
+
col = 2
+
button_image = Image.new("buttonImages/showOff_off.png")
+
if (isShowOff) then
+
button_image = Image.new("buttonImages/showOff_on.png")
+
end 
+
if (GUI.Button(Rect.new(button(row,col)[1], button(row,col)[2], button(row,col)[3], button(row,col)[4]),  button_image)) then
+
controller:command(BH_SHOWOFF)
+
print("Showoff button pressed")
+
allMotionsFalse()
+
if (isConnected) then isShowOff = true end
+
end
+
]]--
+
+
-- ROW 8
+
--[[
+
row = rowsTotal
+
col = 1
+
button_image = Image.new("buttonImages/encoderOffsets_off.png")
+
if (GUI.Button(Rect.new(Screen.width - button(row,col)[1]-buttonWidth, button(row,col)[2], button(row,col)[3], button(row,col)[4]),  button_image)) then
+
 
+
  for i=1,16 do
+
encName = "enc"..i
+
+
if i == 1 then
+
print(" ")
+
print("Finger 1")
+
end
+
+
if i == 5 then
+
print(" ")
+
print("Finger 2")
+
end
+
+
if i == 9 then
+
print(" ")
+
print("Finger 3")
+
end
+
+
if i == 13 then
+
print(" ")
+
print("Finger 4")
+
end
+
+
enc = hand:findDevice(encName)
+
enc:command(CAN_CMD_RESET_ENC)
+
--print("Test Encoders")
+
  end
+
  io.read()
+
end
+
+
row = rowsTotal - 1
+
col = 1
+
button_image = Image.new("buttonImages/motorDirections_off.png")
+
if (GUI.Button(Rect.new(Screen.width - button(row,col)[1]-buttonWidth, button(row,col)[2], button(row,col)[3], button(row,col)[4]),  button_image)) then
+
controller:command(BH_TEST)
+
print("Test Motor Positive Direction")
+
end
+
+
]]--
+
 
+
end
+
 
</syntaxhighlight>
 
</syntaxhighlight>
  
To access our new controller, ''new_XDL.xdl'', we must change what is necessary in this ''Lua'' file.
+
To access our new controller, ''myAHController.xdl'', we must change what is necessary in this ''Lua'' file.
Change '''controlXDL = "controls/control_AHAS_L.xdl"''' to '''controlXDL = "controls/new_XDL.xdl"''' in the fourth line.
+
Change '''controlXDL = "controls/control_AHAS_L.xdl"''' to '''controlXDL = "controls/myAHController.xdl"''' in the fourth line.
  
 
For now, we will leave all of the buttons in place for later use.
 
For now, we will leave all of the buttons in place for later use.
Line 502: Line 202:
  
 
aml = "models/Etc/AllegroHand/AllegroHandL.aml"
 
aml = "models/Etc/AllegroHand/AllegroHandL.aml"
controlXDL = "controls/new_XDL.xdl"
+
controlXDL = "controls/myAHController.xdl"
 
...
 
...
 
...
 
...
Line 512: Line 212:
 
==AHAS Shortcut==
 
==AHAS Shortcut==
  
To make our life easier in the future, we will create a shortcut directly to this newly created ''ALLEGROHAND1.lua'' simulation load file.
+
To make our life easier in the future, we will create a shortcut directly to this newly created ''myAHController.lua'' simulation load file.
  
 
First, navigate to ''Allegro.exe'' in the AHAS ''bin'' folder.  
 
First, navigate to ''Allegro.exe'' in the AHAS ''bin'' folder.  
Line 518: Line 218:
 
<pre>C:\Program Files (x86)\SimLab\Allegro Hand Application Studio\bin\Allegro.exe</pre>
 
<pre>C:\Program Files (x86)\SimLab\Allegro Hand Application Studio\bin\Allegro.exe</pre>
  
Right-click ''Allegro.exe'' and select ''Create shortcut'' in the menu. Likely, you will be forced to create the shortcut on ''Desktop'' due to write privileges in the ''Program Files'' directory. If not, create the shortcut there, then move it to the ''Desktop''. Rename the shortut to something like '''''AllegroHand1''''' so that you can tell it apart from the original AHAS shortcut.
+
Right-click ''Allegro.exe'' and select ''Create shortcut'' in the menu. Likely, you will be forced to create the shortcut on ''Desktop'' due to write privileges in the ''Program Files'' directory. If not, create the shortcut there, then move it to the ''Desktop''. Rename the shortut to something like '''''myAHController''''' so that you can tell it apart from the original AHAS shortcut.
  
This shortcut will open AHAS as normal giving you the option to select a hand and a CAN device. To link directly to a certain simulation, right-click the shortcut and select ''Properties'' from the menu. In the ''Shortcut'' tab of the ''Properties'' window, locate the ''Target field''. Edit the ''Target'' field so that the second argument is the new ''Lua'' file path, ''controls/ALLEGRoHAND1.Lua''
+
This shortcut will open AHAS as normal giving you the option to select a hand and a CAN device. To link directly to a certain simulation, right-click the shortcut and select ''Properties'' from the menu. In the ''Shortcut'' tab of the ''Properties'' window, locate the ''Target field''. Edit the ''Target'' field so that the second argument is the new ''Lua'' file path, ''controls/myAHController.Lua''
  
 
<pre>
 
<pre>
 
Original Target: "C:\Program Files (x86)\SimLab\Allegro Hand Application Studio\bin\Allegro.exe"
 
Original Target: "C:\Program Files (x86)\SimLab\Allegro Hand Application Studio\bin\Allegro.exe"
New Target:      "C:\Program Files (x86)\SimLab\Allegro Hand Application Studio\bin\Allegro.exe" controls\ALLEGROHAND1.lua
+
New Target:      "C:\Program Files (x86)\SimLab\Allegro Hand Application Studio\bin\Allegro.exe" controls\myAHController.lua
 
</pre>
 
</pre>
  
 
<br>[[Image:shortcut.jpg|300px]]<br><br>
 
<br>[[Image:shortcut.jpg|300px]]<br><br>
  
Close the ''Properties'' window and double-click the the shortcut to test it out. An Allegro Hand simulator should load and none of the buttons should work. If this is the case, more on to creating your first AHAS controller!
+
Close the ''Properties'' window.<br>
  
 
==Finally, the Controller!==
 
==Finally, the Controller!==
Line 535: Line 235:
 
We created our Visual Studio (VS) project earlier in the tutorial with three files:
 
We created our Visual Studio (VS) project earlier in the tutorial with three files:
 
<pre>
 
<pre>
control_AllegroHand.cpp
+
myAHController.cpp
control_AllegroHand.h
+
myAHController.h
control_AllegroHandCmd.h
+
myAHControllerCmd.h
 
</pre>
 
</pre>
  
 
'''Goals:'''  
 
'''Goals:'''  
# Create a simple hand motion to run at the start of AHAS.
+
# Make your own dll that doesn't do anything.
# Link this motion to a button in AHAS.
+
# Call some of the BHand library grasping motions using AHAS buttons.
+
 
<br>
 
<br>
  
The following code is the basis for your AHAS control plug-in. Please paste this code into the respective files, compile, then click the shortcut on the desktop to launch your custom AHAS application. You can now begin to develop your Allegro Hand controller. You might be failed to launch your application. In that case, download [[File:AllegroHandAml.zip]], unzip and paste them in ''Allegro Hand Application Studio\bin\models\Etc\AllegroHand folder''.
+
The following code is the basis for your AHAS control plug-in. Please paste this code into the respective files, compile, then click the shortcut on the desktop to launch your custom AHAS application. You can now begin to develop your Allegro Hand controller.<br>
 +
You might be failed to launch your application.<br>
 +
In that case, download [[File:AllegroHandAml.zip]], unzip and paste them in ''Allegro Hand Application Studio\bin\models\Etc\AllegroHand folder''.
  
 
For more information, please read the comments below and reference the ''RoboticsLab Programming Guide''.<br>
 
For more information, please read the comments below and reference the ''RoboticsLab Programming Guide''.<br>
 
[http://simlab.dyndns.org:9000/AllegroHandWiki/images/2/29/RoboticsLab_BegProgrammingGuide.pdf RoboticsLab Programming Guide PDF] - Page 139, Section 4. ''Custom Control Algorithms''
 
[http://simlab.dyndns.org:9000/AllegroHandWiki/images/2/29/RoboticsLab_BegProgrammingGuide.pdf RoboticsLab Programming Guide PDF] - Page 139, Section 4. ''Custom Control Algorithms''
  
===control_AllegroHand.h===
+
===myAHController.h===
 
<syntaxhighlight lang="cpp">
 
<syntaxhighlight lang="cpp">
  
#ifndef __CONTROL_ALLEGROHAND_H__
+
#ifndef __MY_AH_CONTROLLER_H__
#define __CONTROL_ALLEGROHAND_H__
+
#define __MY_AH_CONTROLLER_H__
 
+
 
#include <list>
 
#include <list>
 
#include "rControlAlgorithm/rControlAlgorithm.h"
 
#include "rControlAlgorithm/rControlAlgorithm.h"
 
#include "BHand/BHand.h"
 
#include "BHand/BHand.h"
 
+
// control_AllegroHand inherited from algorithm interface class
+
// myAHController inherited from algorithm interface class
class REXPORT control_AllegroHand : public rControlAlgorithmEx
+
class REXPORT myAHController : public rControlAlgorithmEx
 
{
 
{
 
public:
 
public:
control_AllegroHand(rDC rdc);
+
myAHController(rDC rdc);
~control_AllegroHand();
+
~myAHController();
 
+
 
virtual void init(int mode = 0);
 
virtual void init(int mode = 0);
 
virtual void update(const rTime& t);
 
virtual void update(const rTime& t);
 
virtual int  command(const short& cmd, const int& arg = 0);
 
virtual int  command(const short& cmd, const int& arg = 0);
 
+
 
private:
 
private:
 
virtual void _readDevices();
 
virtual void _readDevices();
 
virtual void _writeDevices();
 
virtual void _writeDevices();
 
+
 
virtual void _compute(const rTime& t);
 
virtual void _compute(const rTime& t);
 
+
 
void _arrangeJointDevices();
 
void _arrangeJointDevices();
 
+
 
+
 
private:
 
private:
+
 
// algorithm variables go here
 
// algorithm variables go here
 
};
 
};
 
+
 
#endif
 
#endif
  
 
</syntaxhighlight>
 
</syntaxhighlight>
  
===control_AllegroHandCmd.h===
+
===myAHControllerCmd.h===
 
<syntaxhighlight lang="cpp">
 
<syntaxhighlight lang="cpp">
  
#ifndef __CONTROL_ALLEGROHAND_CMD_H__
+
#ifndef __MY_AH_CONTROLLER_CMD_H__
#define __CONTROL_ALLEGROHAND_CMD_H__
+
#define __MY_AH_CONTROLLER_CMD_H__
 
+
 
#include "rCommand/rCmdManipulator.h"
 
#include "rCommand/rCmdManipulator.h"
 
+
 
// These commands will be fed into command()
 
// These commands will be fed into command()
 
// and can be used to envoke certain actions
 
// and can be used to envoke certain actions
Line 606: Line 306:
 
#define BH_HOME (RCMD_GO_HOME)
 
#define BH_HOME (RCMD_GO_HOME)
 
// #define BH_ONE (RCMD_USER + 1)
 
// #define BH_ONE (RCMD_USER + 1)
 
+
 
#endif
 
#endif
  
 
</syntaxhighlight>
 
</syntaxhighlight>
  
===control_AllegroHand.cpp===
+
===myAHController.cpp===
 
<syntaxhighlight lang="cpp">
 
<syntaxhighlight lang="cpp">
  
#include "control_AllegroHand.h"
+
#include "myAHController.h"
#include "control_AllegroHandCmd.h"
+
#include "myAHControllerCmd.h"
 
+
 
+
control_AllegroHand::control_AllegroHand(rDC rdc)  
+
myAHController::myAHController(rDC rdc)  
 
:rControlAlgorithmEx(rdc)
 
:rControlAlgorithmEx(rdc)
 
{
 
{
 
// initialize all the class member variables
 
// initialize all the class member variables
 
}
 
}
 
+
control_AllegroHand::~control_AllegroHand()
+
myAHController::~myAHController()
 
{
 
{
 
}
 
}
 
+
void control_AllegroHand::init(int mode)
+
void myAHController::init(int mode)
 
{
 
{
 
// create hand and find devices
 
// create hand and find devices
Line 636: Line 336:
 
// set all of the components to zero before computing
 
// set all of the components to zero before computing
 
}
 
}
 
+
void control_AllegroHand::_arrangeJointDevices()
+
void myAHController::_arrangeJointDevices()
 
{
 
{
 
// find and store all motors and encoders
 
// find and store all motors and encoders
 
}
 
}
 
+
void control_AllegroHand::update(const rTime& t)
+
void myAHController::update(const rTime& t)
 
{
 
{
 
// Evokes _readDevices(), _estimate(), _reflect(),
 
// Evokes _readDevices(), _estimate(), _reflect(),
 
// _compute(), _writeDevices() in turn by default.
 
// _compute(), _writeDevices() in turn by default.
 
}
 
}
 
+
void control_AllegroHand::_readDevices()
+
void myAHController::_readDevices()
 
{
 
{
 
// read sensors
 
// read sensors
 
}
 
}
 
+
void control_AllegroHand::_writeDevices()
+
void myAHController::_writeDevices()
 
{
 
{
 
// write to actuators
 
// write to actuators
 
}
 
}
 
+
void control_AllegroHand::_compute(const double& t)
+
void myAHController::_compute(const double& t)
 
{
 
{
 
// Computes control inputs
 
// Computes control inputs
 
}
 
}
 
+
int control_AllegroHand::command(const short& cmd, const int& arg)
+
int myAHController::command(const short& cmd, const int& arg)
 
{
 
{
 
// Handles user-defined commands according to cmd.
 
// Handles user-defined commands according to cmd.
 
// Further information can be retrieved from the second argument.
 
// Further information can be retrieved from the second argument.
 
+
 
// The variable cmd will be received from Allegro Application Studio
 
// The variable cmd will be received from Allegro Application Studio
 
// and will be used to envoke hand actions
 
// and will be used to envoke hand actions
 
return 0;
 
return 0;
 
}
 
}
 
+
 
rControlAlgorithm* CreateControlAlgorithm(rDC& rdc)
 
rControlAlgorithm* CreateControlAlgorithm(rDC& rdc)
 
{
 
{
return new control_AllegroHand(rdc);
+
return new myAHController(rdc);
 
}
 
}
  
 
</syntaxhighlight>
 
</syntaxhighlight>
  
Please move onto our next tutorial to learn how to control the joints of the Allegro Hand.
+
Execute the myAHController.exe in desktop folder. You will see virtual AllegroHand and an apple.<br>
 +
The buttons on the left don't work because you've replaced original control_AllegroHand.dll file to your own dll.<br>
 +
Please move onto our next tutorial to learn how to control the joints of the Allegro Hand.<br>
  
 
[[2. Allegro Hand Joint Position Control]]
 
[[2. Allegro Hand Joint Position Control]]
 
[[Category:Programming Guides]]
 
[[Category:Programming Guides]]

Latest revision as of 09:56, 25 June 2018

We do not support AHAS Tutorials anymore. Please try Windows Projects or Linux Projects.

To implement your own control algorithm for the Allegro Hand is relatively simple once the intial framework has been established. This tutorial will guide you through the steps necessary to create your own controller plugin and access it via Allegro Application Studio.

Note: This tutorial assumes you have Allegro Application Studio and Visual Studio 2008 (Service Pack 1) installed. If you have not yet installed Allegro Application Studio, please see the pages Allegro Application Studio (Installation) and Allegro Application Studio (User Manual).

Contents

[edit] Create User Controllers Folder

Start off by creating a folder called userControllers within the Allegro Hand installation directory. The Visual Studio projects can be stored anywhere, but if you match the project folder location seen in this tutorial, all following file paths specified will be correct.

Allegro Hand Application Studio\userControllers

Within this folder, we will create a new Visual Studio DLL project.

[edit] Create New DLL Project

Open up Visual Studio (VS) 2008. Again, it is necessary to have Service Pack 1 installed to use SimLab products.
It is necessary to open VS 2008 with Administrator Privilege.

[edit] Create Project

In the File dropdown menu, click New > Project.

File > New > Project

In the New Project window, select Win32 under Project types and choose the Win32 Console Application template. In the Name field, choose a name for the controller. We recommend Its name as myAHController for the project name. In the Location field, choose the newly created userControllers folder in the Allegro Hand Application Studio directory.

C:\Program Files (x86)\SimLab\Allegro Hand Application Studio\userControllers


NewProject.jpg

Create directory for solution should be unchecked. Click OK to continue.

When greeted by the Win32 Application Wizard, click Next > to configure the new project.


ApplicationWizard.jpg

You will then be presented with a few options. Change the Application type to DLL and, under Addition options, choose to create and Empty project.


ApplicationSettings.jpg

Click Finish to create your new project.

[edit] Add Files

In the Solution Explorer (likely in a pane on the left side of VS) you should see your new project, myAHController.
Right click the bold project name (not Solution 'myAHController' to add a new item to the project.

myAHController (right click) > Add > New Item...


AddFile.jpg

If you click Visual C++ under in the Categories pane, you will all of the available templates. Choose the template C++ File (.cpp) and name is myAHController.
Leave the location as the default. Click Add to add the file to your project.


AddCpp.jpg

Repeat the Add New Item process two more times to add two Header Files (.h) to the project titled myAHController and myAHControllerCmd.
By this time you should have added three files to the project:

myAHController.cpp
myAHController.h
myAHControllerCmd.h

You can see these new files in your Solution Explorer.


SolnExplorerWFiles.jpg

[edit] Project Properties

To compile the project with all the proper dependencies and behaviors, the several properties must be set prior.

In the Solution Explorer (likely in a pane on the left side of VS), right click the bold project name (not Solution 'myAHController' (1 project)), and select Properties.

myAHController (right click) > Properties


Properties.jpg

Within the project Property Pages window, you will see a pane of expandable groups. The following properties must be edited before compiling a control plugin for Allegro Hand Application Studio:

[edit] [Debug Configuration]

Configuration Properties > C/C++ >
  1. General > Additional Include Directories: ..\..\include;
  2. Preprocessor > Preprocessor Definitions: WIN32;_DEBUG;_WINDOWS;_USRDLL;MYAHCONTROLLER_EXPORTS;R_EXPORTS
 
Configuration Properties > Linker >
  3. General > Output File: ..\..\bin\controls\$(ProjectName).dll
  4. General > Additional Library Directories: ..\..\lib;..\..\lib\BHand;
  5. Input > Additional Dependencies: rMath_9d.lib rxControlSDK_9d.lib libBHand.lib

[edit] [Release Configuration]

Configuration Properties > C/C++ >
  1. General > Additional Include Directories: ..\..\include;
  2. Preprocessor > Preprocessor Definitions: WIN32;NDEBUG;_WINDOWS;_USRDLL;CONTROL_ALLEGROHAND_EXPORTS;R_EXPORTS
 
Configuration Properties > Linker >
  3. General > Output File: ..\..\bin\controls\$(ProjectName).dll
  4. General > Additional Library Directories: ..\..\lib;..\..\lib\BHand;
  5. Input > Additional Dependencies: rMath_9.lib rxControlSDK_9.lib libBHand.lib


Props1.jpg

The only new preprocessor definition should be R_EXPORTS.
This allows the DLL file to be exported properly for use with Allegro Hand Application Studio.


Props2.jpg

The output file specified is the DLL file control plugin. This is output the the bin\controls directory where AHAS can access it. The additional library directories contain general and Allegro Hand specific libraries included with AHAS.


Props3.jpg

The additional dependencies include the RoboticsLab Math and Controls SDK libraries, along with the Allegro Hand library.


Props4.jpg

Press Apply to save the changes then press OK to close the Properties window.

[edit] Create Controller XDL

And XDL file must be created to link AHAS and the controller DLL exported by the VS project. This file has two main purposes:

  1. It provides the path to the controller DLL
    • This allows the user to easily switch to a new controller by simply changing the path. Neither the controller file code nor the AHAS files need to be edited to switch the controller.
  2. Variables can be added to this file and accessed by the controller.
    • This allows properties like gains to be edited without recompiling the controller code.

[edit] New XDL

For the purpose of separating user created control plugins from the stock AHAS controller, we will create a new XDL file to be used with a new AHAS file. For future user created controller plugins, you need only edit the path to the control plugin DLL within this XDL. You will not need to create a new XDL and AHAS file for each control plugin.

Start by navigating to the controls folder of your AHAS installation folder.

C:\Program Files (x86)\SimLab\Allegro Hand Application Studio\bin\controls

In this folder you will find a file entitled control_AllegroHand_L.xdl.
Copy and paste the file in the same folder and rename it myAHController.xdl

[edit] Edit myAHController.xdl file

The contents of the file can be edited in any text editor but an editor meant for html editing, like Notepad++, is suggested.

Open the XDL file in whatever text editor you choose and you will see the following.

<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<DLL xmlns="http://www.simlab.co.kr/2008/XDL" name="control_AllegroHand" path="control_AllegroHand.dll" type="USER_CONTROL" ver="1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.simlab.co.kr/2008/XDL XDL.xsd">
 
  <credit address="SimLab Co., Ltd." creator="Sangyup Yi" date="August 22, 2012" description="control Allegro Hand" email="seanyi@simlab.co.kr"/>
 
  <property name="handNumber" value="1"/>
 
  <property name="myName" value="hand1"/>
 
  <property name="whichHand" value="Left"/>
 
</DLL>

In this XML code, the fields of interest are set apart from the rest of the code. In your XML file, there will likely be one long line with most of the information in it. In this XML file we must change the fields Name, the controller name(myAHController), and Path, the path to the DLL file(myAHController.dll) exported by myAHController VS project.

Reminder: The path is just the name of the DLL file because the DLL will export to the same folder as the XDL file, controls.

Last, we will check the field titled whichHand. This field is referenced by the controller to determine whether to control a left or right hand. If you are using an Allegro RIGHT Hand, this field should say Right. If using a LEFT hand, this field should say Left. Save the changes and close the text editor.

[edit] AHAS Lua File

The AHAS environment is created using a Lua file located in the bin\controls directory of the AHAS installation directory. To take advantage of the new controller that we will create, we will create a new Lua file. This allows us to roll back to the stock AHAS environment if we encounter any problems.

Find the Lua file called AHAS_L.lua and copy and paste it to the same folder. Rename the file myAHController.lua. Open myAHController.lua to see the following code.

print(RoboticsLab.version())
 
aml = "models/Etc/AllegroHand/AllegroHandL.aml"
controlXDL = "controls/control_AHAS_L.xdl"
 
sysname = "hand"
T0 = HTransform.new(Rotation.new(), Vector3D.new(0, 0, 0))
hand = RoboticsLab.createSystem(aml, sysname, T0)
...

To access our new controller, myAHController.xdl, we must change what is necessary in this Lua file. Change controlXDL = "controls/control_AHAS_L.xdl" to controlXDL = "controls/myAHController.xdl" in the fourth line.

For now, we will leave all of the buttons in place for later use.


Note: In this file, we are loading the AllegroHandL.aml which is the model for the virtual left hand. If your XDL whichHand field says Left, then this is correct. If the whichHand field says Right, you should load AllegroHandR.aml.


Our edited Lua looks like this:

print(RoboticsLab.version())
 
aml = "models/Etc/AllegroHand/AllegroHandL.aml"
controlXDL = "controls/myAHController.xdl"
...
...
...

We will continue to edit this Lua as the tutorial progresses.

[edit] AHAS Shortcut

To make our life easier in the future, we will create a shortcut directly to this newly created myAHController.lua simulation load file.

First, navigate to Allegro.exe in the AHAS bin folder.

C:\Program Files (x86)\SimLab\Allegro Hand Application Studio\bin\Allegro.exe

Right-click Allegro.exe and select Create shortcut in the menu. Likely, you will be forced to create the shortcut on Desktop due to write privileges in the Program Files directory. If not, create the shortcut there, then move it to the Desktop. Rename the shortut to something like myAHController so that you can tell it apart from the original AHAS shortcut.

This shortcut will open AHAS as normal giving you the option to select a hand and a CAN device. To link directly to a certain simulation, right-click the shortcut and select Properties from the menu. In the Shortcut tab of the Properties window, locate the Target field. Edit the Target field so that the second argument is the new Lua file path, controls/myAHController.Lua

Original Target: "C:\Program Files (x86)\SimLab\Allegro Hand Application Studio\bin\Allegro.exe"
New Target:      "C:\Program Files (x86)\SimLab\Allegro Hand Application Studio\bin\Allegro.exe" controls\myAHController.lua


Shortcut.jpg

Close the Properties window.

[edit] Finally, the Controller!

We created our Visual Studio (VS) project earlier in the tutorial with three files:

myAHController.cpp
myAHController.h
myAHControllerCmd.h

Goals:

  1. Make your own dll that doesn't do anything.


The following code is the basis for your AHAS control plug-in. Please paste this code into the respective files, compile, then click the shortcut on the desktop to launch your custom AHAS application. You can now begin to develop your Allegro Hand controller.
You might be failed to launch your application.
In that case, download File:AllegroHandAml.zip, unzip and paste them in Allegro Hand Application Studio\bin\models\Etc\AllegroHand folder.

For more information, please read the comments below and reference the RoboticsLab Programming Guide.
RoboticsLab Programming Guide PDF - Page 139, Section 4. Custom Control Algorithms

[edit] myAHController.h

#ifndef __MY_AH_CONTROLLER_H__
#define __MY_AH_CONTROLLER_H__
 
#include <list>
#include "rControlAlgorithm/rControlAlgorithm.h"
#include "BHand/BHand.h"
 
// myAHController inherited from algorithm interface class
class REXPORT myAHController : public rControlAlgorithmEx
{
public:
	myAHController(rDC rdc);
	~myAHController();
 
	virtual void init(int mode = 0);
	virtual void update(const rTime& t);
	virtual int  command(const short& cmd, const int& arg = 0);
 
private:
	virtual void _readDevices();
	virtual void _writeDevices();
 
	virtual void _compute(const rTime& t);
 
	void _arrangeJointDevices();
 
 
private:
 
	// algorithm variables go here
};
 
#endif

[edit] myAHControllerCmd.h

#ifndef __MY_AH_CONTROLLER_CMD_H__
#define __MY_AH_CONTROLLER_CMD_H__
 
#include "rCommand/rCmdManipulator.h"
 
// These commands will be fed into command()
// and can be used to envoke certain actions
// by the robot. Allegro Application Studio
// will use these to interface with the
// cotroller plug-in.
#define BH_NONE		(RCMD_USER + 0)
#define BH_HOME		(RCMD_GO_HOME)
// #define BH_ONE		(RCMD_USER + 1)
 
#endif

[edit] myAHController.cpp

#include "myAHController.h"
#include "myAHControllerCmd.h"
 
 
myAHController::myAHController(rDC rdc) 
:rControlAlgorithmEx(rdc)
{
	// initialize all the class member variables
}
 
myAHController::~myAHController()
{
}
 
void myAHController::init(int mode)
{
	// create hand and find devices
	// arrange joint devices function will be called here
	// set degrees of freedom
	// make sure all vectors are the correct size and
	// set all of the components to zero before computing
}
 
void myAHController::_arrangeJointDevices()
{
	// find and store all motors and encoders
}
 
void myAHController::update(const rTime& t)
{
	// Evokes _readDevices(), _estimate(), _reflect(),
	// _compute(), _writeDevices() in turn by default.
}
 
void myAHController::_readDevices()
{
	// read sensors
}
 
void myAHController::_writeDevices()
{
	// write to actuators
}
 
void myAHController::_compute(const double& t)
{
	// Computes control inputs
}
 
int myAHController::command(const short& cmd, const int& arg)
{
	// Handles user-defined commands according to cmd.
	// Further information can be retrieved from the second argument.
 
	// The variable cmd will be received from Allegro Application Studio
	// and will be used to envoke hand actions
	return 0;
}
 
rControlAlgorithm* CreateControlAlgorithm(rDC& rdc)
{
	 return new myAHController(rdc);
}

Execute the myAHController.exe in desktop folder. You will see virtual AllegroHand and an apple.
The buttons on the left don't work because you've replaced original control_AllegroHand.dll file to your own dll.
Please move onto our next tutorial to learn how to control the joints of the Allegro Hand.

2. Allegro Hand Joint Position Control





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