hardware_ros_driver_template.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 # -- coding: utf-8 --
3 # license removed for brevity
4 
5 #########################################################################################
6 # INSTRUCTIONS #
7 #########################################################################################
8 # TODO: ASSUME THAT YOU HAVE A SYSTEM WITH 4 ANCHORS.
9 #
10 # LET'S SAY THE IDS OF ANCHORS ARE:
11 # 101, 102, 103 and 104.
12 #
13 # AND THEIR COORDINATES (unit: meter):
14 # 101: [2.675, -0.09, 1.94]
15 # 102: [3.42, 4.58, 2.07]
16 # 103: [12.475, -0.015, 2.4]
17 # 104: [12.473, 4.543, 2.35]
18 #
19 # THE MOST IMPORTANT THING IN HERE IS THAT; ANCHOR WITH MINIMUM ID MUST BE
20 # THE "SYNCHRONIZER" OF THE SYSTEM. SO, "ANCHOR 101" MUST BE THE SYNCHRONIZER IN THAT
21 # SYSTEM.
22 #
23 # BASED ON THIS INFORMATION, TDOA VALUES OF ANCHORS SHOULD BE LIKE THAT:
24 # "TDOA_102_101",
25 # "TDOA_103_101" and
26 # "TDOA_104_101"
27 #
28 # NOTE: THESE INFORMATIONS MENTIONED ABOVE SHOULD BE READABLE FROM YOUR UWB HARDWARE !!!
29 #
30 # SINCE WE HAVE THE ALL INFORMATION ABOUT THE ANCHORS, LETS TALK ABOUT HOW TO PUBLISH
31 # ALL OF THAT DATA THROUGH "AnchorScan.msg".
32 #########################################################################################
33 
34 # Import essential libraries
35 # If exists, add additional libraries according to your driver.
36 import time
37 import rospy
38 
39 from hardware_driver_pkg.msg import AnchorScan
40 
41 
42 def read_data():
43 
44  # TODO: Read your anchor information from sensors
45  # in here.
46  # Write your own function in here.
47 
48 
49 
51 
52  # Initialize ros node.
53  rospy.init_node("hardware_ros_driver_template", anonymous = True)
54 
55  # This line declares that your node is publishing to the IPS topic using the message type AnchorScan.
56  # DO NOT CHANGE !!!
57  pub = rospy.Publisher('IPS', AnchorScan, queue_size = 2)
58  rate = rospy.Rate(5)
59 
60  # Get data of anchors.
61  read_data()
62 
63  while not rospy.is_shutdown():
64 
65  # Create a msg object.
66  msg = AnchorScan()
67 
68  # Get ROS Time in here.
69  # DO NOT CHANGE !!!
70  msg.header.stamp = rospy.Time.now()
71 
72 
73  msg.AnchorID = [101, 102, 103, 104] # IDs of anchors.
74  # This value must be read from the sensor.
75  # This is the example of the content.
76 
77  msg.x = [2.675, 3.42, 12.475, 12.473] # x coordinates of anchors
78  # This value must be read from the sensor.
79  # This is the example of the content.
80 
81  msg.y = [-0.09, 4.58, -0.015, 4.543] # y coordinates of anchors
82  # This value must be read from the sensor.
83  # This is the example of the content.
84 
85  msg.z = [1.94, 2.07, 2.4, 2.35] # z coordinates of anchors
86  # This value must be read from the sensor.
87  # This is the example of the content.
88 
89  msg.tdoa_of_anchors = [TDOA_102_101, TDOA_103_101, TDOA_104_101] # TDOA values of anchors
90  # This value must be read from the sensor.
91  # This is the example of the content.
92 
93  pub.publish(msg)
94  rate.sleep()
95 
96 
97 if __name__ == '__main__':
98  try:
100  except rospy.ROSInterruptException:
101  pass


uwb_hardware_driver
Author(s):
autogenerated on Wed Dec 18 2019 03:20:46