Skip to content

Commit 074d7f0

Browse files
committed
example: draw a square.
1 parent 6032f31 commit 074d7f0

File tree

1 file changed

+65
-0
lines changed

1 file changed

+65
-0
lines changed
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
#!/usr/bin/env python3
2+
# Software License Agreement (BSD License)
3+
#
4+
# Copyright (c) 2019, UFACTORY, Inc.
5+
# All rights reserved.
6+
#
7+
# Author: Vinman <vinman.wen@ufactory.cc> <vinman.cub@gmail.com>
8+
9+
"""
10+
Description: Move line(linear motion)
11+
"""
12+
13+
import os
14+
import sys
15+
import time
16+
17+
sys.path.append(os.path.join(os.path.dirname(__file__), '../../..'))
18+
19+
from xarm.wrapper import XArmAPI
20+
21+
22+
#######################################################
23+
"""
24+
Just for test example
25+
"""
26+
if len(sys.argv) >= 2:
27+
ip = sys.argv[1]
28+
else:
29+
try:
30+
from configparser import ConfigParser
31+
parser = ConfigParser()
32+
parser.read('../robot.conf')
33+
ip = parser.get('xArm', 'ip')
34+
except:
35+
ip = input('Please input the xArm ip address:')
36+
if not ip:
37+
print('input error, exit')
38+
sys.exit(1)
39+
########################################################
40+
41+
42+
arm = XArmAPI(ip, is_radian=True)
43+
arm.motion_enable(enable=True)
44+
arm.set_mode(0)
45+
arm.set_state(state=0)
46+
47+
arm.reset(wait=True)
48+
49+
Z_GROUND = 91.2
50+
51+
arm.set_position(x=300, y=-50, z=Z_GROUND, roll=-180, pitch=0, yaw=0, speed=100, is_radian=False, wait=True)
52+
print(arm.get_position(), arm.get_position(is_radian=False))
53+
arm.set_position(x=300, y=50, z=Z_GROUND, roll=-180, pitch=0, yaw=0, speed=100, is_radian=False, wait=True)
54+
print(arm.get_position(), arm.get_position(is_radian=False))
55+
arm.set_position(x=400, y=50, z=Z_GROUND, roll=-180, pitch=0, yaw=0, speed=100, is_radian=False, wait=True)
56+
print(arm.get_position(), arm.get_position(is_radian=False))
57+
arm.set_position(x=400, y=-50, z=Z_GROUND, roll=-180, pitch=0, yaw=0, speed=100, is_radian=False, wait=True)
58+
print(arm.get_position(), arm.get_position(is_radian=False))
59+
arm.set_position(x=300, y=-50, z=Z_GROUND, roll=-180, pitch=0, yaw=0, speed=100, is_radian=False, wait=True)
60+
print(arm.get_position(), arm.get_position(is_radian=False))
61+
arm.set_position(x=300, y=-50, z=Z_GROUND+10, roll=-180, pitch=0, yaw=0, speed=100, is_radian=False, wait=True)
62+
print(arm.get_position(), arm.get_position(is_radian=False))
63+
64+
arm.reset(wait=True)
65+
arm.disconnect()

0 commit comments

Comments
 (0)