Controlling PacScript

Direct execution of DENSO scripts is supported, although it is not generally recommended except for special use cases.

Running a script stored on COBOTTA

When using CobottaCtrl directly in local mode, always call disconnect() on exit, including when interrupted by KeyboardInterrupt or another exception.

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()
    
    cobotta.turn_on_motor()
    cobotta.release_arm()
    
    name = "Pro1.pcs"  # The filename extension is optional

    # Mutually exclusive with take_script()
    cobotta.take_script(name)
    cobotta.run_script()
    cobotta.wait_for_complete()

except KeyboardInterrupt as e:
    logger.error(e)
except Exception as e:
    loggger.error(e)
finally:
    cobotta.disconnect()

Uploading a script to COBOTTA

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)

file_content = """
Sub Main 

	TakeArm Keep = 0
	
	' Descend to P[61]
	Move L, @0 P[61]

End Sub
"""
# Upload file_content as Pro2.pcs
cobotta.upload_content_to_cobotta(file_content, "Pro2.pcs")
print(cobotta.get_cobotta_file_names())

Listing scripts stored on COBOTTA

from cobotta2 import Config, CobottaCtrl, MotionMode

Config.load_yaml("config_cobotta1.yaml")

logger = XLogger(log_level="debug", logger_name=Config.CLIENT_LOGGER_NAME)
cobotta = CobottaCtrl(cobotta_ip=Config.COBOTTA_IP, arm_name="Arm", logger=logger)

print(cobotta.get_cobotta_file_names())

Downloading a script from COBOTTA

When using CobottaCtrl directly in local mode, always call disconnect() on exit, including when interrupted by KeyboardInterrupt or another exception.

from cobotta2 import Config, CobottaCtrl
from x_logger import XLogger


Config.load_yaml("config_cobotta1.yaml")

logger = XLogger(log_level="debug", logger_name=Config.CLIENT_LOGGER_NAME)
cobotta = CobottaCtrl(cobotta_ip=Config.COBOTTA_IP, arm_name="Arm", logger=logger)

print(cobotta.get_cobotta_file_names())
cobotta.download_file_from_cobotta("P62.pcs")


Author

  • Kengo NAKADA