<filename>example/wrapper/common/8000-load_identify_current.py
#!/usr/bin/env python3
# Software License Agreement (BSD License)
#
# Copyright (c) 2019, UFACTORY, Inc.
# All rights reserved.
#
# Author: Vinman <<EMAIL>> <<EMAIL>>

"""
Description: identify load with the end force sensor
"""

import os
import sys
import time

sys.path.append(os.path.join(os.path.dirname(__file__), '../../..'))

from xarm.wrapper import XArmAPI

#######################################################
"""
Just for test example
"""
if len(sys.argv) >= 2:
    ip = sys.argv[1]
else:
    try:
        from configparser import ConfigParser
        parser = ConfigParser()
        parser.read('../robot.conf')
        ip = parser.get('xArm', 'ip')
    except:
        ip = input('Please input the xArm ip address:')
        if not ip:
            print('input error, exit')
            sys.exit(1)
########################################################

arm = XArmAPI(ip)
arm.motion_enable(enable=True)
arm.clean_error()
arm.set_mode(0)
arm.set_state(0)
time.sleep(0.1)


def progress(item):
    print('progress: {}'.format(item['progress']))


arm.register_iden_progress_changed_callback(progress)
start_time = time.time()
code, result = arm.iden_tcp_load()
end_time = time.time()
print('code={}, result={}, cost_time={}'.format(code, result, end_time - start_time))
arm.release_iden_progress_changed_callback(progress)
arm.disconnect()
