8 from visualization_msgs.msg
import MarkerArray
9 from geometry_msgs.msg
import Point
19 if len(data.markers) > 0
and lastSize != len(data.markers[0].points):
20 t = rospy.Time(data.markers[0].header.stamp.secs, data.markers[0].header.stamp.nsecs)
22 listener.waitForTransform(fixedFrame, baseFrame, t, rospy.Duration(0.2))
23 (trans,rot) = listener.lookupTransform(fixedFrame, baseFrame, t)
24 gtPoses.append(Point(trans[0], trans[1], 0))
25 stamps.append(t.to_sec())
26 slamPoses.append(data.markers[0].points[len(data.markers[0].points)-1])
27 slamPosesInd.append(len(data.markers[0].points)-1)
28 first_xyz = numpy.empty([0,3])
29 second_xyz = numpy.empty([0,3])
31 newrow = [g.x,g.y,g.z]
32 first_xyz = numpy.vstack([first_xyz, newrow])
34 newrow = [p.x,p.y,p.z]
35 second_xyz = numpy.vstack([second_xyz, newrow])
36 first_xyz = numpy.matrix(first_xyz).transpose()
37 second_xyz = numpy.matrix(second_xyz).transpose()
39 rmse_v = numpy.sqrt(numpy.dot(trans_error,trans_error) / len(trans_error))
41 print "points= " + str(len(data.markers[0].points)) +
" added=" + str(len(slamPoses)) +
" rmse=" + str(rmse_v)
44 if len(data.markers) > 0
and len(slamPosesInd) > 0:
46 for i
in slamPosesInd:
47 slamPoses[j] = data.markers[0].points[i]
49 if len(data.markers) > 0:
50 lastSize = len(data.markers[0].points)
52 if __name__ ==
'__main__':
53 rospy.init_node(
'sync_markers_gt', anonymous=
True)
55 fixedFrame = rospy.get_param(
'~fixed_frame_id',
'world')
56 baseFrame = rospy.get_param(
'~frame_id',
'base_link_gt')
57 rospy.Subscriber(
"trajectory_node_list", MarkerArray, callback, queue_size=1)
65 fileSlam = open(
'slam_poses.txt',
'w')
66 fileGt = open(
'gt_poses.txt',
'w')
67 fileRMSE = open(
'rmse.txt',
'w')
68 print "slam= " + str(len(slamPoses))
69 print "gt= " + str(len(gtPoses))
70 print "stamps= " + str(len(stamps))
71 for c, g, t, r
in zip(slamPoses, gtPoses, stamps, rmse):
72 fileSlam.write(
'%f %f %f 0 0 0 0 1\n' % (t, c.x, c.y))
73 fileGt.write(
'%f %f %f 0 0 0 0 1\n' % (t, g.x, g.y))
74 fileRMSE.write(
'%f %f\n' % (t, r))