เมื่อหุ่นยนต์ได้ถูกวัดขนาดแล้ว, เราจะมีสองทางเลือกเพื่อสร้างโปรแกรมการใช้ความแม่นยำที่แท้จริงของหุ่นยนต์ที่คำนวณ
●โปรแกรมตัวกรองที่มีอยู่: เป้าหมายหุ่นยนต์ทั้งหมดภายในโปรแกรมถูกดัดแปลงเพื่อพัฒนาความแม่นยำของหุ่นยนต์ มันสามารถทำให้เสร็จด้วยตนเองหรือการใช้ API
●ใช้ RoboDK สำหรับการเขียนโปรแกรมออฟไลน์เพื่อสร้างโปรแกรมที่แม่นยำ Offline Programming to generate accurate programs (สร้างโปรแกรมเสร็จสิ้นด้วยตัวกรอง, รวมถึงการสร้างโปรแกรมด้วยการใช้ API)
เพื่อกรองโปรแกรมที่ใช้งานอยู่: ลาก&วางโปรแกรมหุ่นยนต์ลงในหน้าจอหลักของ RoboDK’s (หรือเลือกFile➔Open) และเลือกFilter only. โปรแกรมจะถูกกรองและบันทึกลงในไฟล์เดียวกันผลรวมของตัวกรองจะกล่าวถึงถ้ามีปัญหาใดๆถูกใช้ขั้นตอนตัวกรองเรามีตัวเลือกในการนำเข้าโปรแกรมถ้าเราต้องการจำลองมันภายใน RoboDKถ้าโปรแกรมมีการใช้งานร่วมกัน (หน้าต่างเครื่องมือหรือความหมายหน้าต่างหรือโปรแกรมย่อย, ...) จะต้องมีการตั้งอยู่ในสารบบเดียวกันที่โปรแกรมถูกนำเข้าครั้งแรก
เมื่อเรานำเข้าโปรแกรมใน RoboDK เราจะสามารถสร้างมันจากความแม่นยำที่แท้จริงหรืออาจจะไม่เลย ในการตั้งค่าความแม่นยำหลักของ RoboDK (Tools➔Options➔Accuracy) พวกเราสามารถตัดสินใจถ้าพวกเราต้องการสร้างโปรแกรมด้วยการเร่งการเคลื่อนไหว ถ้าพวกเราต้องการถามทุกครั้งหรือถ้าพวกเราต้องใช้การเคลื่อนไหวหุ่นยนต์ล่าสุด การเคลื่อนไหวหุ่นยนต์ล่าสุดสามารถถูกเปลี่ยนโดยการคลิกขวาที่หุ่นยนต์และเปิดใช้งาน/ไม่เปิดใช้งานป้ายชื่อ “ใช้เร่งการเคลื่อนไหว” ถ้ามันเปิดใช้งานเราจะเห็นจุดสีเขียว, ถ้าไม่เปิดใช้งานเราจะเห็นเป็นจุดสีแดง
นอกจากนี้ยังสามารถกรองโปรแกรมอย่างเสร็จสมบูรณ์โดยการใช้ RoboDK ที่ให้มาวัดขนาดหุ่นยนต์และการเรียกใช้โปรแกรมFilterProgram :
robot.FilterProgram(file_program)
ตัวอย่าง macro ถูกเรียกว่า FilterProgram มันใช้งานได้ในส่วนของ Macros ของคลังความรู้ โค้ดดังต่อไปนี้เป็นตัวอย่างชองต้นฉบับPython ซึ่งใช้ RoboDK API เพื่อคัดกรองโปรแกรม
from robolink import*# API to communicate with RoboDK
from robodk import*# basic matrix operations
import os # Path operations
# Get the current working directory
CWD = os.path.dirname(os.path.realpath(__file__))
# Start RoboDK if it is not running and link to the API
RDK = Robolink()
# optional: provide the following arguments to run behind the scenes
#RDK = Robolink(args='/NOSPLASH /NOSHOW /HIDDEN')
# Get the calibrated station (.rdk file) or robot file (.robot):
# Tip: after calibration, right click a robot and select "Save as .robot"
calibration_file = CWD +'/KUKA-KR6.rdk'
# Get the program file:
file_program = CWD +'/Prog1.src'
# Load the RDK file or the robot file:
calib_item = RDK.AddFile(calibration_file)
ifnot calib_item.Valid():
raise Exception("Something went wrong loading "+ calibration_file)
# Retrieve the robot (no popup if there is only one robot):
robot = RDK.ItemUserPick('Select a robot to filter', ITEM_TYPE_ROBOT)
ifnot robot.Valid():
raise Exception("Robot not selected or not available")
# Activate accuracy
robot.setAccuracyActive(1)
# Filter program: this will automatically save a program copy
# with a renamed file depending on the robot brand
status, summary = robot.FilterProgram(file_program)
if status ==0:
print("Program filtering succeeded")
print(summary)
calib_item.Delete()
RDK.CloseRoboDK()
else:
print("Program filtering failed! Error code: %i"% status)
print(summary)
RDK.ShowRoboDK()
The following code is an example Python script that uses the RoboDK API to filter a target (pose target or joint target), using the FilterTarget command:
ตามโค้ดดังต่อไปนี้เป็นตัวอย่างต้นฉบับ Python ซึ่งใช้ RoboDK API เพื่อคัดกรองเป้าหมาย(ท่าทางเป้าหมายหรือเป้าหมายร่วมกัน),การใช้คำสั่ง FilterTarget:
pose_filt, joints = robot.FilterTarget(nominal_pose, estimated_joints)
นี้เป็นตัวอย่างที่เป็นประโยชน์ถ้ากลุ่มแอพพลิเคชั่นอันดับ(นอกเหนือ RoboDK) สร้างโปรแกรมหุ่นยนต์ซึ่งใช้การออกแบบเป้าหมาย
from robolink import*# API to communicate with RoboDK
from robodk import*# basic matrix operations
defXYZWPR_2_Pose(xyzwpr):
return KUKA_2_Pose(xyzwpr) # Convert X,Y,Z,A,B,C to a pose
defPose_2_XYZWPR(pose):
return Pose_2_KUKA(pose) # Convert a pose to X,Y,Z,A,B,C
# Start the RoboDK API and retrieve the robot:
RDK = Robolink()
robot = RDK.Item('', ITEM_TYPE_ROBOT)
ifnot robot.Valid():
raise Exception("Robot not available")
pose_tcp = XYZWPR_2_Pose([0,0,200,0,0,0]) # Define the TCP
pose_ref = XYZWPR_2_Pose([400,0,0,0,0,0]) # Define the Ref Frame
# Update the robot TCP and reference frame
robot.setTool(pose_tcp)
robot.setFrame(pose_ref)
# Very important for SolveFK and SolveIK (Forward/Inverse kinematics)
robot.setAccuracyActive(False)# Accuracy can be ON or OFF
# Define a nominal target in the joint space:
joints =[0,0,90,0,90,0]
# Calculate the nominal robot position for the joint target:
pose_rob = robot.SolveFK(joints) # robot flange wrt the robot base
# Calculate pose_target: the TCP with respect to the reference frame
pose_target = invH(pose_ref)*pose_rob*pose_tcp
print('Target not filtered:')
print(Pose_2_XYZWPR(pose_target))
joints_approx = joints # joints_approx must be within 20 deg
pose_target_filt, real_joints = robot.FilterTarget(pose_target, joints)
print('Target filtered:')
print(real_joints.tolist())
print(Pose_2_XYZWPR(pose_target_filt))