real_pick_and_place_simple.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 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 
23 def gripper_send_data(send_data):
24  srv_gripper_send_data(send_data)
25 
26 
27 def SET_ROBOT(id, model):
28  ROBOT_ID = id; ROBOT_MODEL= model
29 
30 def shutdown():
31  print "shutdown time!"
32  print "shutdown time!"
33  print "shutdown time!"
34 
35  pub_stop.publish(stop_mode=1) #STOP_TYPE_QUICK)
36  return 0
37 
38 # convert list to Float64MultiArray
40  _res = []
41  for i in list_src:
42  item = Float64MultiArray()
43  item.data = i
44  _res.append(item)
45  #print(_res)
46  #print(len(_res))
47  return _res
48 
49 if __name__ == "__main__":
50  #----- set target robot ---------------
51  my_robot_id = "dsr01"
52  my_robot_model = "m1013"
53  SET_ROBOT(my_robot_id, my_robot_model)
54 
55  rospy.init_node('pick_and_place_simple_py')
56  rospy.on_shutdown(shutdown)
57 
58 
59  pub_stop = rospy.Publisher('/'+ROBOT_ID +ROBOT_MODEL+'/stop', RobotStop, queue_size=10)
60 
61  #print 'wait services'
62  #rospy.wait_for_service('/'+ROBOT_ID +ROBOT_MODEL+'/drl/drl_start')
63 
64  srv_robotiq_2f_open = rospy.ServiceProxy('/' + ROBOT_ID + ROBOT_MODEL + '/gripper/serial_send_data', SerialSendData)
65 
66  p0 = posj(0, 0, 0, 0, 0, 0)
67  p1 = posj(0, 0, 90, 0, 90, 0)
68  p2 = posj(180, 0, 90, 0, 90, 0)
69 
70  x1 = posx(0, 0, -200, 0, 0, 0)
71  x2 = posx(0, 0, 200, 0, 0, 0)
72  velx = [50, 50]
73  accx = [100, 100]
74 
75  init_data = bytes(b'\0x09\0x10\0x03\0xE8\0x00\0x03\0x06\0x00\0x00\0x00\0x00\0x00\0x00\0x00\0x73\0x30')
76  activation_data = bytes(b'0x09\0x10\0x03\0xE8\0x00\0x03\0x06\0x01\0x00\0x00\0x00\0x00\0x00\0x72\0xE1')
77  open_data = bytes(b'0x09\0x10\0x03\0xE8\0x00\0x03\0x06\0x09\0x00\0x00\0x00\0xFF\0xFF\0x72\0x19')
78  close_data = bytes(b'0x09\0x10\0x03\0xE8\0x00\0x03\0x06\0x09\0x00\0x00\0xFF\0xFF\0xFF\0x42\0x29')
79 
80  time_cnt = 0
81 
82  while not rospy.is_shutdown():
83 
84  if time_cnt == 0:
85  gripper_send_data(init_data)
86  rospy.sleep(4)
87  gripper_send_data(activation_data)
88  rospy.sleep(4)
89 
90  gripper_send_data(open_data)
91  rospy.sleep(4)
92  gripper_send_data(close_data)
93  rospy.sleep(4)
94 
95 
96 
97  print 'good bye!'


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