dsr_service_drl_simple.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 
16 ROBOT_SYSTEM_VIRTUAL = 1
17 ROBOT_SYSTEM_REAL = 0
18 
19 ROBOT_ID = "dsr01"
20 ROBOT_MODEL = "m1013"
21 import DR_init
22 DR_init.__dsr__id = ROBOT_ID
23 DR_init.__dsr__model = ROBOT_MODEL
24 from DSR_ROBOT import *
25 
26 def shutdown():
27  print "shutdown time!"
28  print "shutdown time!"
29  print "shutdown time!"
30 
31  pub_stop.publish(stop_mode=STOP_TYPE_QUICK)
32  return 0
33 
35  msgRobotState_cb.count += 1
36 
37  if (0==(msgRobotState_cb.count % 100)):
38  rospy.loginfo("________ ROBOT STATUS ________")
39  print(" robot_state : %d" % (msg.robot_state))
40  print(" robot_state_str : %s" % (msg.robot_state_str))
41  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]))
42  #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]))
43 
44  #print(" io_control_box : %d" % (msg.io_control_box))
45 
50  print(" speed : %d" % (msg.speed))
51  #print(" mastering_need : %d" % (msg.mastering_need))
52  #print(" drl_stopped : %d" % (msg.drl_stopped))
53  #print(" disconnected : %d" % (msg.disconnected))
54 msgRobotState_cb.count = 0
55 
57  rospy.Subscriber('/'+ROBOT_ID +ROBOT_MODEL+'/state', RobotState, msgRobotState_cb)
58  rospy.spin()
59  #rospy.spinner(2)
60 
61 if __name__ == "__main__":
62  rospy.init_node('dsr_service_drl_simple_py')
63  rospy.on_shutdown(shutdown)
64 
65  t1 = threading.Thread(target=thread_subscriber)
66  t1.daemon = True
67  t1.start()
68 
69  pub_stop = rospy.Publisher('/'+ROBOT_ID +ROBOT_MODEL+'/stop', RobotStop, queue_size=10)
70 
71  drlCodeMove = "set_velj(50)\nset_accj(50)\nmovej([0,0,90,0,90,0])\n"
72  drlCodeReset = "movej([0,0,0,0,0,0])\n"
73  drl_script_run(ROBOT_SYSTEM_VIRTUAL, drlCodeMove + drlCodeReset)
74  while not rospy.is_shutdown():
75  pass
76  print 'good bye!'


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