如果通过传感器(例如力sensor固定安装在工件底部)获得的是参考机器人BASE坐标系方向的力,可以通过以下函数将力和扭矩转化到当前工具TCP末端。
如果通过传感器(例如力sensor安装机器人末端工具上)获得的是参考机器人TCP坐标系方向的力,可以通过以下函数将力和扭矩转化到参考BASE坐标系。
function Force_Tool2Base(ForceInTool) Curr_pose = get_robot_pose() -- 获取当前机器人末端位姿(主要使用姿态数据) ForceTmp = {ForceInTool[1], ForceInTool[2], ForceInTool[3], 0, 0, 0} TorqueTmp = {ForceInTool[4], ForceInTool[5], ForceInTool[6], 0, 0, 0} Trans1 = {0, 0, 0, Curr_pose[4], Curr_pose[5], Curr_pose[6]} ForceTmp2 = pose_mul(Trans1, ForceTmp) TorqueTmp2 = pose_mul(Trans1, TorqueTmp) ForceInBase = {ForceTmp2[1], ForceTmp2[2], ForceTmp2[3], TorqueTmp2[1], TorqueTmp2[2], TorqueTmp2[3]} return ForceInBase end function Force_Base2Tool(ForceInBase) Curr_pose = get_robot_pose() -- 获取当前机器人末端位姿(主要使用姿态数据) ForceTmp = {ForceInBase[1], ForceInBase[2], ForceInBase[3], 0, 0, 0} TorqueTmp = {ForceInBase[4], ForceInBase[5], ForceInBase[6], 0, 0, 0} Trans1 = {0, 0, 0, Curr_pose[4], Curr_pose[5], Curr_pose[6]} ForceTmp2 = pose_mul(pose_inv(Trans1), ForceTmp) TorqueTmp2 = pose_mul(pose_inv(Trans1), TorqueTmp) ForceInTool = {ForceTmp2[1], ForceTmp2[2], ForceTmp2[3], TorqueTmp2[1], TorqueTmp2[2], TorqueTmp2[3]} return ForceInTool end