-
Notifications
You must be signed in to change notification settings - Fork 112
/
9000-set_linear_track.py
60 lines (48 loc) · 1.57 KB
/
9000-set_linear_track.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/usr/bin/env python3
# Software License Agreement (BSD License)
#
# Copyright (c) 2020, UFACTORY, Inc.
# All rights reserved.
#
# Author: Vinman <[email protected]> <[email protected]>
"""
Example: Direct drive linear motor
Please make sure that the direct drive linear motor is attached to the end.
"""
import os
import sys
import time
sys.path.append(os.path.join(os.path.dirname(__file__), '../../..'))
from xarm.wrapper import XArmAPI
from configparser import ConfigParser
parser = ConfigParser()
parser.read('../robot.conf')
try:
ip = parser.get('xArm', 'ip')
except:
ip = input('Please input the xArm ip address[192.168.1.196]:')
if not ip:
ip = '192.168.1.196'
# arm = XArmAPI(ip)
arm = XArmAPI('192.168.1.196')
arm.motion_enable(True)
arm.clean_error()
arm.set_mode(0)
arm.set_state(0)
time.sleep(1)
code = arm.set_linear_track_back_origin(wait=True)
print('set linear track back origin, code={}'.format(code))
# status = 1 is go back on zero successful,
code, status = arm.get_linear_track_on_zero()
print('get linear track on zero point, code={}, status={}'.format(code, status))
code = arm.set_linear_track_enable(True)
print('set linear track enable, code={}'.format(code))
# set speed 500mm/s
code = arm.set_linear_track_speed(500)
print('set linear track speed, code={}'.format(code))
# set position 300mm
code = arm.set_linear_track_pos(300, wait=True)
print('[wait]set linear track pos, code={}'.format(code))
# set position 700mm
code = arm.set_linear_track_pos(700, wait=False)
print('[no wait]set linear track track pos, code={}'.format(code))