-
Notifications
You must be signed in to change notification settings - Fork 3
/
demo23_flxie2_motion_que.py
executable file
·58 lines (50 loc) · 2.13 KB
/
demo23_flxie2_motion_que.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
#!/usr/bin/env python3
#
# Copyright (C) 2021 UmbraTek Inc. All Rights Reserved.
#
# Software License Agreement (BSD License)
#
# Author: Jimy Zhang <jimy.zhang@umbratek.com> <jimy92@163.com>
# =============================================================================
import sys
import argparse
import os
sys.path.append(os.path.join(os.path.dirname(__file__), '../..'))
from utapi.utra.utra_api_tcp import UtraApiTcp
from utapi.utra.utra_flxie_api import UtraFlxiE2Api
if __name__ == '__main__':
u"""This is a demo of a robot controlling the FLXI E on robot.
The command to control FLXI E will wait for the preceding robot motion command to be executed before taking effect.
run command:
python3 example/utra/demo23_flxie2_motion_que.py --ip 192.168.1.xxx
"""
parser = argparse.ArgumentParser()
parser.description = 'UTRA demo'
parser.add_argument("--ip", help=" ", default="127.0.0.1", type=str)
args = parser.parse_args()
ubot = UtraApiTcp(args.ip)
fixi = UtraFlxiE2Api(ubot, 101)
ret = ubot.reset_err() # Reset error
print("reset_error :%d" % (ret))
ret = ubot.set_motion_mode(0) # Set the operating mode of the arm, 0: position control mode
print("set_motion_mode :%d" % (ret))
ret = ubot.set_motion_enable(8, 1) # Set the enable state of the arm
print("set_motion_enable :%d" % (ret))
ret = ubot.set_motion_status(0) # Set the running status of the arm, 0: Set to ready
print("set_motion_status :%d" % (ret))
ret = ubot.move_sleep(1)
print("move_sleep :%d" % (ret))
ret = fixi.set_motion_mode(1, False)
print("set_motion_mode: %d" % (ret))
ret = fixi.set_motion_enable(1, False)
print("set_motion_enable: %d" % (ret))
ret = fixi.set_pos_target(0, False)
print("set_pos_target: %d" % (ret))
ret = ubot.move_sleep(5)
print("move_sleep :%d" % (ret))
ret = fixi.set_pos_target(20, False)
print("set_pos_target: %d" % (ret))
ret = ubot.move_sleep(10)
print("move_sleep :%d" % (ret))
ret = fixi.set_pos_target(0, False)
print("set_pos_target: %d" % (ret))