Contents

CAN Communication

Baud-Rate

The CAN communication baud-rate is 1Mbps.

Non-Periodic Communication

Messages can be sent to initialize or stop CAN communication.

Periodic Communication

The Allegro Hand control software attempts to communicate with the real or simulated hand at a regular control interval. Every 3 milliseconds, the joint torques are calculated and the joint angles are updated.

CAN Frames

Standard CAN Packet

The standard CAN packet used for communication is 14 bytes including 8 bytes of data.

typedef struct{ 
	unsigned char STD_EXT;            //type of message (Standard or Extended)
	unsigned long msg_id;		//message identifier 
	unsigned char data_length;	// 
	char           data[8];		// data array 
} can_msg;

ID (Message Identifier)

The 4 byte integer CAN message identifier (msg_id) is split into the command ID (26 bits), destination ID (3 bits) and source ID (3 bits).

1 8 16 24 26 27 29 30 32
Command ID Dest. ID Source ID


Command Identifiers

Variable Name Value Description Destination Source
ID_CMD_SET_SYSTEM_ON 0x01 Start periodic communication ID_COMMON ID_DEVICE_MAIN
ID_CMD_SET_SYSTEM_OFF 0x02 Stop periodic communication ID_COMMON ID_DEVICE_MAIN
ID_CMD_SET_PERIOD 0x03 Set communication frequency ID_COMMON ID_DEVICE_MAIN
ID_CMD_SET_MODE_JOINT 0x04 Command Transmission Mode ID_COMMON ID_DEVICE_MAIN
ID_CMD_SET_MODE_TASK 0x05 Command Transmission Mode ID_COMMON ID_DEVICE_MAIN
ID_CMD_SET_TORQUE_1 0x06 Index finger (1) torque command ID_COMMON ID_DEVICE_MAIN
ID_CMD_SET_TORQUE_2 0x07 Middle finger (2) torque command ID_COMMON ID_DEVICE_MAIN
ID_CMD_SET_TORQUE_3 0x08 Pinky finger (3) torque command ID_COMMON ID_DEVICE_MAIN
ID_CMD_SET_TORQUE_4 0x09 Thumb torque command ID_COMMON ID_DEVICE_MAIN
ID_CMD_SET_POSITION_1 0x0a (unused) ID_COMMON ID_DEVICE_MAIN
ID_CMD_SET_POSITION_2 0x0b (unused) ID_COMMON ID_DEVICE_MAIN
ID_CMD_SET_POSITION_3 0x0c (unused) ID_COMMON ID_DEVICE_MAIN
ID_CMD_SET_POSITION_4 0x0d (unused) ID_COMMON ID_DEVICE_MAIN
ID_CMD_QUERY_STATE_DATA 0x0e Request joint state ID_COMMON ID_DEVICE_MAIN
ID_CMD_QUERY_STATE_DATA 0x0e Joint state response ID_DEVICE_MAIN ID_DEVICE_SUB_01
ID_DEVICE_SUB_02
ID_DEVICE_SUB_03
ID_DEVICE_SUB_04
ID_CMD_QUERY_CONTROL_DATA 0x0f Joint state response ID_DEVICE_MAIN ID_DEVICE_SUB_01
ID_DEVICE_SUB_02
ID_DEVICE_SUB_03
ID_DEVICE_SUB_04


Source and Destination Identifiers

Variable Name Value Description
ID_COMMON 0x01 Allegro Hand
ID_DEVICE_MAIN 0x02 Control PC
ID_DEVICE_SUB_01 0x03 Index Finger
ID_DEVICE_SUB_02 0x04 Middle Finger
ID_DEVICE_SUB_03 0x05 Little Finger
ID_DEVICE_SUB_04 0x06 Thumb


Case-study: Softing CAN

In this chapter, sample code demonstrating the implementation of the CAN communication interface is provide. This is the foundation for Softing PCI CAN.

Opening the CAN Communication Channel

char ch_name[256]; 
sprintf_s(ch_name, 256, "CAN-ACx-PCI_%d", ch); 
INIL2_initialize_channel(&hCAN[ch-1], ch_name); 
 
