校准机器人后,可通过以下两种方式应用校准参数::
●过滤现有程序:自动修正程序中所有目标点坐标以提升运动精度,支持手动操作或API调用
●离线编程生成优化程序:通过RoboDK生成的程序已内置校准参数(含API生成程序)。
要手动过滤现有程序:将机器人程序文件拖放到RoboDK的主屏幕上(或选择文件➔打开),然后选择仅过滤。程序将被过滤并保存在同一文件夹中。过滤摘要将提及过滤算法是否存在问题。如果你想在RoboDK中模拟程序,也可以选择导入程序。如果程序有任何依赖关系(工具坐标系或基本坐标系定义、子程序......),它们必须位于导入第一个程序的同一目录中。


将程序导入RoboDK后,你可以在有或没有绝对精度的情况下重新生成程序。在RoboDK的主要精度设置中(工具➔选项➔精度),你可以决定是否始终使用精确运动学生成程序,是否希望RoboDK每次都询问,或者是否希望使用当前的机器人运动学。右击机器人,激活/禁用标签:使用机器人运动学模型,即可更改当前机器人运动学。如果激活,则会看到一个绿点;如果未激活,则会看到一个红点。


在给机器人和机器人程序校准过的情况下,使用RoboDK可以通过调用FilterProgram过滤整个程序:
robot.FilterProgram(file_program)
在资源库的"宏"部分,有一个名为"过滤程序"(FilterProgram)的宏示例。以下代码是使用RoboDKAPI过滤程序的Python脚本示例。
fromrobolinkimport*#APItocommunicatewithRoboDK
fromrobodkimport*#basicmatrixoperations
importos#Pathoperations
#Getthecurrentworkingdirectory
CWD=os.path.dirname(os.path.realpath(__file__))
#StartRoboDKifitisnotrunningandlinktotheAPI
RDK=Robolink()
#optional:providethefollowingargumentstorunbehindthescenes
#RDK=Robolink(args='/NOSPLASH/NOSHOW/HIDDEN')
#Getthecalibratedstation(.rdkfile)orrobotfile(.robot):
#Tip:aftercalibration,rightclickarobotandselect"Saveas.robot"
calibration_file=CWD+'/KUKA-KR6.rdk'
#Gettheprogramfile:
file_program=CWD+'/Prog1.src'
#LoadtheRDKfileortherobotfile:
calib_item=RDK.AddFile(calibration_file)
ifnotcalib_item.Valid():
raiseException("Somethingwentwrongloading"+calibration_file)
#Retrievetherobot(nopopupifthereisonlyonerobot):
robot=RDK.ItemUserPick('Selectarobottofilter',ITEM_TYPE_ROBOT)
ifnotrobot.Valid():
raiseException("Robotnotselectedornotavailable")
#Activateaccuracy
robot.setAccuracyActive(1)
#Filterprogram:thiswillautomaticallysaveaprogramcopy
#witharenamedfiledependingontherobotbrand
status,summary=robot.FilterProgram(file_program)
ifstatus==0:
print("Programfilteringsucceeded")
print(summary)
calib_item.Delete()
RDK.CloseRoboDK()
else:
print("Programfilteringfailed!Errorcode:%i"%status)
print(summary)
RDK.ShowRoboDK()
以下代码是一个Python脚本示例,使用FilterTarget命令,利用RoboDKAPI过滤目标(位姿目标或关节目标):
pose_filt,joints=robot.FilterTarget(nominal_pose,estimated_joints)
如果第三方应用程序(RoboDK除外)使用位姿目标生成机器人程序,本示例将非常有用。
Note:如果程序是使用API自动生成的,则不需要这样做。
fromrobolinkimport*#APItocommunicatewithRoboDK
fromrobodkimport*#basicmatrixoperations
defXYZWPR_2_Pose(xyzwpr):
returnKUKA_2_Pose(xyzwpr)#ConvertX,Y,Z,A,B,Ctoapose
defPose_2_XYZWPR(pose):
returnPose_2_KUKA(pose)#ConvertaposetoX,Y,Z,A,B,C
#StarttheRoboDKAPIandretrievetherobot:
RDK=Robolink()
robot=RDK.Item('',ITEM_TYPE_ROBOT)
ifnotrobot.Valid():
raiseException("Robotnotavailable")
pose_tcp=XYZWPR_2_Pose([0,0,200,0,0,0])#DefinetheTCP
pose_ref=XYZWPR_2_Pose([400,0,0,0,0,0])#DefinetheRefFrame
#UpdatetherobotTCPandreferenceframe
robot.setTool(pose_tcp)
robot.setFrame(pose_ref)
#VeryimportantforSolveFKandSolveIK(Forward/Inversekinematics)
robot.setAccuracyActive(False)#AccuracycanbeONorOFF
#Defineanominaltargetinthejointspace:
joints=[0,0,90,0,90,0]
#Calculatethenominalrobotpositionforthejointtarget:
pose_rob=robot.SolveFK(joints)#robotflangewrttherobotbase
#Calculatepose_target:theTCPwithrespecttothereferenceframe
pose_target=invH(pose_ref)*pose_rob*pose_tcp
print('Targetnotfiltered:')
print(Pose_2_XYZWPR(pose_target))
joints_approx=joints#joints_approxmustbewithin20deg
pose_target_filt,real_joints=robot.FilterTarget(pose_target,joints)
print('Targetfiltered:')
print(real_joints.tolist())
print(Pose_2_XYZWPR(pose_target_filt))