6
6
# import ros packages
7
7
import rospy
8
8
from geometry_msgs .msg import Pose , PoseWithCovarianceStamped
9
+ from std_msgs .msg import Bool
9
10
10
11
# Import other required packages
11
12
import numpy as np
@@ -26,6 +27,9 @@ def __init__(self,trueX,trueY,trueZ,
26
27
self .trueOrientationW = trueOrientationW
27
28
self .totalDataPoints = totalDataPoints
28
29
30
+ # Only store data if board is detected
31
+ self .isBoardDetected = False
32
+
29
33
# Indices to track how many data points we have read in out of the total
30
34
self .indexRaw = 0
31
35
self .indexEKF = 0
@@ -39,11 +43,15 @@ def __init__(self,trueX,trueY,trueZ,
39
43
self .arucoRawMeanAndStd = np .zeros ((7 ,2 ))
40
44
self .arucoEKFMeanAndStd = np .zeros ((7 ,2 ))
41
45
46
+ # Update whether marker is detected or not
47
+ def updateMarkerDetected (self , msg ):
48
+ self .isBoardDetected = msg .data
49
+
42
50
# Record raw aruco error
43
51
def exportRaw (self ,pose ):
44
52
45
53
# Collect up to specified number of data points
46
- if self .indexRaw < self .totalDataPoints :
54
+ if self .indexRaw < self .totalDataPoints and self . isBoardDetected :
47
55
48
56
# Store raw error in the next open array index
49
57
self .arucoRaw [0 ][self .indexRaw ] = pose .position .x - self .trueX
@@ -61,7 +69,7 @@ def exportRaw(self,pose):
61
69
def exportFiltered (self ,pose ):
62
70
63
71
# Collect up to specified number of data points
64
- if self .indexEKF < self .totalDataPoints :
72
+ if self .indexEKF < self .totalDataPoints and self . isBoardDetected :
65
73
66
74
# Store ekf pose error in the next open array index
67
75
self .arucoEKF [0 ][self .indexEKF ] = pose .position .x - self .trueX
@@ -78,6 +86,8 @@ def exportFiltered(self,pose):
78
86
# Calculate mean and standard deviation
79
87
def calculateMeanAndStd (self ):
80
88
89
+ rospy .loginfo (self .arucoRaw [2 ])
90
+
81
91
# Calculates the raw and ekf mean and standard deviation in all dimensions
82
92
for x in range (7 ):
83
93
self .arucoRawMeanAndStd [x ][0 ] = np .mean (self .arucoRaw [x ])
@@ -111,6 +121,7 @@ def calculateMeanAndStd(self):
111
121
# Create subscribers to raw and filtered pose topics
112
122
poseSubscriber_raw = rospy .Subscriber ('aruco/pose_raw' , Pose , aruco_pose_tracker .exportRaw )
113
123
poseSubscriber_filter_cov = rospy .Subscriber ('ekf/pose_filtered' , Pose , aruco_pose_tracker .exportFiltered )
124
+ markerDetectedSub = rospy .Subscriber ('aruco/marker_detected' , Bool , aruco_pose_tracker .updateMarkerDetected )
114
125
115
126
# Wait until enough data points have been collected
116
127
while aruco_pose_tracker .indexRaw < totalDataPoints and \
0 commit comments