Any Robot + RoboDK + Python: Generate Dataset and Perform Hand-Eye Calibration
참고
이 튜토리얼은 UR5e 및 Yaskawa H10에서만 테스트되었으며 RoboDK에서 지원하는 로봇에서만 작동합니다.
Introduction
정확한 hand-eye calibration에는 좋은 데이터 세트가 필요하지만 이 데이터 세트를 생성하는 것은 어려운 작업일 수 있습니다. 이 작업을 단순화하는 한 가지 방법은 미리 로봇 포즈를 저장하고 나중에 획득 프로세스를 자동화하는 것입니다. 이 자습서에서는 RoboDK를 사용하여 hand-eye dataset의 수집을 자동화합니다. 이것은 Zivid hand-eye calibration에서 hand-eye transform matrix를 얻는 데 필요한 필요한 3D 이미지와 로봇 포즈를 제공합니다. 이 샘플은 eye-in-hand와 eye-to-hand 모두 작동합니다.
hand-eye calibration에 익숙하지 않다면 Hand-Eye Calibration 문서를 참조하여 시작하는 것이 좋습니다.
Requirements
Linux의 경우 Zivid 도구를 포함하여 Zivid software 를 설치합니다.
Zivid-Python 을 설치합니다.
RoboDK software 를 설치합니다.
Robodk robot library 가 지원하는 로봇이어야 합니다.
Set Up RoboDK Environment
RoboDK .rdk 파일은 로봇, 대상 포즈 및 환경에 대한 정보를 저장합니다. hand-eye calibration dataset을 생성하는데 필요하고 유용한 .rdk 파일의 구성 요소는 다음과 같습니다.
로봇 모델 파일 (.robot)
대상 포즈 목록 (예: Target 0, Target 1, Target 2 등)
로봇 환경의 가상 모델 (선택 사항)
CAD model of the camera in use, e.g., Zivid 2 CAD file (optional)
RoboDK에서 example file .rdk 를 열어 확인하십시오.
Add Robot to RoboDK Environment
RoboDK 프로그램을 열고 사용할 로봇을 추가하여 시작합니다. 로봇을 추가하려면 File -> Open online library 로 이동하여 GUI를 사용하여 라이브러리를 엽니다. 이 인터페이스를 통해 모델과 일치하는 로봇을 찾아 마우스로 Open 을 선택합니다. 로봇이 스테이션에 나타나지 않으면 Download 를 선택하고 .rdk 환경으로 다운로드하여 사용합니다. 이는 Select a robot RoboDK tutorial 에도 설명되어 있습니다.
Connect to Robot through RoboDK
경고
Depending on the brand of the robot being used, a driver setup can be required to connect to RoboDK. For help on this setup, check out the robot tips section in the RoboDK documentation. For example, here is the advice for ABB robots.
Hand-Eye 스크립트를 실행하기 전에 먼저 RoboDK 인터페이스를 사용하여 로봇에 연결해야 합니다. RoboDK GUI에서 Connect -> Connect Robot 합니다. 그러면 로봇 IP와 포트 번호를 삽입할 수 있는 측면 패널이 열립니다.
참고
대부분의 로봇에는 제어 펜던트 또는 태블릿에 원격 모드가 있습니다. 연결을 설정할 수 있도록 로봇이 원격 모드에 있는지 확인하십시오.
To connect to the robot you must know its IP address, it should be found/listed in the robot control pendant. Follow the steps for connecting to the robot for RoboDK. Also verify the port number. The default number that comes with the driver should work unless changes have been made previously.
Click Connect and if the Connection status box is green, the RoboDK interface can be used to control the robot. If it is red instead, make sure that you have the right port number and IP address. If it is still red, check the Troubleshoot RoboDK chapter at the end of this tutorial.
Create Poses for Hand-Eye Calibration
경고
If your robot is calibrated, you need to load the DH parameters from your robot controller into RoboDK before creating the hand-eye dataset. Incorrect robot calibration can lead to poor hand-eye calibration results. In Bad Robot Calibration (DH parameters) troubleshooting article, we explain how to retrieve and load DH parameters for a UR robot. If your robot is calibrated and it is not a UR robot, check your robot documentation for retrieving DH parameters.
Learn how to create a target in RoboDK to save the poses.
RoboDK를 사용하여 포즈를 만드는 것은 두 가지 방법으로 접근할 수 있습니다.
펜던트를 사용하여 로봇을 원하는 포즈로 물리적으로 이동한 다음 RoboDK를 통해 연결하여 포즈를 기록합니다.
RoboDK를 통해 로봇을 원격으로 이동하여 포즈 생성 및 저장
팁
로봇을 RoboDK를 통해 이동 중인데 로봇이 충분히 빠르게 또는 충분히 느리게 이동하지 않는 경우 set the robot speed in RoboDK 링크를 선택하여 RoboDK에서 로봇 속도를 설정하십시오. 속도를 설정한 후 자신이 만든 프로그램을 마우스 오른쪽 단추로 클릭하고 Run on the robot 으로 표시한 다음 다시 마우스 오른쪽 단추를 클릭하고 Run 을 선택합니다.
Each pose that is added to the sequence should have the camera facing the calibration object and keep the entire object in the field of view. The calibration object should be centered in the image. When creating the poses, use Live Scene View in Zivid Studio to see the scene as you move the robot into position. This helps pick the orientations that will provide the best coverage. It is recommended to have between 10-20 poses to get an accurate hand-eye transform. You can see illustrated below how it looks in RoboDK.
Run the Python Script
스크립트를 실행하기 전에 .rdk 파일을 열고 로봇에 연결해야 합니다. The script can be found in the Zivid python samples ; 아래에 표시된 필수 명령줄 인수를 사용합니다.
type_group.add_argument("--eih", "--eye-in-hand", action="store_true", help="eye-in-hand calibration")
type_group.add_argument("--eth", "--eye-to-hand", action="store_true", help="eye-to-hand calibration")
parser.add_argument(
"--settings-path",
required=False,
type=Path,
help="Path to the camera settings YML file",
)
parser.add_argument("--ip", required=True, help="IP address of the robot controller")
parser.add_argument(
"--target-keyword",
required=True,
help='This is the keyword shared for naming all poses used for hand-eye dataset, i.e. if we have: "Target 1", "Target 2", ... , "Target N". Then we should use "Target"',
)
subparsers = parser.add_subparsers(dest="calibration_object", required=True, help="Calibration object type")
subparsers.add_parser("checkerboard", help="Use checkerboard for calibration")
marker_parser = subparsers.add_parser("marker", help="Use marker for calibration")
marker_parser.add_argument(
"--dictionary",
required=True,
choices=list(zivid.calibration.MarkerDictionary.valid_values()),
help="Dictionary used for marker calibration",
)
marker_parser.add_argument("--ids", nargs="+", required=True, type=int, help="IDs used for marker calibration")
Once the script is initialized, it asks for a name for the dataset folder.
The dataset and results are stored as a Zivid Studio hand-eye session in datasets/handeye/<name> next to the script, so you can also open them in Hand-Eye Calibration in Zivid Studio.
If you do not enter a name, the current date and time is used.
The session layout is not the dataset layout that the hand-eye calibration CLI tool reads, so calibrate a session with this script or in Zivid Studio.
The script runs through the given poses and performs a hand-eye calibration, as follows.
Script walk-through
RoboDK 핸드-아이 캘리브레이션 스크립트를 작동시키려면 두 개의 추가 Python 파일이 필요합니다.
robodk_tools.py 는 로봇을 설정하는데 사용됩니다.
hand_eye_session.py is used to save and load the session: the robot poses, captures and calibration results.
스크립트는 각각 다음 단계를 통해 실행됩니다.
Connect to robot
먼저 IP 주소를 인수로 제공하여 robodk_tools.py 의 connect_to_robot() 함수를 사용하여 로봇에 연결해야 합니다. 이 함수는 시뮬레이터와의 링크를 설정하는데 사용되는 rdk 개체와 다양한 로봇 구성 파라미터를 포함하는 robot 개체를 반환합니다.
Set robot targets
그런 다음 robodk_tools.py 에서 get_robot_targets() 함수를 사용하여 대상 목록을 가져옵니다. 이 목록은 RoboDK .rdk 파일에서 가져오며 각 대상에 대한 로봇 포즈를 포함합니다. 대상 목록을 얻으려면 이전 단계에서 얻은 rdk 개체와 사용자가 제공한 대상 키워드를 인수로 제공해야 합니다.
Set robot speed and acceleratio
로봇 구성의 마지막 단계는 로봇의 속도와 가속도를 정의하는 것입니다. 이러한 매개 변수를 정의하기 위해 robot_speed_accel_limits 라는 이름의 4개의 정수 목록을 만듭니다. 각각 선형 속도, 관절 속도, 선형 가속 및 관절 가속입니다. 그런 다음 robodk_tools.py 의 set_robot_speed_and_acceleration() 함수를 robot 개체와 robot_speed_accel_limits 를 인수로 사용하여 로봇 구성이 수행됩니다.
Generate Hand-Eye dataset
Now we generate the hand-eye dataset by moving the robot to each pose in the list of targets.
For each pose, we capture and save the ZDF file and the robot’s pose during capture into the session’s Calibration folder.
In this step, the user is asked for a name for the dataset folder, which is created under datasets/handeye next to the script.
If no name is entered, the current date and time is used.
To generate this dataset we use the generate_hand_eye_dataset() function.
It takes as arguments a zivid application, app object, to gain access to the camera, a robot object, the list of targets to move the robot to, and the command-line options, and returns the session.
Perform Hand-Eye calibration
To perform the hand-eye calibration, we iterate over all robot poses and ZDF files saved from the previous step.
Using the perform_hand_eye_calibration() function with the generated session as argument, we obtain the hand-eye calibration result (the transformation matrix and residuals).
The calibration type (eye-in-hand or eye-to-hand) and the calibration object are taken from the session.
Save Hand-Eye results
Lastly, the calibration result is saved into the session’s Calibration folder, as hand_eye_transform.yaml and hand_eye_residuals.yaml.
This is done with the session’s save_calibration_result() method.
Verify and use Transform from Hand-Eye
핸드-아이 캘리브레이션을 완료한 후, 다음 단계는 생성된 변환 행렬이 정확하고 요구되는 정확도 범위 내에 있는지 확인하는 것입니다.
문서 How to Verify Hand-Eye Calibration 에서 여러 가지 방법을 설명하고 있습니다. 하지만 저희가 권장하는 핸드-아이 캘리브레이션 검증 방법은 Zivid Calibration Object 장면에 배치하고 로봇으로 터치 테스트를 수행하는 것입니다.
If you are ready to learn how to use the hand-eye transform, we recommend reading How To Use the Result of Hand-Eye Calibration.
Troubleshoot RoboDK
Robot Moving to Different Configuration than Intended
Connect Through Firewall on windows
참고
이 방법은 Windows 11에서 테스트되었습니다.
Check driver blockage
Windows를 실행하는 컴퓨터에 연결할 때 방화벽이 로봇에 대한 연결을 차단할 수 있다는 점에 유의하십시오. 한 가지 옵션은 방화벽을 완전히 비활성화하는 것이지만 시스템이 취약해질 수 있으므로 권장하지 않습니다.
대신 Windows 방화벽에 새 규칙을 추가하여 사용하는 로봇의 드라이버 및 IP 주소에 대해서만 통신을 허용할 수 있습니다. 이 두 속성을 찾으려면 connect to robot 을 선택하여 more options 패널을 확장합니다. 이 경우 드라이버는 guilabel:apiur 입니다.
시스템의 Windows Defender 방화벽으로 이동하여 Advanced settings 으로 이동하세요. 그러면 방화벽 규칙 정의 페이지로 이동합니다. 여기에서 로봇 제어에 필요한 드라이버와의 통신을 허용하도록 인바운드 규칙을 변경할 수 있습니다.
Robot driver에 표지판이 차단되어 있으면 인바운드 규칙을 확인하십시오. driver가 차단된 경우 이 규칙을 비활성화합니다. 그렇지 않으면 방화벽이 통신을 차단합니다.
이 규칙이 비활성화되면 RoboDK 소프트웨어가 로봇에 연결할 수 있는지 확인하십시오. 그래도 로봇에 연결할 수 없으면 driver가 로봇과 통신할 수 있도록 특별히 허용하는 규칙을 만들어야 합니다.
Create a new inbound rule
New Rule… 을 클릭하면 컴퓨터와 로봇 간의 통신을 허용하는 규칙을 만들고 정의할 수 있습니다.
시작하려면 첫 번째 페이지에서 Custom 옵션을 선택하고 두 번째 페이지에서 All programs 옵션을 선택해야 합니다. 아래 그림에서 찾을 수 있습니다.
다음 페이지에서 TCP를 프로토콜로 선택한 다음 특정 로컬 포트를 선택하고 RoboDK의 포트 번호와 일치하는 포트 번호를 삽입해야 합니다.
다음 단계는 IP 주소를 설정하는 것입니다. Which remote IP address does this rule apply to? 아래에서 These IP addresses 를 선택합니다. 그런 다음 Add 를 클릭하고 RoboDK의 IP와 일치하는 IP를 설정합니다.
OK 및 Next 를 누른 후 Allow all connections 을 선택하고 다음 페이지에서 모든 확인란을 선택합니다.
Finally, choose a proper name for the rule, click Finish and you are good to go!