3 This node publishes tf transforms between the frame_id set in the config file and the beacon positions in that zone. 4 You can use these transforms for visualization in rviz to make sure you have set up your environment correctly. 7 - beacon.frame_id -> beacon.eid 8 Transforms for all zones and beacons defined in the config file. Transforms are broadcasted from the zone 9 frame_id to the position of the beacon in that frame 12 - ~config_file (string, default='config/zones.yml'): 13 Path to the configuration file of zones and beacons relative to the package directory 14 - ~rate (double, default=0.1): 15 The publishing rate of transforms in transforms per second 22 from geometry_msgs.msg
import TransformStamped
28 Get all beacons from the configuration file and store them in a list. Then publish tf transforms for every beacon 29 from the zone's frame_id to the position of the beacon. 33 config_dir = rospy.get_param(
'~config_file')
if rospy.has_param(
'~config_file')
else 'config/zones.yml' 34 abs_dir = os.path.join(rospkg.RosPack().get_path(
'indoor_positioning'), config_dir)
40 for z
in positioning.zones:
42 self.beacons.append(b)
45 self.
br = tf2_ros.StaticTransformBroadcaster()
48 self.
rate = rospy.Rate(rospy.get_param(
'~rate'))
if rospy.has_param(
'~rate')
else rospy.Rate(0.1)
51 """Publish static tfs for beacon positions and zone polygons""" 52 tf = TransformStamped()
53 while not rospy.is_shutdown():
55 tf.header.stamp = rospy.Time.now()
57 tf.header.frame_id = b.frame_id
58 tf.child_frame_id = b.eid
60 tf.transform.translation.x = b.position[0]
61 tf.transform.translation.y = b.position[1]
62 tf.transform.translation.z = b.position[2]
64 tf.transform.rotation.x = 0
65 tf.transform.rotation.y = 0
66 tf.transform.rotation.z = 0
67 tf.transform.rotation.w = 1
69 self.br.sendTransform(tf)
75 if __name__ ==
'__main__':
77 rospy.init_node(
'ips_map', anonymous=
True)
83 except rospy.ROSInterruptException: