# Camera When using `CobottaCtrl` directly in local mode, always call `disconnect()` on exit, including when interrupted by `KeyboardInterrupt` or another exception. ## Basic usage from Python ```python from cobotta2 import Config, CobottaCtrl, MotionMode Config.load_yaml("config_cobotta2.yaml") logger = XLogger(log_level="info", logger_name=Config.CLIENT_LOGGER_NAME) cobotta = CobottaCtrl(cobotta_ip=Config.COBOTTA_IP, arm_name="Arm", logger=logger) try: cobotta.reset_error() # Number of objects recognized by the camera (used to determine success or failure) cobotta.I2 = 0 # Work coordinates that receive the camera recognition result # Save the current position as a safe initial position cobotta.P10 = cobotta.get_current_position() # take_script() and take_camera() are mutually exclusive # Release the arm before take_camera() if take_arm() was called cobotta.release_arm() while True: logger.info("---------- Camera recognition -------------------") # Select the camera recognition model created with EVP2 Guidance evp_script_name = "try_camera" # The filename EVP2_03.pcs is arbitrary, but may overwrite an existing script on COBOTTA cobotta.take_camera(evp_script_name, "EVP2_03.pcs") cobotta.run_script() cobotta.wait_for_complete() logger.info(f"Result(num): {cobotta.I2}") if cobotta.I2 == 1: break logger.error(f"*** Target not found ***") logger.error(f"*** Retrying in 3 seconds ***") time.sleep(3) logger.error(f"***") logger.info(f"Result(pos): {cobotta.P10}") logger.error(f"***") logger.info("----------- Move to the center of the recognized image --------------") cobotta.take_arm() cobotta.move("P10", motion_mode=MotionMode.LINE, offset=(0,0,0), path_blend="@E", speed=50) cobotta.wait_for_complete() except KeyboardInterrupt as e: logger.error(e) except Exception as e: loggger.error(e) finally: cobotta.disconnect() ``` ## Camera calibration --- ## Author - Kengo NAKADA