案例/模板说明
机械臂主控主函数说明
以下为机械臂主控模板代码,注意对工控机返回的 err_code 进行判断。模板用途为所有接口的集成测试,用作实际使用的参考。
-------------------------Test Code----------------------------------
-- This function is for testing all api
function xyzTest()
xyzTestSwitchApp()
xyzTestSwitchObj()
xyzTestSwitchTool()
-- Because of token, the next 3 test sequence can not be changed
xyzTestImg()
xyzTestGrasp()
xyzTestObj()
xyzTestResetVision()
xyzTestSendJointCartExtJoint()
xyzTestReqPickPlace()
xyzTestGetPickPlace()
xyzTestSwitchStrat()
xyzTestUpdate()
xyzTestGetObjPoseType()
xyzTestRestPalletStatus()
end
function xyzTestSwitchApp()
local app_name = "111"
local error_code = xyzSwitchApp(app_name)
app_name = "error_app"
error_code = xyzSwitchApp(app_name)
end
function xyzTestSwitchObj()
local obj_name = "222"
local error_code = xyzSwitchObj(obj_name)
obj_name = "error_obj"
error_code = xyzSwitchObj(obj_name)
end
function xyzTestSwitchTool()
local tool_name = "333"
local error_code = xyzSwitchTool(tool_name)
tool_name = "error_tool"
error_code = xyzSwitchTool(tool_name)
end
function xyzTestImg()
local ws_id = 0
local token = 1
-- token in robot server will increase after every call
local error_code = xyzReqCapImg(ws_id)
error_code = xyzGetCapImg(token)
ws_id = 0
error_code = xyzCapImg(ws_id)
end
function xyzTestGrasp()
local ws_id = 0
local pose_num = 0
local pose_type = 0
local token = 0
-- token in robot server will increase after every call
local error_code = xyzReqGraspPose(ws_id)
token = 3
error_code = xyzGetGraspPose(token)
end
function xyzTestObj()
local pose_num = 0
local pose_type = 0
local ws_id = 0
local token = 0
-- token in robot server will increase after every call
local error_code = xyzReqObjPose(ws_id)
token = 4
error_code = xyzGetObjPose(token)
end
function xyzTestResetVision()
local ws_id = 0
local error_code = xyzResetVision(ws_id)
end
function xyzTestSendJointCartExtJoint()
local error_code = xyzSendCurrentJoints()
error_code = xyzSendCurrentCartPose()
end
function xyzTestReqPickPlace()
local error_code = xyzReqPick()
error_code = xyzReqPlace()
error_code = xyzReqPickPlace()
end
function xyzTestGetPickPlace()
local pose_type = 0
local pose_num = 0
-- please check the waypoint data before xyzExecuteTraj() !
local error_code = xyzGetPickin()
xyzExecuteTraj()
error_code = xyzGetPickout()
xyzExecuteTraj()
error_code = xyzGetPlacein()
xyzExecuteTraj()
error_code = xyzGetPlaceout()
xyzExecuteTraj()
end
function xyzTestSwitchStrat()
local strat_name = "strat1"
local error_code = xyzSwitchStrat(strat_name)
strat_name = "error_strat"
error_code = xyzSwitchStrat(strat_name)
end
function xyzTestUpdate()
local pose_type = 0
local pose_num = 0
local error_code = xyzUpdateTotePose()
error_code = xyzUpdateObjPoseOnHand()
error_code = xyzUpdateObjPoseToHand()
end
function xyzTestGetObjPoseType()
local pose_type = 0
local error_code = xyzGetObjPoseType()
end
function xyzTestRestPalletStatus()
local error_code = xyzResetPalletStatus()
end
-------------------------------Main Function-------------------------------------
function xyzMain()
xyzMasterConnect()
xyzTest()
xyzMasterClose()
end
-- In real situation, xyzMain() should be commented or deleted
-- Call function in script instead
xyzMain()