forked from pal-robotics/gazebo_ros_link_attacher
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdetach.py
executable file
·48 lines (39 loc) · 1.29 KB
/
detach.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/usr/bin/env python
import rospy
from gazebo_ros_link_attacher.srv import Attach, AttachRequest, AttachResponse
if __name__ == '__main__':
rospy.init_node('demo_detach_links')
rospy.loginfo("Creating ServiceProxy to /link_attacher_node/detach")
attach_srv = rospy.ServiceProxy('/link_attacher_node/detach',
Attach)
attach_srv.wait_for_service()
rospy.loginfo("Created ServiceProxy to /link_attacher_node/detach")
# Link them
rospy.loginfo("Detaching cube1 and cube2")
req = AttachRequest()
req.model_name_1 = "cube1"
req.link_name_1 = "link"
req.model_name_2 = "cube2"
req.link_name_2 = "link"
attach_srv.call(req)
# From the shell:
"""
rosservice call /link_attacher_node/detach "model_name_1: 'cube1'
link_name_1: 'link'
model_name_2: 'cube2'
link_name_2: 'link'"
"""
rospy.loginfo("Attaching cube2 and cube3")
req = AttachRequest()
req.model_name_1 = "cube2"
req.link_name_1 = "link"
req.model_name_2 = "cube3"
req.link_name_2 = "link"
attach_srv.call(req)
rospy.loginfo("Attaching cube3 and cube1")
req = AttachRequest()
req.model_name_1 = "cube3"
req.link_name_1 = "link"
req.model_name_2 = "cube1"
req.link_name_2 = "link"
attach_srv.call(req)