Код скрипта предназначен для робота и состоит из блока кодов, которые являются путевыми точками для сброса товаров.Я хочу сохранить строки, выполнив одну строку кода только один раз, вернуться к началу цикла и запускать только следующую строку кода, пока предыдущая строка не будет выполнена один раз.
function pim60()
script_common_interface("SICKCamera","takePhoto")
script_common_interface("SICKCamera","getResult")
Located = script_common_interface("SICKCamera","partLocated")
end
function intermediatemoves()
X = script_common_interface("SICKCamera","getXposition")
Y = script_common_interface("SICKCamera","getYposition")
R = script_common_interface("SICKCamera","getRotation")
z_offset = 0.24
local offset_pose = {}
table.insert(offset_pose,X)
table.insert(offset_pose,Y)
table.insert(offset_pose,z_offset)
camera_rz = rpy2quaternion({d2r(-180.0), d2r(0.0), d2r(-90.0) + d2r(R)})
move_joint(get_target_pose(offset_pose,camera_rz,false,{0.0, 0.0, 0.0},{1.0, 0.0, 0.0, 0.0}),true)
z_grab = 0.17
local grab_pose = {}
table.insert(grab_pose,X)
table.insert(grab_pose,Y)
table.insert(grab_pose,z_grab)
move_line(get_target_pose(grab_pose,camera_rz,false,{0.0, 0.0, 0.0},{1.0, 0.0, 0.0, 0.0}),true)
set_step_breakpoint()
--(Logic tree item : Gripper) Gripper
script_common_interface("Gripper", "set_robotiq_param|9, 155, 255, 255, true")
set_step_breakpoint()
--(Logic tree item : Move) Movedrp
--(Logic tree item : Waypoint) Waypoint01
move_joint({1.047662, -0.552625, -1.753926, 0.374278, -1.571027, 0.588803}, true)
set_step_breakpoint()
--(Logic tree item : Waypoint) Waypoint02
move_joint({2.307135, 0.811214, -0.349017, 0.045296, -1.569157, -0.006474}, true)
set_step_breakpoint()
end
function returntohome()
--WAYPOINT FOR COLLISION AVOIDANCE
--(Logic tree item : Waypoint) Waypoint02
move_joint({2.307135, 0.811214, -0.349017, 0.045296, -1.569157, -0.006474}, true)
set_step_breakpoint()
--!!HOME POSITION JOINT 5 CAN AFFECT PICK COLLISION WITH PART
--(Logic tree item : Waypoint) Waypointhome
move_joint({1.321444, -0.626547, -2.252496, -0.137991, -1.518901, -0.006779}, true)
set_step_breakpoint()
end
--Open gripper and home
script_common_interface("Gripper", "set_robotiq_param|9, 0, 255, 255, false")
--!!HOME POSITION JOINT 5 CAN AFFECT PICK COLLISION WITH PART
--(Logic tree item : Waypoint) Waypointhome
move_joint({1.321444, -0.626547, -2.252496, -0.137991, -1.518901, -0.006779}, true)
set_step_breakpoint()
--LoopA
repeat
pim60()
until (Located == 1)
intermediatemoves()
move_joint({2.337869, 1.478278, 0.177188, -0.416970, -1.569186, -0.006448}, true)
script_common_interface("Gripper", "set_robotiq_param|9, 0, 0, 83, true")
returntohome()
--LoopB
repeat
pim60()
until (Located == 1)
intermediatemoves()
move_joint({2.145543, 1.478292, 0.177206, -0.416904, -1.569186, -0.006415}, true)
script_common_interface("Gripper", "set_robotiq_param|9, 0, 0, 83, true")
returntohome()
--LoopC
repeat
pim60()
until (Located == 1)
intermediatemoves()
move_joint({2.020320, 1.478307, 0.177206, -0.416897, -1.569190, -0.006412}, true)
script_common_interface("Gripper", "set_robotiq_param|9, 0, 0, 83, true")
returntohome()
--LoopD
repeat
pim60()
until (Located == 1)
intermediatemoves()
move_joint({1.845862, 1.478325, 0.177202, -0.416893, -1.569190, -0.006412}, true)
script_common_interface("Gripper", "set_robotiq_param|9, 0, 0, 83, true")
returntohome()
Этокод используется сейчас и нигде не близко к желаемой функции.Я создал 4 повторяющихся "цикла", которые содержат 4 различных конечных положения для отбрасывания продуктов.