机械臂主控通讯协议 v1 ========================================== 此版本将于 1.5 MAX 弃用 协议格式 +++++++++++++++++++++++++++++++++ “指令(数据)+分隔符+数据+分隔符+数据+分隔符+…+数据+分隔符+结束符” 发送和接收的数据格式如上所示,数据之间通过分隔符划分,最后以一个结束符来结尾。分隔符可以是英文逗号(',')或者空格(' '),结束符可以使'#'或者'\\n'。分隔符和结束符根据机械臂的特性可以灵活调整。 error_code判断 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ .. warning:: 机械臂主控时,机械臂运行程序必须要对接收的返回数据进行 error_code 的判断。如果不处理 error_code,机械臂会发生碰撞或者造成其他更严重的后果,威胁使用者的人身安全! 指令 ++++++++++++++++++++++++++ 1. 心跳信号(xyzHeartBeat) +------------+----------------+-------------------------+ | 机械臂发送 | “500,#” | 500: 机械臂ping工控机用 | +------------+----------------+-------------------------+ | 机械臂接收 | “error_code,#” | | +------------+----------------+-------------------------+ 2. 切换应用(xyzSwitchApp) +------------+------------------+---------------------------------------+ | 机械臂发送 | “501,app_name,#” | 501: 切换应用指令号 | | | +---------------------------------------+ | | | app_name(string): 需要切换到的app名字 | +------------+------------------+---------------------------------------+ | 机械臂接收 | “error_code,#” | | +------------+------------------+---------------------------------------+ 3. 切换flow(xyzSwitchFlow) +------------+-------------------+-------------------------------------------------------------------+ | 机械臂发送 | “502,flow_name,#” | 502: 切换task flow指令号 | | | +-------------------------------------------------------------------+ | | | flow_name(string): 需要切换到的task flow名称,以“.t”结尾,如“1.t” | +------------+-------------------+-------------------------------------------------------------------+ | 机械臂接收 | “error_code,#” | | +------------+-------------------+-------------------------------------------------------------------+ 4. 切换工具(xyzSwitchTool) +------------+----------------+-----------------------+ | 机械臂发送 | “503,tool,#” | 503: 切换工具指令号 | | | +-----------------------+ | | | tool(string): tool id | +------------+----------------+-----------------------+ | 机械臂接收 | “error_code,#” | | +------------+----------------+-----------------------+ 5. 请求拍照(xyzReqCapImg) +------------+---------------------------+-----------------------------------------------------+ | 机械臂发送 | “504,vision_service_id,#” | 504: 请求拍照指令号 | | | +-----------------------------------------------------+ | | | vision_service_id(int): 视觉service_id | +------------+---------------------------+-----------------------------------------------------+ | 机械臂接收 | “error_code,token,#” | token(int): 返回的用于请求对应拍照结果时使用的token | +------------+---------------------------+-----------------------------------------------------+ 6. 获取拍照结果(xyzGetCapImg) +------------+----------------+-----------------------------------+ | 机械臂发送 | “505,token,#” | 505: 获取拍照结果指令号 | | | +-----------------------------------+ | | | token(int): 请求拍照时返回的token | +------------+----------------+-----------------------------------+ | 机械臂接收 | “error_code,#” | | +------------+----------------+-----------------------------------+ 7. 拍照(xyzCapImg) +------------+---------------------------+----------------------------------------+ | 机械臂发送 | “506,vision_service_id,#” | 506: 拍照指令号 | | | +----------------------------------------+ | | | vision_service_id(int): 视觉service_id | +------------+---------------------------+----------------------------------------+ | 机械臂接收 | “error_code,#” | | +------------+---------------------------+----------------------------------------+ 8. 请求抓取目标点位(xyzReqGraspPose) +------------+----------------------+-------------------------------------------------+ | 机械臂发送 | “507,ws_id,#” | 507: 请求抓取目标点位指令号 | | | +-------------------------------------------------+ | | | ws_id(int): 需要获取抓取点位的工作空间id | +------------+----------------------+-------------------------------------------------+ | 机械臂接收 | “error_code,token,#” | token(int): 返回的用于获取目标点位时使用的token | +------------+----------------------+-------------------------------------------------+ 9. 获取抓取目标点位(xyzGetGraspPose) +------------+------------------------------------------------------------+-----------------------------------------------+ | 机械臂发送 | “508,token,#” | 508: 获取抓取目标点位指令号 | | | +-----------------------------------------------+ | | | token(int): 请求抓取目标点位时返回的token | +------------+------------------------------------------------------------+-----------------------------------------------+ | 机械臂接收 | “error_code,x,y,z,a,b,c,d,num,pipeline_num,register_num,#” | x,y,z,a,b,c,d: 为抓取目标点的位姿数据 | | | +-----------------------------------------------+ | | | num(int): 当前有多少个可供抓取的点 | | | +-----------------------------------------------+ | | | pipeline_num(int): pipeline文件number | | | +-----------------------------------------------+ | | | register_num(int): 用到的注册文件的注册number | +------------+------------------------------------------------------------+-----------------------------------------------+ 10. 请求物体位姿(xyzReqObjPose) +------------+----------------------+--------------------------------------------+ | 机械臂发送 | “509,ws_id,#” | 509: 请求物体位姿指令号 | | | +--------------------------------------------+ | | | ws_id(int):请求物体所在的空间id | +------------+----------------------+--------------------------------------------+ | 机械臂接收 | “error_code,token,#” | token(int):用于获取物体位姿时作为识别token | +------------+----------------------+--------------------------------------------+ 11. 获取物体位姿(xyzGetObjPose) +------------+--------------------------------------------+---------------------------------------+ | 机械臂发送 | “510,token,#” | 510: 获取物体位姿指令号 | | | +---------------------------------------+ | | | token(int) :请求物体位姿时得到的token | +------------+--------------------------------------------+---------------------------------------+ | 机械臂接收 | “error_code,x,y,z,a,b,c,d,num,pose_type,#” | x,y,z,a,b,c,d: 物体的位姿数据 | | | +---------------------------------------+ | | | num(int): 当前物体位姿个数 | | | +---------------------------------------+ | | | pose_type(int) :物体的位姿类型 | +------------+--------------------------------------------+---------------------------------------+ 12. 重置任务(xyzResetTask) +------------+----------------+----------------------------+ | 机器人发送 | “511,#” | 511: 重置任务指令号 | | | | | | | | 一般用来初始化任务内部变量 | +------------+----------------+----------------------------+ | 机器人接收 | “error_code,#“ | | +------------+----------------+----------------------------+ 13. 发送机械臂当前角度(xyzSendCurrentJoints) +------------+---------------------------+-----------------------------------------------------------+ | 机械臂发送 | “512,j1,j2,j3,j4,j5,j6,#” | 512: 发送机械臂当前角度指令号 | | | +-----------------------------------------------------------+ | | | j1~j6: 机械臂当前的角度信息 | | | +-----------------------------------------------------------+ | | | 如果机械臂轴数小于6轴,则需要对应位置补零,依旧发送六个数 | +------------+---------------------------+-----------------------------------------------------------+ | 机械臂接收 | “error_code,#” | | +------------+---------------------------+-----------------------------------------------------------+ 14. 发送机械臂当前Cartesian(xyzSendCurrentCartPose) +------------+-----------------------+-------------------------------------------------------+ | 机械臂发送 | “513,x,y,z,a,b,c,d,#” | 513: 发送机械臂当前笛卡尔位姿指令号 | | | +-------------------------------------------------------+ | | | x,y,z: 机械臂当前位置数据 | | | +-------------------------------------------------------+ | | | a,b,c,d: 机械臂当前姿态数据 | | | +-------------------------------------------------------+ | | | 如果机械臂是欧拉角形式,则只需给a,b,c赋值,d赋值0即可 | +------------+-----------------------+-------------------------------------------------------+ | 机械臂接收 | “error_code,#” | | +------------+-----------------------+-------------------------------------------------------+ 15. 发送机械臂当前扩展轴位置(xyzSendCurrentExtJoints) +------------+---------------------------+------------------------------------------+ | 机械臂发送 | “514,j1,j2,j3,j4,j5,j6,#” | 514: 发送机械臂当前扩展轴的位置 | | | +------------------------------------------+ | | | j1~j6: 机械臂当前扩展轴的角度信息 | | | +------------------------------------------+ | | | 如果扩展轴数不足6的,需要补零后发送六个数 | +------------+---------------------------+------------------------------------------+ | 机械臂接收 | “error_code,#” | | +------------+---------------------------+------------------------------------------+ 16. 请求pick动作规划(xyzReqPick) +------------+----------------+-----------------------------+ | 机械臂发送 | “515,#” | 515: 请求pick动作规划指令号 | | | | | | | | | | | | 该指令暂不支持 | +------------+----------------+-----------------------------+ | 机械臂接收 | “error_code,#” | | +------------+----------------+-----------------------------+ 17. 请求place动作规划(xyzReqPlace) +------------+----------------+------------------------------+ | 机械臂发送 | “516,#” | 516: 请求place动作规划指令号 | | | | | | | | 该指令暂不支持 | +------------+----------------+------------------------------+ | 机械臂接收 | “error_code,#” | | +------------+----------------+------------------------------+ 18. 请求pick和place规划(xyzReqPickPlace) +------------+----------------+--------------------------------+ | 机械臂发送 | “517,ws_id,#” | 517: 请求pick和place规划指令号 | | | +--------------------------------+ | | | ws_id(int):工作空间id | +------------+----------------+--------------------------------+ | 机械臂接收 | “error_code,#” | | +------------+----------------+--------------------------------+ 19. 获取取料入框轨迹(xyzGetPickin) +------------+-----------------------------------------------+---------------------------------------------------+ | 机械臂发送 | “518,ws_id,#” | 518: 获取取料入框指令号 | | | +---------------------------------------------------+ | | | ws_id(int):工作空间id | +------------+-----------------------------------------------+---------------------------------------------------+ | 机械臂接收 | “error_code,pipeline_num,register_num,traj,#“ | pipeline_num(int): pipeline文件number | | | +---------------------------------------------------+ | | | register_num(int): 用到的注册文件的注册number | | | +---------------------------------------------------+ | | | traj轨迹点: num+ wp_type + wp + wp_type + wp +…. | | | +---------------------------------------------------+ | | | num: waypoint num 轨迹点数量 | | | +---------------------------------------------------+ | | | wp_type 轨迹点类型:joints or Cartesian,可能值: | | | | | | | | - 11 on joints movej | | | | | | | | - 12 on joints movel | | | | | | | | - 21 on cart movej | | | | | | | | - 22 on cart movel | | | +---------------------------------------------------+ | | | wp: 点位,6个值(j1~j6或者xyzabc) | +------------+-----------------------------------------------+---------------------------------------------------+ 20. 获取取料出框轨迹(xyzGetPickout) +------------+-----------------------------------------------+---------------------------------------------------+ | 机械臂发送 | “519,ws_id,#” | 519: 获取取料出框轨迹指令号 | | | +---------------------------------------------------+ | | | ws_id(int):工作空间id | +------------+-----------------------------------------------+---------------------------------------------------+ | 机械臂接收 | “error_code,pipeline_num,register_num,traj,#“ | pipeline_num(int): pipeline文件number | | | +---------------------------------------------------+ | | | register_num(int): 用到的注册文件的注册number | | | +---------------------------------------------------+ | | | traj轨迹点: num+ wp_type + wp + wp_type + wp +…. | | | +---------------------------------------------------+ | | | num: waypoint num 轨迹点数量 | | | +---------------------------------------------------+ | | | wp_type 轨迹点类型:joints or Cartesian,可能值: | | | | | | | | - 11 on joints movej | | | | | | | | - 12 on joints movel | | | | | | | | - 21 on cart movej | | | | | | | | - 22 on cart movel | | | +---------------------------------------------------+ | | | wp: 点位,6个值(j1~j6或者xyzabc) | +------------+-----------------------------------------------+---------------------------------------------------+ 21. 获取放料入框轨迹(xyzGetPlacein) +------------+-----------------------------------------------+---------------------------------------------------+ | 机械臂发送 | “520,ws_id,#” | 520: 获取放料入框轨迹指令号 | | | +---------------------------------------------------+ | | | ws_id(int):工作空间id | +------------+-----------------------------------------------+---------------------------------------------------+ | 机械臂接收 | “error_code,pipeline_num,register_num,traj,#“ | pipeline_num(int): pipeline文件number | | | +---------------------------------------------------+ | | | register_num(int): 用到的注册文件的注册number | | | +---------------------------------------------------+ | | | traj轨迹点: num+ wp_type + wp + wp_type + wp +…. | | | +---------------------------------------------------+ | | | num: waypoint num 轨迹点数量 | | | +---------------------------------------------------+ | | | wp_type 轨迹点类型:joints or Cartesian,可能值: | | | | | | | | - 11 on joints movej | | | | | | | | - 12 on joints movel | | | | | | | | - 21 on cart movej | | | | | | | | - 22 on cart movel | | | +---------------------------------------------------+ | | | wp: 点位,6个值(j1~j6或者xyzabc) | +------------+-----------------------------------------------+---------------------------------------------------+ 22. 获取放料出框轨迹(xyzGetPlaceout) +------------+-----------------------------------------------+---------------------------------------------------+ | 机械臂发送 | “521,ws_id,#” | 521: 获取放料出框轨迹指令号 | | | +---------------------------------------------------+ | | | ws_id(int):工作空间id | +------------+-----------------------------------------------+---------------------------------------------------+ | 机械臂接收 | “error_code,pipeline_num,register_num,traj,#“ | pipeline_num(int): pipeline文件number | | | +---------------------------------------------------+ | | | register_num(int): 用到的注册文件的注册number | | | +---------------------------------------------------+ | | | traj轨迹点: num+ wp_type + wp + wp_type + wp +…. | | | +---------------------------------------------------+ | | | num: waypoint num 轨迹点数量 | | | +---------------------------------------------------+ | | | wp_type 轨迹点类型:joints or Cartesian,可能值: | | | | | | | | - 11 on joints movej | | | | | | | | - 12 on joints movel | | | | | | | | - 21 on cart movej | | | | | | | | - 22 on cart movel | | | +---------------------------------------------------+ | | | wp: 点位,6个值(j1~j6或者xyzabc) | +------------+-----------------------------------------------+---------------------------------------------------+ 23. 请求切换策略(xyzSwitchStrat) +------------+--------------------+------------------------------+ | 机器人发送 | “522,strat_name,#” | 522: 请求切换策略指令号 | | | +------------------------------+ | | | strat_name(string): 策略名称 | +------------+--------------------+------------------------------+ | 机器人接收 | “error_code,#” | | +------------+--------------------+------------------------------+ 24. 料箱重定位(xyzUpdateTotePose) +------------+------------------------------+---------------------------------------------------------------------+ | 机械臂发送 | “523,#” | 523: 料箱重定位指令号 | | | | | | | | | | | | 执行完毕后,环境中的料箱位姿会被自动更新 | +------------+------------------------------+---------------------------------------------------------------------+ | 机械臂接收 | “error_code,x,y,z,a,b,c,d,#” | x,y,z,a,b,c,d: 重定位后的料箱位姿数据,目前该值用不到,用户无需使用 | +------------+------------------------------+---------------------------------------------------------------------+ 25. 工件在上手的二次定位(xyzUpdateObjPoseOnHand) +------------+----------------+---------------------------------+ | 机械臂发送 | “524,#” | 524: 工件在手上的二次定位指令号 | +------------+----------------+---------------------------------+ | 机械臂接收 | “error_code,#” | | +------------+----------------+---------------------------------+ 26. 工件不在手上的二次定位(xyzUpdateObjPoseToHand) +------------+-----------------------------------------------+---------------------------------------------------+ | 机械臂发送 | “525,#” | 525: 工件不在手上的二次定位指令号 | +------------+-----------------------------------------------+---------------------------------------------------+ | 机械臂接收 | “error_code,pipeline_num,register_num,traj,#“ | pipeline_num(int): pipeline文件number | | | +---------------------------------------------------+ | | | register_num(int): 用到的注册文件的注册number | | | +---------------------------------------------------+ | | | traj轨迹点: num+ wp_type + wp + wp_type + wp +…. | | | +---------------------------------------------------+ | | | num: waypoint num 轨迹点数量 | | | +---------------------------------------------------+ | | | wp_type 轨迹点类型:joints or Cartesian,可能值: | | | | | | | | - 11 on joints movej | | | | | | | | - 12 on joints movel | | | | | | | | - 21 on cart movej | | | | | | | | - 22 on cart movel | | | +---------------------------------------------------+ | | | wp: 点位,6个值(j1~j6或者xyzabc) | +------------+-----------------------------------------------+---------------------------------------------------+ 27. 获取工件姿态类型(xyzGetObjPoseType) +------------+--------------------------+-----------------------------------+ | 机器人发送 | “526,#” | 526: 工件正反面识别指令号 | +------------+--------------------------+-----------------------------------+ | 机器人接收 | “error_code,pose_type,#“ | pose_type(int):工件的pose类型信息 | +------------+--------------------------+-----------------------------------+ 28. 重置工业码垛状态(xyzResetPalletStatus) +------------+----------------+-------------------------+ | 机械臂发送 | “527,#” | 527: 重置码垛状态指令号 | +------------+----------------+-------------------------+ | 机械臂接收 | “error_code,#” | | +------------+----------------+-------------------------+ 29. 切换工件(xyzSwitchItem) +------------+-----------------------------+---------------------------------+ | 机器人发送 | “528,ws_id,item_codename,#” | 528: 切换工件指令号 | | | +---------------------------------+ | | | ws_id(int): 工作空间id | | | +---------------------------------+ | | | item_codename(string): 工件代号 | +------------+-----------------------------+---------------------------------+ | 机器人接收 | “error_code,#“ | | +------------+-----------------------------+---------------------------------+ 30. 计算抓取目标点位(xyzCalculateGraspPose) +------------+------------------------------------------------------------+-----------------------------------------------+ | 机械臂发送 | “529,ws_id,#” | 529: 计算抓取目标点位指令号 | | | +-----------------------------------------------+ | | | 该指令等价于xyzReqGraspPose +xyzGetGraspPose | | | +-----------------------------------------------+ | | | ws_id(int): 工作空间id | +------------+------------------------------------------------------------+-----------------------------------------------+ | 机械臂接收 | “error_code,x,y,z,a,b,c,d,num,pipeline_num,register_num,#” | x,y,z,a,b,c,d: 为抓取目标点的位姿数据 | | | +-----------------------------------------------+ | | | num(int): 当前有多少个可供抓取的点 | | | +-----------------------------------------------+ | | | pipeline_num(int): pipeline文件number | | | +-----------------------------------------------+ | | | register_num(int): 用到的注册文件的注册number | +------------+------------------------------------------------------------+-----------------------------------------------+ 31. 计算物体位姿(xyzCalculateObjectPose) +------------+--------------------------------------------+-------------------------------------------+ | 机械臂发送 | “530,ws_id,#” | 530: 计算物体位姿指令号 | | | +-------------------------------------------+ | | | 该指令等价于xyzReqObjPose + xyzGetObjPose | | | +-------------------------------------------+ | | | ws_id(int): 工作空间id | +------------+--------------------------------------------+-------------------------------------------+ | 机械臂接收 | “error_code,x,y,z,a,b,c,d,num,pose_type,#“ | x,y,z,a,b,c,d: 物体的位姿数据 | | | +-------------------------------------------+ | | | num(int): 当前物体位姿个数 | | | +-------------------------------------------+ | | | pose_type(int) :物体的位姿类型 | +------------+--------------------------------------------+-------------------------------------------+