L2CONFIG L2Config; 
L2Config.fBaudrate = 1000.0; 
L2Config.bEnableAck = 0; 
L2Config.bEnableErrorframe = 0; 
L2Config.s32AccCodeStd = 0; 
L2Config.s32AccMaskStd = 0; 
L2Config.s32AccCodeXtd = 0; 
L2Config.s32AccMaskXtd = 0; 
L2Config.s32OutputCtrl = GET_FROM_SCIM; 
L2Config.s32Prescaler = 1; 
L2Config.s32Sam = 0; 
L2Config.s32Sjw = 1; 
L2Config.s32Tseg1 = 4; 
L2Config.s32Tseg2 = 3; 
L2Config.hEvent = (void*)-1; 
 
CANL2_initialize_fifo_mode(hCAN[ch-1], &L2Config);

CAN Initialization

long Txid; 
unsigned char data[8]; 
 
Txid = ((unsigned long)ID_CMD_SET_PERIOD<<6) | ((unsigned long)ID_COMMON <<3) | ((unsigned long)ID_DEVICE_MAIN); 
data[0] = (unsigned char)period_msec; 
canWrite(hCAN, Txid, data, 1, STD); 
 
Sleep(10); 
 
Txid = ((unsigned long)ID_CMD_SET_MODE_TASK<<6) | ((unsigned long)ID_COMMON <<3) | ((unsigned long)ID_DEVICE_MAIN); 
canWrite(hCAN, Txid, data, 0, STD); 
 
Sleep(10); 
 
Txid = ((unsigned long)ID_CMD_QUERY_STATE_DATA<<6) | ((unsigned long)ID_COMMON <<3) | ((unsigned long)ID_DEVICE_MAIN); 
canWrite(hCAN, Txid, data, 0, STD);

Starting Periodic CAN Communication

When you start periodic CAN communication, joint angles are automatically updated according to the torque control input.

long Txid; 
unsigned char data[8]; 
 
Txid = ((unsigned long)ID_CMD_QUERY_STATE_DATA<<6) | ((unsigned long)ID_COMMON <<3) | ((unsigned long)ID_DEVICE_MAIN); 
canWrite(hCAN[ch-1], Txid, data, 0, STD); 
 
Sleep(10); 
 
Txid = ((unsigned long)ID_CMD_SET_SYSTEM_ON<<6) | ((unsigned long)ID_COMMON <<3) | ((unsigned long)ID_DEVICE_MAIN); 
canWrite(hCAN[ch-1], Txid, data, 0, STD);

Stopping Periodic CAN Communication

long Txid; 
unsigned char data[8]; 
 
Txid = ((unsigned long)ID_CMD_SET_SYSTEM_OFF<<6) | ((unsigned long)ID_COMMON <<3) | ((unsigned long)ID_DEVICE_MAIN); 
canWrite(hCAN[ch-1], Txid, data, 0, STD);

Transmitting Control Torques

Control inputs for the four joints in each finger should be packed in a single CAN frame. The sample code below demontrates how to encode four PWM inputs into an 8 byte data buffer and how to set the CAN frame ID properly.

Note: PWM = Desired_Torque (N-m) * 800.0.
800.0 is an empirical constant that will convert torque to PWM.

As seen below, torque2pwm = 800.0


Note: The joint index order used in the following code is for Allegro Hand versions 2.0 and up. For Allegro hand 1.0 or earlier, see the code snippet after this one.

long Txid; 
unsigned char data[8]; 
float torque2pwm = 800.0f 
short pwm[4] = { 
	0.1*torque2pwm, 
	0.1*torque2pwm, 
	0.1*torque2pwm, 
	0.1*torque2pwm 
}; 
 
// This joint index order is used Allegro Hand versions 2.0 and up.
if (findex >= 0 && findex < 4) 
{ 
	data[0] = (unsigned char)( (pwm[3] >> 8) & 0x00ff); 
	data[1] = (unsigned char)(pwm[3] & 0x00ff); 
 
	data[2] = (unsigned char)( (pwm[2] >> 8) & 0x00ff); 
	data[3] = (unsigned char)(pwm[2] & 0x00ff); 
 
	data[4] = (unsigned char)( (pwm[1] >> 8) & 0x00ff); 
	data[5] = (unsigned char)(pwm[1] & 0x00ff); 
 
	data[6] = (unsigned char)( (pwm[0] >> 8) & 0x00ff); 
	data[7] = (unsigned char)(pwm[0] & 0x00ff); 
 
	Txid = ((unsigned long)(ID_CMD_SET_TORQUE_1 + findex)<<6) | ((unsigned long)ID_COMMON <<3) | ((unsigned long)ID_DEVICE_MAIN); 
	canWrite(hCAN, Txid, data, 8, STD); 
}


