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.

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

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.

New DLL Project

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

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. 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.

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


NewProject.jpg

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.

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.

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


AddFile.jpg

notes

DLL project sim or app not necessary, just plugin to AAS


  • C/C++ GENERAL additional include (..\..\..\include;)
  • Linker GENERAL output file to bin controls (..\..\..\bin\controls\$(ProjectName).dll)
  • Linker geral addition lib dirs (..\..\..\lib;..\..\..\lib\BHand;)
  • Linker input additonal dep (rMath_9.lib rxControlSDK_9.lib libBHand.lib)
  • C/C++ Preprocessor Definitions WIN32;_DEBUG;_WINDOWS;_USRDLL;CONTROL_ALLEGROHAND_EXPORTS;R_EXPORTS

Create XDL path to DLL

Create Custom Lua file with new controller Add buttons, maybe


  1. create new project
  2. Win32 Application, DLL, empty proj
  3. Add cpp, h, and h


control_AllegroHandCmd.h:

#ifndef __CONTROL_ALLEGROHAND_AUTO_CMD_H__
#define __CONTROL_ALLEGROHAND_AUTO_CMD_H__
 
#include "rCommand/rCmdDefine.h"
 
#define DEFAULT_CMD		(RCMD_USER + 1)
//#define USER_CMD_1	(RCMD_USER + 10)
 
#endif




control_AllegroHand.h:

#ifndef __CONTROL_ALLEGROHAND_H__
#define __CONTROL_ALLEGROHAND_H__
 
#include <list>
#include "rControlAlgorithm/rControlAlgorithm.h"
#include "BHand/BHand.h"
//#include "rDeviceERHandRemoteCmd.h" // for BlueTooth or TCPIP control
 
#define JDOF 16 // Degrees of freedom
 
class REXPORT control_AllegroHand : public rControlAlgorithmEx
{
public:
	control_AllegroHand(rDC rdc);
	~control_AllegroHand();
 
	virtual void init(int mode = 0);
	virtual void update(const rTime& t);
 
	//// dont use
	// virtual void setNominalSystem(const TCHAR* path, const TCHAR* aml, const HTransform& T0, const dVector& q0);
 
	//// dont use
	//virtual void setPeriod(const rTime& dT);
 
	virtual int command(const short& cmd, const int& arg = 0);
 
	//// for plotting
	// virtual void datanames(vector<string_type>& names, int channel = -1);
	// virtual void collect(vector<double>& data, int channel = -1);
 
	//// for Move Object?? for telling where to grasp
	// virtual void onSetInterestFrame(const TCHAR* name, const HTransform& T);
 
private:
	// virtual void _estimate();
	virtual void _readDevices();
	virtual void _writeDevices();
 
	//virtual void _reflect();
	virtual void _compute(const rTime& t);
 
	void _arrangeJointDevices();
 
	//void _servoOn();
	//void _servoOff();
 
 
private:
	rTime				_cur_time;
 
	BHand*				_hand;
	bool				_is_left_hand;
 
	rID					_motor[16];
	rID					_enc[16];
	//rID				_remoteTP_BT;
	//rID				_remoteTP_TCPIP;
 
	dVector				_q;			// joint position for 16 joints
	dVector				_qdot;		// joint velocity
	dVector				_torque;	// joint torque
 
	int					_jdof;
 
	double				_x[4];
	double				_y[4];
	double				_z[4];
 
	//// for testing each motor
	//int					_jid_test;
	//bool				_test_mode;
 
	//// for remote control
	//MessageRemoteTP_t	_msgRTP;
	//int					_sz2read_msgRTP;
 
	//// for show off
	//int					_demo_mode;
	//rTime				_demo_start_time;
	//dVector				_demo_q_des;
};
 
#endif


control_AllegroHand.h:

#ifndef __CONTROL_ALLEGROHAND_H__
#define __CONTROL_ALLEGROHAND_H__
 
#include <list>
#include "rControlAlgorithm/rControlAlgorithm.h"
 
// make sure this header is in the Allegro Hand Application Studio include directory
#include "BHand/BHand.h"
 
#define JDOF 16 // Degrees of freedom
 
class REXPORT control_AllegroHand : public rControlAlgorithmEx
{
public:
	control_AllegroHand(rDC rdc);
	~control_AllegroHand();
 
	virtual void init(int mode = 0);
 
	// controller will update every control period
	virtual void update(const rTime& t);
 
	// send motor commands
	virtual int command(const short& cmd, const int& arg = 0);
 
private:
 
	virtual void _readDevices();
	virtual void _writeDevices();
 
	virtual void _compute(const rTime& t);
 
	// function will find all joint devices
	void _arrangeJointDevices();	
 
 
private:
 
	rTime				_cur_time;
 
	BHand*				_hand;
	bool				_is_left_hand;
 
	rID				_motor[16];	// motor IDs
	rID				_enc[16];	// encoder IDs
 
	dVector				_q;		// joint position for 16 joints (read from encoders)
	dVector				_qdot;		// joint velocity
	dVector				_torque;	// joint torque
 
        dVector				_q_des          // target joint position              
 
	int				_jdof;		// number of degrees of freedom (16)
 
	double				_x[4];		// X coord for each of the 4 fingertips
	double				_y[4];		// Y coord for each of the 4 fingertips
	double				_z[4];		// Z coord for each of the 4 fingertips
 
 
};
 
#endif









You are not allowed to post comments.




Copyright & Trademark Notice
Allegro, the Allegro logo, RoboticsLab, the RoboticsLab logo, and all related files and documentation are Copyright ⓒ 2008-2020 Wonik Robotics Co., Ltd. All rights reserved. RoboticsLab and Allegro are trademarks of Wonik Robotics. All other trademarks or registered trademarks mentioned are the properties of their respective owners.

Wonik Robotics's Allegro Hand is based on licensed technology developed by the Humanoid Robot Hand research group at the Korea Institute of Industrial Technology (KITECH).

Any references to the BHand Library or the Allegro Hand Motion and/or Grasping Library refer to a library of humanoid robotic hand grasping algorithms and motions developed and published by KITECH researchers.
J.-H. Bae, S.-W. Park, D. Kim, M.-H. Baeg, and S.-R. Oh, "A Grasp Strategy with the Geometric Centroid of a Groped Object Shape Derived from Contact Spots," Proc. of the 2012 IEEE Int. Conf. on Robotics and Automation (ICRA2012), pp. 3798-3804

Wiki maintained by Sean Yi <seanyi@wonikrobotics.com>

KitechLogo.jpg Wonikrobotics logo.png





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