Skip to content

Commit 2e7a768

Browse files
committed
added comments
1 parent 79e67e3 commit 2e7a768

File tree

1 file changed

+28
-6
lines changed

1 file changed

+28
-6
lines changed

Mapping.py

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,22 @@
77
from getPointCloud import getPointCloudPolarInd
88

99
# Thresholds
10-
ROT_THRESHOLD = 0.2 # radians
11-
TRANS_THRESHOLD = 2.0 # meters
12-
TRANS_THRESHOLD_SQ = TRANS_THRESHOLD * TRANS_THRESHOLD # meters^2
10+
ROT_THRESHOLD = 0.2 # radians
11+
TRANS_THRESHOLD = 2.0 # meters
12+
TRANS_THRESHOLD_SQ = TRANS_THRESHOLD * TRANS_THRESHOLD # meters^2
13+
1314

1415
# Keyframe class
1516
class Keyframe():
1617

1718
def __init__(self, pose: np.ndarray, featurePoints: np.ndarray,
1819
radarPolarImg: np.ndarray) -> None:
20+
'''
21+
@brief Keyframe class. Contains pose, feature points and point cloud information
22+
@param[in] pose (3 x 1) Pose information [x, y, th] in (m, m, rad) # TODO: Confirm these units
23+
@param[in] featurePoints (K x 2) Tracked feature points from previous keyframe
24+
@param[in] radarPolarImg (M x N) Radar polar (range-azimuth) image
25+
'''
1926
self.pose = pose
2027
self.featurePoints = featurePoints # set of (tracked) feature points
2128
self.radarPolarImg = radarPolarImg # radar polar image
@@ -30,6 +37,7 @@ def __init__(self, pose: np.ndarray, featurePoints: np.ndarray,
3037
# '''
3138
# MAX_RANGE_CLIP_DEFAULT
3239

40+
3341
# Map class
3442
class Map():
3543

@@ -46,7 +54,11 @@ def __init__(self, sequenceName: str, estTraj: Trajectory,
4654
self.keyframes = []
4755

4856
# TODO: might not want to make keyframe before adding it
49-
def isGoodKeyframe(self, keyframe: Keyframe):
57+
def isGoodKeyframe(self, keyframe: Keyframe) -> bool:
58+
'''
59+
@brief Check if a keyframe is good for adding using information about relative rotation and translation
60+
@return If keyframe passes checks
61+
'''
5062
# Get information of prev KF's pose
5163
prevKF = self.keyframes[-1]
5264
srcPose = prevKF.pose
@@ -62,14 +74,24 @@ def isGoodKeyframe(self, keyframe: Keyframe):
6274
return True
6375

6476
# Check translation condition
65-
deltaTrans = (srcPose[0:2] - targetPose[0:2]) ** 2
77+
deltaTrans = (srcPose[0:2] - targetPose[0:2])**2
6678
deltaTrans = deltaTrans.sum()
6779

6880
if (deltaTrans >= TRANS_THRESHOLD_SQ):
6981
return True
7082

7183
return False
7284

73-
def addKeyframe(self, keyframe: Keyframe):
85+
def addKeyframe(self, keyframe: Keyframe) -> None:
86+
'''
87+
@brief Add a keyframe to the running pose graph
88+
@param[in] keyframe Keyframe to add
89+
'''
7490
self.keyframes.append(keyframe)
91+
92+
def bundleAdjustment(self) -> None:
93+
'''
94+
@brief Perform bundle adjustment on the last 2 keyframes
95+
@return None
96+
'''
7597
pass

0 commit comments

Comments
 (0)