11 sys.dont_write_bytecode =
True 12 sys.path.append( os.path.abspath(os.path.join(os.path.dirname(__file__),
"../../../../common/imp")) )
23 from DSR_ROBOT
import *
42 self.lock.append( threading.Lock() )
43 self.bIsWait.append(
False)
53 self.
lock[r].acquire()
60 self.
lock[r].release()
69 for i
in range(self.
nRobot):
74 for i
in range(self.
nRobot):
75 self.
lock[i].release()
84 print "shutdown time!" 85 print "shutdown time!" 86 print "shutdown time!" 88 pub_stop_r1.publish(stop_mode=STOP_TYPE_QUICK)
89 pub_stop_r2.publish(stop_mode=STOP_TYPE_QUICK)
94 msgRobotState_cb_r1.count += 1
96 if (0==(msgRobotState_cb_r1.count % 100)):
97 rospy.loginfo(
"________ ROBOT[1] STATUS ________")
98 print(
" robot_state : %d" % (msg.robot_state))
99 print(
" robot_state_str : %s" % (msg.robot_state_str))
100 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]))
108 print(
" speed : %d" % (msg.speed))
112 msgRobotState_cb_r1.count = 0
115 msgRobotState_cb_r2.count += 1
117 if (0==(msgRobotState_cb_r2.count % 100)):
118 rospy.loginfo(
"________ ROBOT[2] STATUS ________")
119 print(
" robot_state : %d" % (msg.robot_state))
120 print(
" robot_state_str : %s" % (msg.robot_state_str))
121 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]))
129 print(
" speed : %d" % (msg.speed))
133 msgRobotState_cb_r2.count = 0
136 rospy.Subscriber(
'/'+ robot_id + robot_model +
'/state', RobotState, msgRobotState_cb_r1)
141 rospy.Subscriber(
'/'+ robot_id + robot_model +
'/state', RobotState, msgRobotState_cb_r2)
147 JReady = posj(0, -20, 110, 0, 60, 0)
148 J00 = posj(-180, 0, -145, 0, -35, 0)
149 J01r = posj(-180.0, 71.4, -145.0, 0.0, -9.7, 0.0)
150 J02r = posj(-180.0, 67.7, -144.0, 0.0, 76.3, 0.0)
151 J03r = posj(-180.0, 0.0, 0.0, 0.0, 0.0, 0.0)
152 J04r = posj(-90.0, 0.0, 0.0, 0.0, 0.0, 0.0)
153 J04r1 = posj(-90.0, 30.0, -60.0, 0.0, 30.0, -0.0)
154 J04r2 = posj(-90.0, -45.0, 90.0, 0.0, -45.0, -0.0)
155 J04r3 = posj(-90.0, 60.0, -120.0, 0.0, 60.0, -0.0)
156 J04r4 = posj(-90.0, 0.0, -0.0, 0.0, 0.0, -0.0)
157 J05r = posj(-144.0, -4.0, -84.8, -90.9, 54.0, -1.1)
158 J07r = posj(-152.4, 12.4, -78.6, 18.7, -68.3, -37.7)
159 J08r = posj(-90.0, 30.0, -120.0, -90.0, -90.0, 0.0)
160 JEnd = posj(0.0, -12.6, 101.1, 0.0, 91.5, -0.0)
161 dREL1 = posx(0, 0, 350, 0, 0, 0)
162 dREL2 = posx(0, 0, -350, 0, 0, 0)
167 J1 = posj(81.2, 20.8, 127.8, 162.5, 56.1, -37.1)
168 X0 = posx(-88.7, 799.0, 182.3, 95.7, 93.7, 133.9)
169 X1 = posx(304.2, 871.8, 141.5, 99.5, 84.9, 133.4)
170 X2 = posx(437.1, 876.9, 362.1, 99.6, 84.0, 132.1)
171 X3 = posx(-57.9, 782.4, 478.4, 99.6, 84.0, 132.1)
172 amp = [0, 0, 0, 30, 30, 0]
173 period = [0, 0, 0, 3, 6, 0]
174 x01 = [423.6, 334.5, 651.2, 84.7, -180.0, 84.7]
175 x02 = [423.6, 34.5, 951.2, 68.2, -180.0, 68.2]
176 x03 = [423.6, -265.5, 651.2, 76.1, -180.0, 76.1]
177 x04 = [423.6, 34.5, 351.2, 81.3, -180.0, 81.3]
183 r = CDsrRobot(robot_id, robot_model)
185 while not rospy.is_shutdown():
187 RobotSync.Wait(nRobotID)
188 r.movej(JReady, 20, 20)
196 RobotSync.Wait(nRobotID)
197 r.movej(J1, 20, 20, 0)
199 RobotSync.Wait(nRobotID)
200 r.movel(X3, velx, accx, 2.5)
202 except Exception
as err:
204 rospy.loginfo(
"Runtime Exception : %s" % err)
210 r = CDsrRobot(robot_id, robot_model)
212 while not rospy.is_shutdown():
214 RobotSync.Wait(nRobotID)
215 r.movej(JReady, 20, 20)
223 RobotSync.Wait(nRobotID)
224 r.movej(J1, 20, 20, 0)
226 RobotSync.Wait(nRobotID)
227 r.movel(X3, velx, accx, 2.5)
229 except Exception
as err:
231 rospy.loginfo(
"Runtime Exception : %s" % err)
234 if __name__ ==
"__main__":
235 rospy.init_node(
'm1013x2_sync_py')
236 rospy.on_shutdown(shutdown)
238 robot_id1 =
"dsr01"; robot_model1 =
"m1013" 239 robot_id2 =
"dsr02"; robot_model2 =
"m1013" 241 pub_stop_r1 = rospy.Publisher(
'/'+ robot_id1 + robot_model1 +
'/stop', RobotStop, queue_size=10)
242 pub_stop_r2 = rospy.Publisher(
'/'+ robot_id2 + robot_model2 +
'/stop', RobotStop, queue_size=10)
245 t1 = threading.Thread(target=thread_subscriber_r1, args=(robot_id1, robot_model1)) 249 t2 = threading.Thread(target=thread_subscriber_r2, args=(robot_id2, robot_model2)) 255 t1 = threading.Thread(target=thread_robot1, args=(robot_id1, robot_model1))
259 t2 = threading.Thread(target=thread_robot2, args=(robot_id2, robot_model2))
265 while not rospy.is_shutdown():
267 RobotSync.WakeUpAll()
def thread_robot2(robot_id, robot_model)
def thread_subscriber_r1(robot_id, robot_model)
def msgRobotState_cb_r2(msg)
def thread_robot1(robot_id, robot_model)
def thread_subscriber_r2(robot_id, robot_model)
def msgRobotState_cb_r1(msg)