Note: The joint index order used in the following code is for Allegro Hand versions 1.0 and down. For Allegro hand 2.0 or later, see the code snippet before this one.

// This joint index order is used Allegro Hand versions 1.0 and down.
if (findex >= 0 && findex < 4) 
{ 
	data[0] = (unsigned char)( (pwm[0] >> 8) & 0x00ff); 
	data[1] = (unsigned char)(pwm[0] & 0x00ff); 
 
	data[2] = (unsigned char)( (pwm[1] >> 8) & 0x00ff); 
	data[3] = (unsigned char)(pwm[1] & 0x00ff); 
 
	data[4] = (unsigned char)( (pwm[2] >> 8) & 0x00ff); 
	data[5] = (unsigned char)(pwm[2] & 0x00ff); 
 
	data[6] = (unsigned char)( (pwm[3] >> 8) & 0x00ff); 
	data[7] = (unsigned char)(pwm[3] & 0x00ff); 
 
	Txid = ((unsigned long)(ID_CMD_SET_TORQUE_1 + findex)<<6) | ((unsigned long)ID_COMMON <<3) | ((unsigned long)ID_DEVICE_MAIN); 
	canWrite(hCAN, Txid, data, 8, STD); 
}


Receiving Joint Angles

Each finger consists of four joints. The joint angles for those four joints can be received via one CAN packet. The sample code below demonstrates the method for decoding the data buffer and reading the joint angles.

The sample code assumes that when fingers are in their zero positions, the joint angles from the can packet are 32768. In practice, users should perform experiments and introduce offsets to obtain the zero position.

char cmd; 
char src; 
char des; 
int len; 
unsigned char data[8]; 
int ret; 
can_msg msg; 
PARAM_STRUCT param; 
 
ret = CANL2_read_ac(hCAN, &param); 
 
switch (ret) 
{ 
case CANL2_RA_DATAFRAME: 
	msg.msg_id = param.Ident; 
	msg.STD_EXT = STD; 
	msg.data_length = param.DataLength; 
 
	msg.data[0] = param.RCV_data[0]; 
	msg.data[1] = param.RCV_data[1]; 
	msg.data[2] = param.RCV_data[2]; 
	msg.data[3] = param.RCV_data[3]; 
	msg.data[4] = param.RCV_data[4]; 
	msg.data[5] = param.RCV_data[5]; 
	msg.data[6] = param.RCV_data[6]; 
	msg.data[7] = param.RCV_data[7]; 
 
	break; 
} 
 
cmd = (char)( (msg.msg_id >> 6) & 0x1f ); 
des = (char)( (msg.msg_id >> 3) & 0x07 ); 
src = (char)( msg.msg_id & 0x07 ); 
len = (int)( msg.data_length ); 
for(int nd=0; nd<len; nd++) 
	data[nd] = msg.data[nd]; 
 
switch (cmd) 
{ 
case ID_CMD_QUERY_CONTROL_DATA: 
	{
		if (id_src >= ID_DEVICE_SUB_01 && id_src <= ID_DEVICE_SUB_04) 
		{ 
			int temp_pos[4]; // raw angle data 
			float ang[4]; // degree 
			float q[4]; // radian 
 
			temp_pos[0] = (int)(data[0] | (data[1] << 8)); 
			temp_pos[1] = (int)(data[2] | (data[3] << 8)); 
			temp_pos[2] = (int)(data[4] | (data[5] << 8)); 
			temp_pos[3] = (int)(data[6] | (data[7] << 8)); 
 
			ang[0] = ((float)(temp_pos[0]-32768)*(333.3f/65536.0f))*(1); 
			ang[1] = ((float)(temp_pos[1]-32768)*(333.3f/65536.0f))*(1); 
			ang[2] = ((float)(temp_pos[2]-32768)*(333.3f/65536.0f))*(1); 
			ang[3] = ((float)(temp_pos[3]-32768)*(333.3f/65536.0f))*(1); 
 
			q[0] = (3.141592f/180.0f) * ang[0]; 
			q[1] = (3.141592f/180.0f) * ang[1]; 
			q[2] = (3.141592f/180.0f) * ang[2]; 
			q[3] = (3.141592f/180.0f) * ang[3]; 
		} 
	} 
 
}

