single_robot_mobile_circle.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 # -*- coding: utf-8 -*-
3 # ##
4 # @brief [py example gripper] gripper test for doosan robot
5 # @author Jin Hyuk Gong (jinhyuk.gong@doosan.com)
6 
7 import rospy
8 import os
9 import threading, time
10 import sys
11 import random
12 from geometry_msgs.msg import Twist
13 
14 sys.dont_write_bytecode = True
15 sys.path.append( os.path.abspath(os.path.join(os.path.dirname(__file__),"../../../../common/imp")) ) # get import pass : DSR_ROBOT.py
16 
17 # for single robot
18 ROBOT_ID = "dsr01"
19 ROBOT_MODEL = "m1013"
20 
21 RAND_MAX = 2147483647
22 
23 import DR_init
24 DR_init.__dsr__id = ROBOT_ID
25 DR_init.__dsr__model = ROBOT_MODEL
26 from DSR_ROBOT import *
27 
28 
30  msg = Twist()
31  x_odom = 0
32  z_angular = 9
33  msg.linear.x = 10
34  time_cnt = 0
35 
36  while not rospy.is_shutdown():
37  msg.linear.x = x_odom
38  msg.angular.z = z_angular
39  pubMobile.publish(msg)
40  x_odom = x_odom + 0.1
41 
42  if time_cnt > 1:
43  z_angular = z_angular + 0.005
44 
45  rospy.sleep(0.1)
46  time_cnt = time_cnt + 1
47 
48 def SET_ROBOT(id, model):
49  ROBOT_ID = id; ROBOT_MODEL= model
50 
51 def shutdown():
52  print "shutdown time!"
53  print "shutdown time!"
54  print "shutdown time!"
55 
56  pub_stop.publish(stop_mode=1) #STOP_TYPE_QUICK)
57  return 0
58 
59 # convert list to Float64MultiArray
61  _res = []
62  for i in list_src:
63  item = Float64MultiArray()
64  item.data = i
65  _res.append(item)
66  #print(_res)
67  #print(len(_res))
68  return _res
69 
70 if __name__ == "__main__":
71  #----- set target robot ---------------
72  my_robot_id = "dsr01"
73  my_robot_model = "m1013"
74  SET_ROBOT(my_robot_id, my_robot_model)
75 
76  rospy.init_node('single_robot_mobile_py')
77  rospy.on_shutdown(shutdown)
78 
79  pub_stop = rospy.Publisher('/'+ROBOT_ID +ROBOT_MODEL+'/stop', RobotStop, queue_size=10)
80  pubMobile = rospy.Publisher('/'+ROBOT_ID + '/twist_marker_server/cmd_vel', Twist, queue_size=10)
81 
82  mThread = threading.Thread(target = thread_mobile)
83  mThread.daemon = True
84  mThread.start()
85 
86  set_velx(30,20) # set global task speed: 30(mm/sec), 20(deg/sec)
87  set_accx(60,40) # set global task accel: 60(mm/sec2), 40(deg/sec2)
88 
89  velx=[50, 50]
90  accx=[100, 100]
91 
92  p1= posj(0,0,0,0,0,0) #joint
93  p2= posj(0.0, 0.0, 90.0, 0.0, 90.0, 0.0) #joint
94 
95  x1= posx(400, 500, 800.0, 0.0, 180.0, 0.0) #task
96  x2= posx(400, 500, 500.0, 0.0, 180.0, 0.0) #task
97 
98  c1 = posx(559,434.5,651.5,0,180,0)
99  c2 = posx(559,434.5,251.5,0,180,0)
100 
101 
102  q0 = posj(0,0,0,0,0,0)
103  q1 = posj(10, -10, 20, -30, 10, 20)
104  q2 = posj(25, 0, 10, -50, 20, 40)
105  q3 = posj(50, 50, 50, 50, 50, 50)
106  q4 = posj(30, 10, 30, -20, 10, 60)
107  q5 = posj(20, 20, 40, 20, 0, 90)
108  qlist = [q0, q1, q2, q3, q4, q5]
109 
110  x1 = posx(600, 600, 600, 0, 175, 0)
111  x2 = posx(600, 750, 600, 0, 175, 0)
112  x3 = posx(150, 600, 450, 0, 175, 0)
113  x4 = posx(-300, 300, 300, 0, 175, 0)
114  x5 = posx(-200, 700, 500, 0, 175, 0)
115  x6 = posx(600, 600, 400, 0, 175, 0)
116  xlist = [x1, x2, x3, x4, x5, x6]
117 
118 
119  X1 = posx(370, 670, 650, 0, 180, 0)
120  X1a = posx(370, 670, 400, 0, 180, 0)
121  X1a2= posx(370, 545, 400, 0, 180, 0)
122  X1b = posx(370, 595, 400, 0, 180, 0)
123  X1b2= posx(370, 670, 400, 0, 180, 0)
124  X1c = posx(370, 420, 150, 0, 180, 0)
125  X1c2= posx(370, 545, 150, 0, 180, 0)
126  X1d = posx(370, 670, 275, 0, 180, 0)
127  X1d2= posx(370, 795, 150, 0, 180, 0)
128 
129 
130  seg11 = posb(DR_LINE, X1, radius=20)
131  seg12 = posb(DR_CIRCLE, X1a, X1a2, radius=21)
132  seg14 = posb(DR_LINE, X1b2, radius=20)
133  seg15 = posb(DR_CIRCLE, X1c, X1c2, radius=22)
134  seg16 = posb(DR_CIRCLE, X1d, X1d2, radius=23)
135  b_list1 = [seg11, seg12, seg14, seg15, seg16]
136 
137 
138 
139  while not rospy.is_shutdown():
140  movej(p2, vel=100, acc=100)
141  movejx(x1, vel=30, acc=60)
142  movel(x2, velx, accx)
143  movec(c1, c2, velx, accx)
144  movesj(qlist, vel=100, acc=100)
145  movesx(xlist, vel=100, acc=100)
146  move_spiral(rev=9.5,rmax=20.0,lmax=50.0,time=20.0,axis=DR_AXIS_Z,ref=DR_TOOL)
147  move_periodic(amp =[10,0,0,0,30,0], period=1.0, atime=0.2, repeat=5, ref=DR_TOOL)
148  moveb(b_list1, vel=150, acc=250, ref=DR_BASE, mod=DR_MV_MOD_ABS)
149 
150 
151 
152  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 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 Sat May 18 2019 02:32:56