8 if __name__ ==
'__main__':
9 rospy.init_node(
'groundtruth_tf_broadcaster')
10 fixedFrame = rospy.get_param(
'~fixed_frame_id',
'world')
11 baseFrame = rospy.get_param(
'~frame_id',
'base_link_gt')
12 offset_time = rospy.get_param(
'~offset_time', 0.0)
13 offset_x = rospy.get_param(
'~offset_x', 0.0)
14 offset_y = rospy.get_param(
'~offset_y', 0.0)
15 offset_theta = rospy.get_param(
'~offset_theta', 0.0)
16 gtFile = rospy.get_param(
'~file',
'groundtruth.txt')
17 gtFile = os.path.expanduser(gtFile)
25 for line
in open(gtFile,
'r'): 26 mylist = line.split(',')
27 if len(mylist) == 4
and not rospy.is_shutdown():
28 stamp = float(int(mylist[0]))/1000000.0 + offset_time
31 theta = float(mylist[3])
41 trans1_mat = tf.transformations.translation_matrix((x, y, 0))
42 rot1_mat = tf.transformations.quaternion_matrix(tf.transformations.quaternion_from_euler(0, 0, theta))
43 mat1 = numpy.dot(trans1_mat, rot1_mat)
45 trans2_mat = tf.transformations.translation_matrix((offset_x, offset_y, 0))
46 rot2_mat = tf.transformations.quaternion_matrix(tf.transformations.quaternion_from_euler(0, 0, offset_theta))
47 mat2 = numpy.dot(trans2_mat, rot2_mat)
49 mat3 = numpy.dot(mat1, mat2)
50 trans3 = tf.transformations.translation_from_matrix(mat3)
51 rot3 = tf.transformations.quaternion_from_matrix(mat3)
57 now = rospy.get_time()
58 while not rospy.is_shutdown()
and now < stamp:
63 now = rospy.get_time()
64 if not rospy.is_shutdown():
65 br.sendTransform(trans3,
67 rospy.Time.from_sec(stamp),