Download

Allegro Hand CAN Protocol (English) ----------- This page.
Allegro Hand CAN Protocol (Korean)





avatar

Anonymous user #1

10 days ago
Score 0+

https://www.adidasuk.uk.com/ Adidas UK https://www.jordan4.de/ Air Jordan 4 https://www.air-jordan1.us/ Air Jordan 1 https://www.air-jordan1.us/ Jordan 1 https://www.air-jordans.us/ Air Jordans https://www.air-jordans.us/ Nike Air Jordans https://www.jordans-1.us/ Jordans 1 https://www.jordans-1.us/ Air Jordan 1 https://www.nikejordan1.us/ Nike Jordan 1 https://www.nikejordan1.us/ Nike Jordan https://www.jordan-1s.us/ Jordan 1s https://www.jordan-1s.us/ Jordan 1 https://www.adidas-yeezy.org/ Adidas Yeezy https://www....website.com/ Adidas Yeezy https://www....website.com/ Yeezy https://www....inestore.us/ Adidas Yeezy https://www.adidasyeezys.com/ Adidas Yeezy https://www.adidasyeezys.org/ Adidas Yeezy https://www.adidasyeezys.org/ Yeezy Shoes https://www....y-shoes.com/ Adidas Yeezy https://www....y-shoes.com/ Yeezy Shoes https://www.air-jordan1.com/ Air Jordan 1 https://www.air-jordan11.com/ Air Jordan 11 https://www....an1-mid.com/ Air Jordan 1 Mid https://www.airjordan1s.us/ Air Jordan 1 https://www.airjordan1s.us/ Jordan 1 https://www.airjordan1s.us/ Jordan 1 https://www.air-jordan4.com/ Air Jordan 4 https://www....dans.us.org/ Air Jordans https://www.air-jordans1.com/ Air Jordan 1 https://www.air-jordans1.com/ Jordan 1 https://www....an-shoes.us/ Air Jordan Shoes https://www....an-shoes.us/ Air Jordan https://www.airsjordans.com/ Air Jordans https://www.aj1.us.com/ Jordan AJ 1 https://www.fakeyeezys.us/ Fake Yeezys https://www.jordan-1.co.uk/ Air Jordan 1 https://www.jordan-1.co.uk/ Jordan 1 https://www.jordan-1.de/ Jordan 1 https://www.jordan-1.org/ Jordan 1 https://www.jordan1.uk.com/ Jordan 1 https://www.jordan-11s.com/ Jordan 11 https://www.jordan-13.us/ Jordan 13 https://www.jordan1low.com/ Jordan 1 Low https://www.jordan1mid.co.uk/ Air Jordan 1 Mid https://www.jordan1mid.co.uk/ Jordan 1 Mid https://www.jordan1-mid.com/ Air Jordan 1 Mid https://www.jordan1-mid.com/ Jordan 1 Mid https://www.jordan1-mid.com/ Jordan 1 https://www.jordan-1s.com/ Jordan 1s https://www.jordan-4.co.uk/ Air Jordan 4 https://www.jordan-4.co.uk/ Jordan 4 https://www.jordan4.de/ Air Jordan 4 https://www.jordan4.de/ Jordan 4 https://www.jordan-4.us/ Air Jordan 4 https://www.jordan-4.us/ Jordan 4 https://www....aryblack.us/ Jordan https://www....aryblack.us/ Jordan 4 Military Black https://www.jordan-4s.us/ Jordan 4 https://www.jordan-4s.us/ Jordan 4s https://www.jordan-5.us/ Jordan 5 https://www.jordan-aj1.com/ Jordan 1 https://www.jordanaj1.com/ Jordan AJ 1 https://www.jordan-aj1.com/ Jordan AJ 1 https://www.jordanretro4.com/ Jordan Retro 4 https://www.jordans-11.com/ Jordan 11 https://www.jordans4s.com/ Jordans 4 https://www....hoes.us.com/ Jordan Shoes https://www.jordans-shoes.com/ Jordans Shoes https://www.jordansshoes.org/ Jordans Shoes https://www....nestore.com/ NFL Shop Official Online Store https://www....seys.us.com/ NFL Jerseys https://www....-jordan.com/ Nike Air Jordan https://www....vapormax.us/ Nike Air VaporMax https://www.nikejordan1.com/ Nike Jordan 1 https://www.nike-jordans.com/ Nike Jordans https://www.nikeoutlet.uk.com/ Nike Outlet https://www....factory.com/ Nike Outlet https://www....hopping.com/ Nike Outlet Store https://www....hopping.com/ Nike Outlet https://www....ping.us.com/ Nike Outlet Store Online Shopping https://www....ping.us.com/ Nike Outlet https://www.nikes-shoes.com/ Nike Shoes https://www.nikeuk.uk.com/ Nike UK https://www....flyknit.com/ Nike Vapormax Flyknit https://www.off-white.us.org/ Off White https://www....eshoess.com/ Off White Shoes https://www.pandoraa.org/ Pandora Jewelry https://www.pandoraa.org/ Pandora https://www....racelet.org/ Pandora Bracelet https://www....racelet.org/ Pandora Bracelets https://www....acelets.org/ Pandora Bracelets https://www....arms.uk.com/ Pandora Charms https://www....charmss.com/ Pandora Charms https://www....charmss.com/ Pandora Jewelry https://www....charmss.org/ Pandora Charms Sale Clearance https://www....charmss.org/ Pandora Charms https://www....ialsite.com/ Pandora Jewelry Official Site https://www....ialsite.com/ Pandora Jewelry https://www....ialsite.org/ Pandora Jewelry Official Site https://www....ewelrys.com/ Pandora Jewelry https://www....ewelrys.com/ Pandora https://www....ewelrys.org/ Pandora Jewelry Official Site https://www....ewelrys.org/ Pandora Jewelry https://www....lrys.us.com/ Pandora Jewelry Official Site Clearance https://www....lrys.us.com/ Pandora Jewelry https://www....jewelrys.us/ Pandora Jewelry https://www....ineshop.org/ Pandora Online Shop https://www....ineshop.org/ Pandora https://www.pandoraoutlet.org/ Pandora Outlet https://www.pandorauk.uk.com/ Pandora UK https://www.retro-jordan.com/ Retro Jordans https://www.supplyyeezys.us/ YEEZY SUPPLY https://www....jordan1.com/ Travis Scott Jordan 1 https://www.uncjordan1.us/ UNC Jordan 1 https://www.yeezy.uk.com/ Yeezy https://www.yeezy350.de/ Yeezy 350 https://www.yeezy350.uk.com/ Yeezy 350 https://www.yeezy350.uk.com/ Yeezy https://www.yeezy-350s.com/ Yeezy 350 https://www.yeezy-350s.com/ Yeezy Boost 350 https://www.yeezy350-v2.com/ Yeezy 350 V2 https://www.yeezy-450.com/ Yeezy 450 https://www.yeezy-700.us.com/ Yeezy 700 https://www.yeezyadidas.de/ Adidas yeezy https://www....-runner.com/ Yeezy Foam Runner https://www.yeezys-350.com/ Yeezy 350 https://www.yeezys500.com/ Yeezy 500 https://www.yeezys-700.com/ Yeezy 700 https://www....hoes.us.com/ Yeezy https://www....ides.uk.com/ Yeezy Slides https://www....ides.uk.com/ Yeezy https://www....ides.us.com/ Yeezy Slides https://www.yeezysslides.com/ Yeezy Slides https://www.yeezys-supply.com/ Yeezy Supply https://www.yeezy-supply.com/ Yeezy Supply https://www.yeezyv2.us.com/ Yeezy https://www.yeezyy.us/ Yeezy Shoes https://www.yeezyy.us/ Yeezy https://www.yeezy-zebra.com/ Yeezy Zebra https://www.jordans-shoes.com/ Jordan Shoes https://www.jordans-shoes.com/ Jordans

https://www.yeezy-slides.org/ Yeezy Slides
Add your comment
Allegro Hand welcomes all comments. If you do not want to be anonymous, register or log in. It is free.




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 1   Bots & Crawlers 0