# チュートリアル ## 1. 研究用スクリプトの基本形 ```python from ur.ur_ctrl import UrCtrl, MotionMode ROBOT_IP = "10.170.10.56" with UrCtrl(ROBOT_IP) as robot: robot.set_speed(20) robot.set_accel(20) p = robot.current_position print(p) ``` ## 2. 教示点を作る ```python with URCtrl(ROBOT_IP) as robot: robot.teach("P1") robot.teach("J1") ``` ## 3. 教示点へ移動する ```python with URCtrl(ROBOT_IP) as robot: robot.move("P1", motion_mode=MotionMode.PTP) ``` ## 4. 測定位置へ直線移動する ```python with URCtrl(ROBOT_IP) as robot: robot.move("P1", motion_mode=MotionMode.LINE, speed=10, accel=10) ``` ## 5. 退避する ```python with URCtrl(ROBOT_IP) as robot: robot.move("P1+(0,0,50)", motion_mode=MotionMode.LINE) ``` ## 6. IO と組み合わせる ```python with URCtrl(ROBOT_IP) as robot: robot.move("P_pick", motion_mode=MotionMode.LINE) robot.set_IO(0, True) robot.move("P_place", motion_mode=MotionMode.LINE) robot.set_IO(0, False) ``` ## 7. 状態を見て止める ```python with URCtrl(ROBOT_IP) as robot: state = robot.state() if state.get("protective_stopped"): print(robot.get_current_error_info()) ``` ## 8. 実験シーケンスに組み込む ```python with URCtrl(ROBOT_IP) as robot: robot.move("P_sample", motion_mode=MotionMode.LINE) robot.set_IO(0, True) # 測定器制御をここに置く # detector.start() # detector.wait() robot.set_IO(0, False) robot.move("P_home", motion_mode=MotionMode.PTP) ``` このように、ロボット操作を測定シーケンスの一部として記述する。