dwm1001_anchorService.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 """ For more info on the documentation go to https://www.decawave.com/sites/default/files/dwm1001-api-guide.pdf
3 """
4 
5 from dwm1001_systemDefinitions import SYS_DEFS
6 
7 
8 __author__ = SYS_DEFS.AUTHOR
9 __version__ = SYS_DEFS.VERSION
10 __maintainer__ = SYS_DEFS.MAINTAINER
11 __email__ = SYS_DEFS.EMAIL
12 __status__ = SYS_DEFS.STATUS
13 
14 
15 import rospy
16 from localizer_dwm1001.msg import Anchor
17 from localizer_dwm1001.msg import Tag
18 from localizer_dwm1001.srv import Anchor_0
19 from localizer_dwm1001.srv import Tag_srv
20 from localizer_dwm1001.srv import Anchor_1
21 from localizer_dwm1001.srv import Anchor_2
22 from localizer_dwm1001.srv import Anchor_3
23 from std_srvs.srv import Trigger, TriggerResponse
24 
25 anchor_0 = Anchor()
26 anchor_1 = Anchor()
27 anchor_2 = Anchor()
28 anchor_3 = Anchor()
29 tag = Tag()
30 
31 
32 def triggerResponseAnchor0( request):
33  return (anchor_0.x, anchor_0.y, anchor_0.z)
34 
35 def triggerResponseAnchor1( request):
36  return (anchor_1.x, anchor_1.y, anchor_1.z)
37 
38 def triggerResponseAnchor2( request):
39  return (anchor_2.x, anchor_2.y, anchor_2.z)
40 
41 def triggerResponseAnchor3( request):
42  return (anchor_3.x, anchor_3.y, anchor_3.z)
43 
44 def triggerResponseTag( request):
45  return (tag.x, tag.y, tag.z)
46 
47 
48 
49 
50 def Anchor0callback(data):
51  global anchor_0
52  anchor_0 = data
53 
54 def Anchor1callback(data):
55  global anchor_1
56  anchor_1 = data
57 
58 def Anchor2callback(data):
59  global anchor_2
60  anchor_2 = data
61 
62 def Anchor3callback(data):
63  global anchor_3
64  anchor_3 = data
65 
66 def TagCallback(data):
67  global tag
68  tag = data
69 
70 
71 
72 rospy.init_node('dwm1001_service')
73 rospy.Subscriber("/dwm1001/anchor0", Anchor, Anchor0callback)
74 rospy.Subscriber("/dwm1001/anchor1", Anchor, Anchor1callback)
75 rospy.Subscriber("/dwm1001/anchor2", Anchor, Anchor2callback)
76 rospy.Subscriber("/dwm1001/anchor3", Anchor, Anchor3callback)
77 rospy.Subscriber("/dwm1001/tag", Tag, TagCallback)
78 rospy.Service('/Anchor_0', Anchor_0, triggerResponseAnchor0)
79 rospy.Service('/Anchor_1', Anchor_1, triggerResponseAnchor1)
80 rospy.Service('/Anchor_2', Anchor_2, triggerResponseAnchor2)
81 rospy.Service('/Anchor_3', Anchor_3, triggerResponseAnchor3)
82 rospy.Service('/Tag', Tag_srv, triggerResponseTag)
83 
84 rospy.spin()
85 


dwm1001_ros
Author(s):
autogenerated on Mon Jun 10 2019 13:05:20