dsr_service_drl_basic.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 # -*- coding: utf-8 -*-
3 # ##
4 # @brief [py example basic] 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 from std_msgs.msg import String,Int32,Int32MultiArray,Float64,Float64MultiArray,MultiArrayLayout,MultiArrayDimension
11 import sys
12 sys.dont_write_bytecode = True
13 #sys.path.append( os.path.abspath(os.path.join(os.path.dirname(__file__),"../../../../common/imp")) ) # get import pass : DSR_ROBOT.py
14 #from DSR_ROBOT import *
15 
16 from dsr_msgs.msg import *
17 from dsr_msgs.srv import *
18 
19 ROBOT_ID = "dsr01"
20 ROBOT_MODEL = "m0609"
21 
22 ROBOT_SYSTEM_VIRTUAL = 1
23 ROBOT_SYSTEM_REAL = 0
24 
25 def SET_ROBOT(id, model):
26  ROBOT_ID = id; ROBOT_MODEL= model
27 
28 def shutdown():
29  print "shutdown time!"
30  print "shutdown time!"
31  print "shutdown time!"
32 
33  pub_stop.publish(stop_mode=1) #STOP_TYPE_QUICK)
34  return 0
35 
36 # convert list to Float64MultiArray
38  _res = []
39  for i in list_src:
40  item = Float64MultiArray()
41  item.data = i
42  _res.append(item)
43  #print(_res)
44  #print(len(_res))
45  return _res
46 
47 if __name__ == "__main__":
48  #----- set target robot ---------------
49  my_robot_id = "dsr01"
50  my_robot_model = "m1013"
51  SET_ROBOT(my_robot_id, my_robot_model)
52 
53  rospy.init_node('dsr_service_drl_basic_py')
54  rospy.on_shutdown(shutdown)
55 
56 
57  pub_stop = rospy.Publisher('/'+ROBOT_ID +ROBOT_MODEL+'/stop', RobotStop, queue_size=10)
58 
59  #print 'wait services'
60  rospy.wait_for_service('/'+ROBOT_ID +ROBOT_MODEL+'/drl/drl_start')
61 
62  drl_start = rospy.ServiceProxy('/'+ROBOT_ID + ROBOT_MODEL + '/drl/drl_start', DrlStart)
63  drl_stop = rospy.ServiceProxy('/'+ROBOT_ID + ROBOT_MODEL + '/drl/drl_stop', DrlStop)
64  drl_resume = rospy.ServiceProxy('/'+ROBOT_ID + ROBOT_MODEL + '/drl/drl_resume', DrlResume)
65  drl_pause = rospy.ServiceProxy('/'+ROBOT_ID + ROBOT_MODEL + '/drl/drl_pause', DrlPause)
66 
67  move_joint = rospy.ServiceProxy('/'+ROBOT_ID +ROBOT_MODEL+'/motion/move_joint', MoveJoint)
68 
69  drlCodeMove = "set_velj(50)\nset_accj(50)\nmovej([0,0,90,0,90,0])\n"
70  drlCodeHome = "movej([0,0,0,0,0,0])\n"
71  drl_start(ROBOT_SYSTEM_REAL, drlCodeMove + drlCodeHome)
72 
73  print 'good bye!'
def _ros_listToFloat64MultiArray(list_src)


py
Author(s):
autogenerated on Sat May 18 2019 02:32:55