# Tutorials ## 1. Basic structure of a research script ```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. Create taught points ```python with URCtrl(ROBOT_IP) as robot: robot.teach("P1") robot.teach("J1") ``` ## 3. Move to a taught point ```python with URCtrl(ROBOT_IP) as robot: robot.move("P1", motion_mode=MotionMode.PTP) ``` ## 4. Move linearly to a measurement position ```python with URCtrl(ROBOT_IP) as robot: robot.move("P1", motion_mode=MotionMode.LINE, speed=10, accel=10) ``` ## 5. Retract ```python with URCtrl(ROBOT_IP) as robot: robot.move("P1+(0,0,50)", motion_mode=MotionMode.LINE) ``` ## 6. Combine motion with 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. Inspect the state and stop ```python with URCtrl(ROBOT_IP) as robot: state = robot.state() if state.get("protective_stopped"): print(robot.get_current_error_info()) ``` ## 8. Integrate into an experimental sequence ```python with URCtrl(ROBOT_IP) as robot: robot.move("P_sample", motion_mode=MotionMode.LINE) robot.set_IO(0, True) # Place instrument-control operations here # detector.start() # detector.wait() robot.set_IO(0, False) robot.move("P_home", motion_mode=MotionMode.PTP) ``` This allows robot operations to be written as part of a measurement sequence.