dsr_simple_test.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 # -*- coding: utf-8 -*-
3 # ##
4 # @brief [py example simple] motion basic test for doosan robot
5 # @author Kab Kyoum Kim (kabkyoum.kim@doosan.com)
6 
7 import rospy
8 import os
9 import threading, time
10 import sys
11 sys.dont_write_bytecode = True
12 sys.path.append( os.path.abspath(os.path.join(os.path.dirname(__file__),"../../../../common/imp")) ) # get import pass : DSR_ROBOT.py
13 
14 # for single robot
15 ROBOT_ID = "dsr01"
16 ROBOT_MODEL = "m1013"
17 import DR_init
18 DR_init.__dsr__id = ROBOT_ID
19 DR_init.__dsr__model = ROBOT_MODEL
20 from DSR_ROBOT import *
21 
22 def shutdown():
23  print "shutdown time!"
24  print "shutdown time!"
25  print "shutdown time!"
26 
27  pub_stop.publish(stop_mode=STOP_TYPE_QUICK)
28  return 0
29 
31  msgRobotState_cb.count += 1
32 
33  if (0==(msgRobotState_cb.count % 100)):
34  rospy.loginfo("________ ROBOT STATUS ________")
35  print(" robot_state : %d" % (msg.robot_state))
36  print(" robot_state_str : %s" % (msg.robot_state_str))
37  print(" current_posj : %7.3f %7.3f %7.3f %7.3f %7.3f %7.3f" % (msg.current_posj[0],msg.current_posj[1],msg.current_posj[2],msg.current_posj[3],msg.current_posj[4],msg.current_posj[5]))
38  #print(" current_posx : %7.3f %7.3f %7.3f %7.3f %7.3f %7.3f" % (msg.current_posx[0],msg.current_posx[1],msg.current_posx[2],msg.current_posx[3],msg.current_posx[4],msg.current_posx[5]))
39 
40  #print(" io_control_box : %d" % (msg.io_control_box))
41 
46  print(" speed : %d" % (msg.speed))
47  #print(" mastering_need : %d" % (msg.mastering_need))
48  #print(" drl_stopped : %d" % (msg.drl_stopped))
49  #print(" disconnected : %d" % (msg.disconnected))
50 msgRobotState_cb.count = 0
51 
53  rospy.Subscriber('/'+ROBOT_ID +ROBOT_MODEL+'/state', RobotState, msgRobotState_cb)
54  rospy.spin()
55  #rospy.spinner(2)
56 
57 if __name__ == "__main__":
58  rospy.init_node('dsr_simple_test_py')
59  rospy.on_shutdown(shutdown)
60 
61  t1 = threading.Thread(target=thread_subscriber)
62  t1.daemon = True
63  t1.start()
64 
65  pub_stop = rospy.Publisher('/'+ROBOT_ID +ROBOT_MODEL+'/stop', RobotStop, queue_size=10)
66 
67  set_velx(30,20) # set global task speed: 30(mm/sec), 20(deg/sec)
68  set_accx(60,40) # set global task accel: 60(mm/sec2), 40(deg/sec2)
69 
70  velx=[50, 50]
71  accx=[100, 100]
72 
73  p1= posj(0,0,0,0,0,0) #joint
74  p2= posj(0.0, 0.0, 90.0, 0.0, 90.0, 0.0) #joint
75 
76  x1= posx(400, 500, 800.0, 0.0, 180.0, 0.0) #task
77  x2= posx(400, 500, 500.0, 0.0, 180.0, 0.0) #task
78 
79  c1 = posx(559,434.5,651.5,0,180,0)
80  c2 = posx(559,434.5,251.5,0,180,0)
81 
82 
83  q0 = posj(0,0,0,0,0,0)
84  q1 = posj(10, -10, 20, -30, 10, 20)
85  q2 = posj(25, 0, 10, -50, 20, 40)
86  q3 = posj(50, 50, 50, 50, 50, 50)
87  q4 = posj(30, 10, 30, -20, 10, 60)
88  q5 = posj(20, 20, 40, 20, 0, 90)
89  qlist = [q0, q1, q2, q3, q4, q5]
90 
91  x1 = posx(600, 600, 600, 0, 175, 0)
92  x2 = posx(600, 750, 600, 0, 175, 0)
93  x3 = posx(150, 600, 450, 0, 175, 0)
94  x4 = posx(-300, 300, 300, 0, 175, 0)
95  x5 = posx(-200, 700, 500, 0, 175, 0)
96  x6 = posx(600, 600, 400, 0, 175, 0)
97  xlist = [x1, x2, x3, x4, x5, x6]
98 
99 
100  X1 = posx(370, 670, 650, 0, 180, 0)
101  X1a = posx(370, 670, 400, 0, 180, 0)
102  X1a2= posx(370, 545, 400, 0, 180, 0)
103  X1b = posx(370, 595, 400, 0, 180, 0)
104  X1b2= posx(370, 670, 400, 0, 180, 0)
105  X1c = posx(370, 420, 150, 0, 180, 0)
106  X1c2= posx(370, 545, 150, 0, 180, 0)
107  X1d = posx(370, 670, 275, 0, 180, 0)
108  X1d2= posx(370, 795, 150, 0, 180, 0)
109 
110 
111  seg11 = posb(DR_LINE, X1, radius=20)
112  seg12 = posb(DR_CIRCLE, X1a, X1a2, radius=21)
113  seg14 = posb(DR_LINE, X1b2, radius=20)
114  seg15 = posb(DR_CIRCLE, X1c, X1c2, radius=22)
115  seg16 = posb(DR_CIRCLE, X1d, X1d2, radius=23)
116  b_list1 = [seg11, seg12, seg14, seg15, seg16]
117 
118  while not rospy.is_shutdown():
119  movej(p2, vel=100, acc=100)
120  movejx(x1, vel=30, acc=60, sol=0)
121  movel(x2, velx, accx)
122  movec(c1, c2, velx, accx)
123  movesj(qlist, vel=100, acc=100)
124  movesx(xlist, vel=100, acc=100)
125  move_spiral(rev=9.5,rmax=20.0,lmax=50.0,time=20.0,axis=DR_AXIS_Z,ref=DR_TOOL)
126  move_periodic(amp =[10,0,0,0,30,0], period=1.0, atime=0.2, repeat=5, ref=DR_TOOL)
127  moveb(b_list1, vel=150, acc=250, ref=DR_BASE, mod=DR_MV_MOD_ABS)
128 
129  print 'good bye!'
def movej(fTargetPos, fTargetVel, fTargetAcc, fTargetTime=0.0, fBlendingRadius=0.0, nMoveMode=MOVE_MODE_ABSOLUTE, nBlendingType=BLENDING_SPEED_TYPE_DUPLICATE, nSyncType=0)
def movesj(fTargetPos, nPosCount, fTargetVel, fTargetAcc, fTargetTime=0.0, nMoveMode=MOVE_MODE_ABSOLUTE, nSyncType=0)
def movejx(fTargetPos, fTargetVel, fTargetAcc, fTargetTime=0.0, fBlendingRadius=0.0, nMoveReference=MOVE_REFERENCE_BASE, nMoveMode=MOVE_MODE_ABSOLUTE, nBlendingType=BLENDING_SPEED_TYPE_DUPLICATE, nSolSpace=0, nSyncType=0)
def msgRobotState_cb(msg)
def movel(fTargetPos, fTargetVel, fTargetAcc, fTargetTime=0.0, fBlendingRadius=0.0, nMoveReference=MOVE_REFERENCE_BASE, nMoveMode=MOVE_MODE_ABSOLUTE, nBlendingType=BLENDING_SPEED_TYPE_DUPLICATE, nSyncType=0)
def movesx(fTargetPos, nPosCount, fTargetVel, fTargetAcc, fTargetTime=0.0, nMoveMode=MOVE_MODE_ABSOLUTE, nMoveReference=MOVE_REFERENCE_BASE, nVelOpt=SPLINE_VELOCITY_OPTION_DEFAULT, nSyncType=0)
def moveb(fTargetPos, nPosCount, fTargetVel, fTargetAcc, fTargetTime=0.0, nMoveMode=MOVE_MODE_ABSOLUTE, nMoveReference=MOVE_REFERENCE_BASE, nSyncType=0)
def movec(fTargetPos, fTargetVel, fTargetAcc, fTargetTime=0.0, fBlendingRadius=0.0, nMoveReference=MOVE_REFERENCE_BASE, nMoveMode=MOVE_MODE_ABSOLUTE, fAngle1=0.0, fAngle2=0.0, nBlendingType=BLENDING_SPEED_TYPE_DUPLICATE, nSyncType=0)


py
Author(s):
autogenerated on Thu Jun 20 2019 19:43:32