发表于:2009/2/24 8:39:45
#0楼
连接控制器代码
void crebot6vdlg::onbuttonconnectcontroller()
{
/**////连接运动控制器,并作初始化
///dcm2163 controller object
cdmcwin m_dmcwin;
cdmcwinregistry dmcwinregistry;
galilregistry galilregistry;
/**////判断运动控制器是否注册
if (dmcwinregistry.getgalilregistryinfo(m_ncontroller, &galilregistry) != 0)
{
//setdlgitemtext(idc_edit_sys_msg,请先使用dmc smart terminal软件正确设置dmc2163运动控制器!);
showinfo(请先使用dmc smart terminal软件正确设置dmc2163运动控制器!,icon_alert);
return;
}
if(galilregistry.fcontrollertype!=controllertypeethernet||strcmp(galilregistry.szmodel,dmc-21x3/2)!=0)
{
showinfo(请先使用dmc smart terminal软件正确设置dmc2163运动控制器!并且使用以太网通讯!,icon_alert);
// setdlgitemtext(idc_edit_sys_msg,请先使用dmc smart terminal软件正确设置dmc2163运动控制器!并且使用以太网通讯!);
return;
}
/**//// 初始化运动控制器,设置为在注册表中第一个运动控制器
m_dmcwin.setcontroller(m_ncontroller);
m_dmcwin.sethwnd(getsafehwnd());
/**//// 打开和dmc运动控制器间的连接
m_dmcwin.open();
cstring tempstring;
if(m_dmcwin.isconnected())
{
tempstring=已经连接: ;
if (m_dmcwin.getversion(szresponse, sizeof(szresponse)) == 0)
{
//setdlgitemtext(idc_edit_sys_msg,tempstring);
tempstring+=szresponse;
showinfo(tempstring,icon_info);
}
((cstatic *)getdlgitem(idc_static_comu_status))->seticon(afxgetapp()->loadicon(idi_icon_robot_ready));
}
else
{
/**//// 返回错误信息
m_dmcwin.geterrortext(m_dmcwin.getlasterror(),szresponse,sizeof(szresponse));
tempstring = 连接运动控制器失败: ;
tempstring += szresponse;
//setdlgitemtext(idc_edit_sys_msg,tempstring);
showinfo(tempstring,icon_error);
return;
}
getdlgitem(idc_button_calibrate)->enablewindow(true);
getdlgitem(idc_button_connect_controller)->enablewindow(false);
}
/**////获取运动控制状态线程
char *const command_get_axis_pos[18]={mg_tda\r,mg_lfa\r,mg_lra\r,
mg_tdb\r,mg_lfb\r,mg_lrb\r,
mg_tdc\r,mg_lfc\r,mg_lrc\r,
mg_tdd\r,mg_lfd\r,mg_lrd\r,
mg_tde\r,mg_lfe\r,mg_lre\r,
mg_tdf\r,mg_lff\r,mg_lrf\r
};
bool gbgetmotionstatusthreadrunning=true;
dword winapi threadproc_getmotionstatus( lpvoid pparam )
{
//t_axis *axisarray=(t_axis *)pparam;
long rc;
char szrepaly[4096];
int axisindex=0;
int errorokcount=0;
file *fdebug=fopen(d.txt,wt);
while(gbgetmotionstatusthreadrunning)
{
::waitforsingleobject(ghmutexvisit,infinite);//当ghmutexvisit变成有信号才返回,否则,一直等下去。
for(axisindex=0;axisindex6;axisindex++)
{
rc = m_dmcwin.command(command_get_axis_pos[3*axisindex],szrepaly,sizeof(szrepaly));
if (rc == dmcnoerror)
gcuraxispulse[axisindex]=atol(szrepaly);
else if (rc == dmcerror_timeout)
gdmctimeoutcount++;
rc = m_dmcwin.command(command_get_axis_pos[3*axisindex+1],szrepaly,sizeof(szrepaly));
if (rc == dmcnoerror)
gcuraxisforwardlimit[axisindex]=atoi(szrepaly);
else if (rc == dmcerror_timeout)
gdmctimeoutcount++;
rc = m_dmcwin.command(command_get_axis_pos[3*axisindex+2],szrepaly,sizeof(szrepaly));
if (rc == dmcnoerror)
gcuraxisbackwardlimit[axisindex]=atoi(szrepaly);
else if (rc == dmcerror_timeout)
gdmctimeoutcount++;
}
/**////rc = m_dmcwin.command(mg_bgs\r,szrepaly,sizeof(szrepaly));
if(gbmotionfinished==false)
{
errorokcount=0;
for(axisindex=0;axisindex6;axisindex++)
{
fprintf(fdebug,%d ,(int)(fabs(gcuraxispulse[axisindex]-gllimovegoalpulse[axisindex])));
if(fabs(gcuraxispulse[axisindex]-gllimovegoalpulse[axisindex])control_error_pulse)
errorokcount++;
}
if(errorokcount==6)
gbmotionfinished=true;
fprintf(fdebug,\n);
// lvectroerror+=(gcuraxispulse[axisindex]-gllimovegoalpulse[axisindex])*(gcuraxispulse[axisindex]-gllimovegoalpulse[axisindex]);
// fprintf(fdebug,%ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld\n,gcuraxispulse[0],gllimovegoalpulse[0],gcuraxispulse[1],gllimovegoalpulse[1],gcuraxispulse[2],gllimovegoalpulse[2],gcuraxispulse[3],gllimovegoalpulse[3],gcuraxispulse[4],gllimovegoalpulse[4],gcuraxispulse[5],gllimovegoalpulse[5],lvectroerror);
// if(lvectroerror// gbmotionfinished=true;
}
::releasemutex(ghmutexvisit);
sleep(20);
}
fclose(fdebug);
return 0; // thread completed successfully
}
从绝对编码器读取值。机器人零点位置标定
/**////机器人运行前必须至少进行一次标定操作!
void crebot6vdlg::onbuttoncalibrate()
{
/**////dmc运动控制器已经设置好
/**//* m_dmcwin.command(dmc_init_command_seq[0],szresponse,sizeof(szresponse));
m_dmcwin.command(dmc_init_command_seq[1],szresponse,sizeof(szresponse));
m_dmcwin.command(dmc_init_command_seq[2],szresponse,sizeof(szresponse));
m_dmcwin.command(dmc_init_command_seq[3],szresponse,sizeof(szresponse));
m_dmcwin.command(dmc_init_command_seq[4],szresponse,sizeof(szresponse));
m_dmcwin.command(dmc_init_command_seq[5],szresponse,sizeof(szresponse));
m_dmcwin.command(dmc_init_command_seq[6],szresponse,sizeof(szresponse));
m_dmcwin.command(dmc_init_command_seq[7],szresponse,sizeof(szresponse));
*/
/**////打开rs232c串口读取绝对编码器值
if(opencommport(com1,baudrate_19200)==false)
{
afxmessagebox(打开rs232c通讯端口失败! 标定没有完成!);
return;
}
int i;
long abspulse[6];
for(i=1;i6;i++)
{
if(readabspositonfromrs422(i,abspulse[i-1])!=rs422_noerror)
{
afxmessagebox(绝对编码器读取数据失败!);
closecommport();
return;
}
abspulse[i-1]=-abspulse[i-1];
sleep(50);
}
closecommport();
long rc;
//dpabs_1,abs_2,abs_3,abs_4,abs_5,abs_6
/**////将绝对编码器的值设置为当前运动控制器的规划值和目标值
sprintf(szcommandstr,dp%d,%d,%d,%d,%d,%d\r,abspulse[0],abspulse[1],abspulse[2],abspulse[3],abspulse[4],abspulse[5]);
m_dmcwin.command(szcommandstr,szresponse,sizeof(szresponse));
/**////for stepper mode,set tp pulse
sprintf(szcommandstr,de%d,%d,%d,%d,%d,%d\r,abspulse[0],abspulse[1],abspulse[2],abspulse[3],abspulse[4],abspulse[5]);
m_dmcwin.command(szcommandstr,szresponse,sizeof(szresponse));
/**////
///从配置文件读取较准原点坐标数据
file *fin=fopen(org_set_file_name,rt);
if(fin==null)
{
afxmessagebox(打开原点配置文件reorg.ini失败!\n\n请通过如下步骤执行原点校准:\n\n1.点动调整机器人各个轴位置到标定位置;\n2.点选隐含菜单--保存标定位置;\n3.退出控制程序,重新运行控制程序。);
showinfo(运行前必须对机器人绝对位置数据作校准!,icon_alert);
return;
}
int readcount=0;
readcount=fscanf(fin,%ld %ld %ld %ld %ld %ld,&abspulse[0],&abspulse[1],&abspulse[2],&abspulse[3],&abspulse[4],&abspulse[5]);
if(readcount!=6)
{
afxmessagebox(打开原点配置文件reorg.ini失败!\n\n请通过如下步骤执行原点校准:\n\n1.点动调整机器人各个轴位置到标定位置;\n2.点选隐含菜单--保存标定位置;\n3.退出控制程序,重新运行控制程序。);
showinfo(运行前必须对机器人绝对位置数据作校准!,icon_alert);
enablejogbuttons(true);
fclose(fin);
return;
}
fclose(fin);
abs_axis_home_pulse[0]=abspulse[0];abs_axis_home_pulse[1]=abspulse[1];abs_axis_home_pulse[2]=abspulse[2];
abs_axis_home_pulse[3]=abspulse[3];abs_axis_home_pulse[4]=abspulse[4];abs_axis_home_pulse[5]=abspulse[5];
if(messagebox(机器人将依次运动r,u,l,s,t,b六个轴到达标定零点位姿。\n\n在运动过程中请确保所有人员远离机器人作业范围!\n\n如果机器人运动过程不正常请立刻按下急停按钮!\n\n\n确认机器人可以安全动作了吗?,
机器人回标定零点,mb_yesno|mb_iconquestion)==idyes)
{
sprintf(szcommandstr,pa%ld,%ld,%ld,%ld,%ld,%ld\r,abs_axis_home_pulse[0],abs_axis_home_pulse[1],abs_axis_home_pulse[2],abs_axis_home_pulse[3],abs_axis_home_pulse[4],abs_axis_home_pulse[5]);
m_dmcwin.command(szcommandstr,szresponse,sizeof(szresponse));
sprintf(szcommandstr,sp20000,30000,30000,50000,50000,50000\r);
m_dmcwin.command(szcommandstr,szresponse,sizeof(szresponse));
sprintf(szcommandstr,ac100000,100000,100000,100000,100000,100000\r);
m_dmcwin.command(szcommandstr,szresponse,sizeof(szresponse));
sprintf(szcommandstr,dc100000,100000,100000,100000,100000,100000\r);
m_dmcwin.command(szcommandstr,szresponse,sizeof(szresponse));
for(i=3;i>=0;i--)
{
m_dmcwin.command(axis_by_axis_move_command[i],szresponse,sizeof(szresponse));
/**////wait motion complete
while(1)
{
rc=m_dmcwin.command(axis_by_axis_move_command[i+6],szresponse,sizeof(szresponse));
//if(atoi(szresponse)==0)
// break;
//if(szresponse[0]==0)
// break;
if (rc == dmcnoerror)
{
if(atoi(szresponse)==0)
break;
}
else if (rc == dmcerror_timeout)
gdmctimeoutcount++;
}
}
for(i=4;i5;i++)
{
m_dmcwin.command(axis_by_axis_move_command[i],szresponse,sizeof(szresponse));
/**////wait motion complete
while(1)
{
rc=m_dmcwin.command(axis_by_axis_move_command[i+6],szresponse,sizeof(szresponse));
//if(atoi(szresponse)==0)
// break;
//if(szresponse[0]==0)
// break;
if (rc == dmcnoerror)
{
if(atoi(szresponse)==0)
break;
}
else if (rc == dmcerror_timeout)
gdmctimeoutcount++;
}
}
if(messagebox(请确认机器人s,l,u,r,b,t,六个轴准确到达标定零点位姿?,询问,mb_yesno|mb_iconquestion)==idyes)
{
showinfo(机器人完成标定检查过程,现在可以正常操作机器人。,icon_ok);
for(i=0;i6;i++)
{
sprintf(szcommandstr,fl%c=%ld;bl%c=%ld;\r, (char)(a+i),(long)(abs_axis_home_pulse[i]+gsoftlimitdegree[2*i+1]*gpulseperdegree[i]),(char)(a+i),(long)(abs_axis_home_pulse[i]+gsoftlimitdegree[2*i]*gpulseperdegree[i]));
m_dmcwin.command(szcommandstr,szresponse,sizeof(szresponse));
}
}
else
{
afxmessagebox(机器人绝对原点标定数据不正确!\n\n请通过如下步骤执行原点校准:\n\n1.点动调整机器人各个轴位置到标定位置;\n2.点选隐含菜单--保存标定位置;\n3.退出控制程序,重新运行控制程序。);
showinfo(运行前必须对机器人绝对位置数据作校准!,icon_alert);
m_dmcwin.clear();
m_dmcwin.close();
return;
}
}
else
{
m_dmcwin.clear();
//m_dmcwin.close();
return;
}
getdlgitem(idc_button_calibrate)->enablewindow(false);
getdlgitem(idc_button_go_stop_position)->enablewindow(true);
enablemotionbuttons(true);
enablejogbuttons(true);
/**////resume the thread
if(m_getstatusthreadhandle!=null)
resumethread(m_getstatusthreadhandle);
settimer(1,150,null);
}
----------------------------------------------
此篇文章从博客转发
原文地址: Http://blog.gkong.com/more.asp?id=78069&Name=yta6020520
void crebot6vdlg::onbuttonconnectcontroller()
{
/**////连接运动控制器,并作初始化
///dcm2163 controller object
cdmcwin m_dmcwin;
cdmcwinregistry dmcwinregistry;
galilregistry galilregistry;
/**////判断运动控制器是否注册
if (dmcwinregistry.getgalilregistryinfo(m_ncontroller, &galilregistry) != 0)
{
//setdlgitemtext(idc_edit_sys_msg,请先使用dmc smart terminal软件正确设置dmc2163运动控制器!);
showinfo(请先使用dmc smart terminal软件正确设置dmc2163运动控制器!,icon_alert);
return;
}
if(galilregistry.fcontrollertype!=controllertypeethernet||strcmp(galilregistry.szmodel,dmc-21x3/2)!=0)
{
showinfo(请先使用dmc smart terminal软件正确设置dmc2163运动控制器!并且使用以太网通讯!,icon_alert);
// setdlgitemtext(idc_edit_sys_msg,请先使用dmc smart terminal软件正确设置dmc2163运动控制器!并且使用以太网通讯!);
return;
}
/**//// 初始化运动控制器,设置为在注册表中第一个运动控制器
m_dmcwin.setcontroller(m_ncontroller);
m_dmcwin.sethwnd(getsafehwnd());
/**//// 打开和dmc运动控制器间的连接
m_dmcwin.open();
cstring tempstring;
if(m_dmcwin.isconnected())
{
tempstring=已经连接: ;
if (m_dmcwin.getversion(szresponse, sizeof(szresponse)) == 0)
{
//setdlgitemtext(idc_edit_sys_msg,tempstring);
tempstring+=szresponse;
showinfo(tempstring,icon_info);
}
((cstatic *)getdlgitem(idc_static_comu_status))->seticon(afxgetapp()->loadicon(idi_icon_robot_ready));
}
else
{
/**//// 返回错误信息
m_dmcwin.geterrortext(m_dmcwin.getlasterror(),szresponse,sizeof(szresponse));
tempstring = 连接运动控制器失败: ;
tempstring += szresponse;
//setdlgitemtext(idc_edit_sys_msg,tempstring);
showinfo(tempstring,icon_error);
return;
}
getdlgitem(idc_button_calibrate)->enablewindow(true);
getdlgitem(idc_button_connect_controller)->enablewindow(false);
}
/**////获取运动控制状态线程
char *const command_get_axis_pos[18]={mg_tda\r,mg_lfa\r,mg_lra\r,
mg_tdb\r,mg_lfb\r,mg_lrb\r,
mg_tdc\r,mg_lfc\r,mg_lrc\r,
mg_tdd\r,mg_lfd\r,mg_lrd\r,
mg_tde\r,mg_lfe\r,mg_lre\r,
mg_tdf\r,mg_lff\r,mg_lrf\r
};
bool gbgetmotionstatusthreadrunning=true;
dword winapi threadproc_getmotionstatus( lpvoid pparam )
{
//t_axis *axisarray=(t_axis *)pparam;
long rc;
char szrepaly[4096];
int axisindex=0;
int errorokcount=0;
file *fdebug=fopen(d.txt,wt);
while(gbgetmotionstatusthreadrunning)
{
::waitforsingleobject(ghmutexvisit,infinite);//当ghmutexvisit变成有信号才返回,否则,一直等下去。
for(axisindex=0;axisindex6;axisindex++)
{
rc = m_dmcwin.command(command_get_axis_pos[3*axisindex],szrepaly,sizeof(szrepaly));
if (rc == dmcnoerror)
gcuraxispulse[axisindex]=atol(szrepaly);
else if (rc == dmcerror_timeout)
gdmctimeoutcount++;
rc = m_dmcwin.command(command_get_axis_pos[3*axisindex+1],szrepaly,sizeof(szrepaly));
if (rc == dmcnoerror)
gcuraxisforwardlimit[axisindex]=atoi(szrepaly);
else if (rc == dmcerror_timeout)
gdmctimeoutcount++;
rc = m_dmcwin.command(command_get_axis_pos[3*axisindex+2],szrepaly,sizeof(szrepaly));
if (rc == dmcnoerror)
gcuraxisbackwardlimit[axisindex]=atoi(szrepaly);
else if (rc == dmcerror_timeout)
gdmctimeoutcount++;
}
/**////rc = m_dmcwin.command(mg_bgs\r,szrepaly,sizeof(szrepaly));
if(gbmotionfinished==false)
{
errorokcount=0;
for(axisindex=0;axisindex6;axisindex++)
{
fprintf(fdebug,%d ,(int)(fabs(gcuraxispulse[axisindex]-gllimovegoalpulse[axisindex])));
if(fabs(gcuraxispulse[axisindex]-gllimovegoalpulse[axisindex])control_error_pulse)
errorokcount++;
}
if(errorokcount==6)
gbmotionfinished=true;
fprintf(fdebug,\n);
// lvectroerror+=(gcuraxispulse[axisindex]-gllimovegoalpulse[axisindex])*(gcuraxispulse[axisindex]-gllimovegoalpulse[axisindex]);
// fprintf(fdebug,%ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld\n,gcuraxispulse[0],gllimovegoalpulse[0],gcuraxispulse[1],gllimovegoalpulse[1],gcuraxispulse[2],gllimovegoalpulse[2],gcuraxispulse[3],gllimovegoalpulse[3],gcuraxispulse[4],gllimovegoalpulse[4],gcuraxispulse[5],gllimovegoalpulse[5],lvectroerror);
// if(lvectroerror// gbmotionfinished=true;
}
::releasemutex(ghmutexvisit);
sleep(20);
}
fclose(fdebug);
return 0; // thread completed successfully
}
从绝对编码器读取值。机器人零点位置标定
/**////机器人运行前必须至少进行一次标定操作!
void crebot6vdlg::onbuttoncalibrate()
{
/**////dmc运动控制器已经设置好
/**//* m_dmcwin.command(dmc_init_command_seq[0],szresponse,sizeof(szresponse));
m_dmcwin.command(dmc_init_command_seq[1],szresponse,sizeof(szresponse));
m_dmcwin.command(dmc_init_command_seq[2],szresponse,sizeof(szresponse));
m_dmcwin.command(dmc_init_command_seq[3],szresponse,sizeof(szresponse));
m_dmcwin.command(dmc_init_command_seq[4],szresponse,sizeof(szresponse));
m_dmcwin.command(dmc_init_command_seq[5],szresponse,sizeof(szresponse));
m_dmcwin.command(dmc_init_command_seq[6],szresponse,sizeof(szresponse));
m_dmcwin.command(dmc_init_command_seq[7],szresponse,sizeof(szresponse));
*/
/**////打开rs232c串口读取绝对编码器值
if(opencommport(com1,baudrate_19200)==false)
{
afxmessagebox(打开rs232c通讯端口失败! 标定没有完成!);
return;
}
int i;
long abspulse[6];
for(i=1;i6;i++)
{
if(readabspositonfromrs422(i,abspulse[i-1])!=rs422_noerror)
{
afxmessagebox(绝对编码器读取数据失败!);
closecommport();
return;
}
abspulse[i-1]=-abspulse[i-1];
sleep(50);
}
closecommport();
long rc;
//dpabs_1,abs_2,abs_3,abs_4,abs_5,abs_6
/**////将绝对编码器的值设置为当前运动控制器的规划值和目标值
sprintf(szcommandstr,dp%d,%d,%d,%d,%d,%d\r,abspulse[0],abspulse[1],abspulse[2],abspulse[3],abspulse[4],abspulse[5]);
m_dmcwin.command(szcommandstr,szresponse,sizeof(szresponse));
/**////for stepper mode,set tp pulse
sprintf(szcommandstr,de%d,%d,%d,%d,%d,%d\r,abspulse[0],abspulse[1],abspulse[2],abspulse[3],abspulse[4],abspulse[5]);
m_dmcwin.command(szcommandstr,szresponse,sizeof(szresponse));
/**////
///从配置文件读取较准原点坐标数据
file *fin=fopen(org_set_file_name,rt);
if(fin==null)
{
afxmessagebox(打开原点配置文件reorg.ini失败!\n\n请通过如下步骤执行原点校准:\n\n1.点动调整机器人各个轴位置到标定位置;\n2.点选隐含菜单--保存标定位置;\n3.退出控制程序,重新运行控制程序。);
showinfo(运行前必须对机器人绝对位置数据作校准!,icon_alert);
return;
}
int readcount=0;
readcount=fscanf(fin,%ld %ld %ld %ld %ld %ld,&abspulse[0],&abspulse[1],&abspulse[2],&abspulse[3],&abspulse[4],&abspulse[5]);
if(readcount!=6)
{
afxmessagebox(打开原点配置文件reorg.ini失败!\n\n请通过如下步骤执行原点校准:\n\n1.点动调整机器人各个轴位置到标定位置;\n2.点选隐含菜单--保存标定位置;\n3.退出控制程序,重新运行控制程序。);
showinfo(运行前必须对机器人绝对位置数据作校准!,icon_alert);
enablejogbuttons(true);
fclose(fin);
return;
}
fclose(fin);
abs_axis_home_pulse[0]=abspulse[0];abs_axis_home_pulse[1]=abspulse[1];abs_axis_home_pulse[2]=abspulse[2];
abs_axis_home_pulse[3]=abspulse[3];abs_axis_home_pulse[4]=abspulse[4];abs_axis_home_pulse[5]=abspulse[5];
if(messagebox(机器人将依次运动r,u,l,s,t,b六个轴到达标定零点位姿。\n\n在运动过程中请确保所有人员远离机器人作业范围!\n\n如果机器人运动过程不正常请立刻按下急停按钮!\n\n\n确认机器人可以安全动作了吗?,
机器人回标定零点,mb_yesno|mb_iconquestion)==idyes)
{
sprintf(szcommandstr,pa%ld,%ld,%ld,%ld,%ld,%ld\r,abs_axis_home_pulse[0],abs_axis_home_pulse[1],abs_axis_home_pulse[2],abs_axis_home_pulse[3],abs_axis_home_pulse[4],abs_axis_home_pulse[5]);
m_dmcwin.command(szcommandstr,szresponse,sizeof(szresponse));
sprintf(szcommandstr,sp20000,30000,30000,50000,50000,50000\r);
m_dmcwin.command(szcommandstr,szresponse,sizeof(szresponse));
sprintf(szcommandstr,ac100000,100000,100000,100000,100000,100000\r);
m_dmcwin.command(szcommandstr,szresponse,sizeof(szresponse));
sprintf(szcommandstr,dc100000,100000,100000,100000,100000,100000\r);
m_dmcwin.command(szcommandstr,szresponse,sizeof(szresponse));
for(i=3;i>=0;i--)
{
m_dmcwin.command(axis_by_axis_move_command[i],szresponse,sizeof(szresponse));
/**////wait motion complete
while(1)
{
rc=m_dmcwin.command(axis_by_axis_move_command[i+6],szresponse,sizeof(szresponse));
//if(atoi(szresponse)==0)
// break;
//if(szresponse[0]==0)
// break;
if (rc == dmcnoerror)
{
if(atoi(szresponse)==0)
break;
}
else if (rc == dmcerror_timeout)
gdmctimeoutcount++;
}
}
for(i=4;i5;i++)
{
m_dmcwin.command(axis_by_axis_move_command[i],szresponse,sizeof(szresponse));
/**////wait motion complete
while(1)
{
rc=m_dmcwin.command(axis_by_axis_move_command[i+6],szresponse,sizeof(szresponse));
//if(atoi(szresponse)==0)
// break;
//if(szresponse[0]==0)
// break;
if (rc == dmcnoerror)
{
if(atoi(szresponse)==0)
break;
}
else if (rc == dmcerror_timeout)
gdmctimeoutcount++;
}
}
if(messagebox(请确认机器人s,l,u,r,b,t,六个轴准确到达标定零点位姿?,询问,mb_yesno|mb_iconquestion)==idyes)
{
showinfo(机器人完成标定检查过程,现在可以正常操作机器人。,icon_ok);
for(i=0;i6;i++)
{
sprintf(szcommandstr,fl%c=%ld;bl%c=%ld;\r, (char)(a+i),(long)(abs_axis_home_pulse[i]+gsoftlimitdegree[2*i+1]*gpulseperdegree[i]),(char)(a+i),(long)(abs_axis_home_pulse[i]+gsoftlimitdegree[2*i]*gpulseperdegree[i]));
m_dmcwin.command(szcommandstr,szresponse,sizeof(szresponse));
}
}
else
{
afxmessagebox(机器人绝对原点标定数据不正确!\n\n请通过如下步骤执行原点校准:\n\n1.点动调整机器人各个轴位置到标定位置;\n2.点选隐含菜单--保存标定位置;\n3.退出控制程序,重新运行控制程序。);
showinfo(运行前必须对机器人绝对位置数据作校准!,icon_alert);
m_dmcwin.clear();
m_dmcwin.close();
return;
}
}
else
{
m_dmcwin.clear();
//m_dmcwin.close();
return;
}
getdlgitem(idc_button_calibrate)->enablewindow(false);
getdlgitem(idc_button_go_stop_position)->enablewindow(true);
enablemotionbuttons(true);
enablejogbuttons(true);
/**////resume the thread
if(m_getstatusthreadhandle!=null)
resumethread(m_getstatusthreadhandle);
settimer(1,150,null);
}
----------------------------------------------
此篇文章从博客转发
原文地址: Http://blog.gkong.com/more.asp?id=78069&Name=yta6020520