Skip to content

Commit 6986732

Browse files
committed
Rename frame -> scan everywhere
1 parent 989dae3 commit 6986732

File tree

11 files changed

+192
-194
lines changed

11 files changed

+192
-194
lines changed

config/25.10.08_short_verify.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
pipelines:
22
- pipeline: form
3-
name: 4_docs_match_estimates
3+
name: frame_to_scan
44

55
datasets:
66
# ncd20

form/feature/factor.hpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,8 @@ struct PlanePoint {
7373

7474
/// @brief Evaluate the residual given two poses
7575
///
76-
/// @param Ti The pose of the first frame
77-
/// @param Tj The pose of the second frame
76+
/// @param Ti The pose of the first scan
77+
/// @param Tj The pose of the second scan
7878
/// @param residual_D_Ti Optional Jacobian of the residual w.r.t. Ti
7979
/// @param residual_D_Tj Optional Jacobian of the residual w.r.t. Tj
8080
/// @return The residual vector
@@ -118,8 +118,8 @@ struct PointPoint {
118118

119119
/// @brief Evaluate the residual given two poses
120120
///
121-
/// @param Ti The pose of the first frame
122-
/// @param Tj The pose of the second frame
121+
/// @param Ti The pose of the first scan
122+
/// @param Tj The pose of the second scan
123123
/// @param residual_D_Ti Optional Jacobian of the residual w.r.t. Ti
124124
/// @param residual_D_Tj Optional Jacobian of the residual w.r.t. Tj
125125
/// @return The residual vector
@@ -151,8 +151,8 @@ class FeatureFactor : public DenseFactor {
151151

152152
/// @brief Evaluate the residual given two poses
153153
///
154-
/// @param Ti The pose of the first frame
155-
/// @param Tj The pose of the second frame
154+
/// @param Ti The pose of the first scan
155+
/// @param Tj The pose of the second scan
156156
/// @param residual_D_Ti Optional Jacobian of the residual w.r.t. Ti
157157
/// @param residual_D_Tj Optional Jacobian of the residual w.r.t. Tj
158158
/// @return The residual vector

form/form.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,12 @@ Estimator::register_scan(const std::vector<Eigen::Vector3f> &scan) noexcept {
4545
// ############################ Feature Extraction ############################ //
4646
//
4747
// ------------------------------ Initialization ------------------------------ //
48-
// This needs to go first to get the frame index
48+
// This needs to go first to get the scan index
4949
Pose3 prediction = m_constraints.predict_next();
50-
auto [frame_idx, scan_constraints] = m_constraints.step(prediction);
50+
auto [scan_idx, scan_constraints] = m_constraints.step(prediction);
5151

5252
// ----------------------------- Extract Features ----------------------------- //
53-
const auto keypoints = m_extractor.extract(scan, frame_idx);
53+
const auto keypoints = m_extractor.extract(scan, scan_idx);
5454
const auto num_keypoints =
5555
std::apply([](auto &...kps) { return (kps.size() + ...); }, keypoints);
5656

@@ -80,7 +80,7 @@ Estimator::register_scan(const std::vector<Eigen::Vector3f> &scan) noexcept {
8080

8181
// ---------------------- Semi-Linearized Optimization ---------------------- //
8282
new_values = m_constraints.optimize(true);
83-
const auto after = new_values.at<Pose3>(X(frame_idx));
83+
const auto after = new_values.at<Pose3>(X(scan_idx));
8484
const auto diff = before.localCoordinates(after).norm();
8585
if (diff < m_params.matcher.new_pose_threshold) {
8686
break;
@@ -101,14 +101,14 @@ Estimator::register_scan(const std::vector<Eigen::Vector3f> &scan) noexcept {
101101
});
102102

103103
// ---------------------------- Keyscan Selection ---------------------------- //
104-
const auto connections = [&](FrameIndex frame) {
105-
return m_constraints.num_recent_connections(frame, m_keyscanner.oldest_rf());
104+
const auto connections = [&](ScanIndex i) {
105+
return m_constraints.num_recent_connections(i, m_keyscanner.oldest_rf());
106106
};
107-
auto marg_frames = m_keyscanner.step(frame_idx, num_keypoints, connections);
107+
auto marg_scans = m_keyscanner.step(scan_idx, num_keypoints, connections);
108108

109109
// ----------------------------- Marginalization ----------------------------- //
110-
m_constraints.marginalize(marg_frames);
111-
tuple::for_each(m_keypoint_map, [&](auto &map) { map.remove(marg_frames); });
110+
m_constraints.marginalize(marg_scans);
111+
tuple::for_each(m_keypoint_map, [&](auto &map) { map.remove(marg_scans); });
112112

113113
return keypoints;
114114
}

form/mapping/keyscanner.cpp

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -26,64 +26,64 @@
2626
namespace form {
2727

2828
// ------------------------- Doers ------------------------- //
29-
std::vector<FrameIndex>
30-
KeyScanner::step(FrameIndex idx, size_t size,
31-
std::function<size_t(FrameIndex)> connections) noexcept {
29+
std::vector<ScanIndex>
30+
KeyScanner::step(ScanIndex idx, size_t size,
31+
std::function<size_t(ScanIndex)> connections) noexcept {
3232
if (idx == 0) {
33-
m_keyframes.push_back(Scan(idx, size));
33+
m_keyscans.push_back(Scan(idx, size));
3434
} else {
35-
m_recent_frames.push_back(Scan(idx, size));
35+
m_recent_scans.push_back(Scan(idx, size));
3636
}
3737

38-
std::vector<FrameIndex> marg_results;
38+
std::vector<ScanIndex> marg_results;
3939

40-
// First we handle recent frames
41-
if (m_recent_frames.size() > m_params.max_num_recent_frames) {
42-
const auto rf = m_recent_frames.front();
43-
m_recent_frames.pop_front();
40+
// First we handle recent scans
41+
if (m_recent_scans.size() > m_params.max_num_recent_scans) {
42+
const auto rf = m_recent_scans.front();
43+
m_recent_scans.pop_front();
4444

45-
// If it's a keyframe, add it to the keyframe indices
45+
// If it's a keyscan, add it to the keyscan indices
4646
auto ratio = static_cast<double>(connections(rf.idx)) /
47-
(static_cast<double>(rf.size * m_recent_frames.size()));
47+
(static_cast<double>(rf.size * m_recent_scans.size()));
4848

4949
if (ratio > m_params.keyscan_match_ratio) {
50-
m_keyframes.push_back(rf);
50+
m_keyscans.push_back(rf);
5151
}
5252
// If not, we marginalize it out
5353
else {
5454
marg_results.push_back(rf.idx);
5555
}
5656
}
5757

58-
std::set<FrameIndex> finished_keyframes;
59-
for (auto &kf : m_keyframes) {
60-
// If this keyframe is connected to a recent frame, we don't marginalize it
58+
std::set<ScanIndex> finished_keyscans;
59+
for (auto &kf : m_keyscans) {
60+
// If this keyscan is connected to a recent scan, we don't marginalize it
6161
if (connections(kf.idx) > 0) {
6262
kf.unused_count = 0;
6363
} else {
6464
++kf.unused_count;
6565
}
6666

67-
// If this keyframe has been unused for too long, we marginalize it out
68-
if (kf.unused_count > m_params.max_steps_unused_keyframe) {
67+
// If this keyscan has been unused for too long, we marginalize it out
68+
if (kf.unused_count > m_params.max_steps_unused_keyscan) {
6969
marg_results.push_back(kf.idx);
70-
finished_keyframes.insert(kf.idx);
70+
finished_keyscans.insert(kf.idx);
7171
}
7272
}
7373

74-
m_keyframes.erase(std::remove_if(m_keyframes.begin(), m_keyframes.end(),
75-
[&](const Scan &f) {
76-
return finished_keyframes.find(f.idx) !=
77-
finished_keyframes.end();
78-
}),
79-
m_keyframes.end());
74+
m_keyscans.erase(std::remove_if(m_keyscans.begin(), m_keyscans.end(),
75+
[&](const Scan &f) {
76+
return finished_keyscans.find(f.idx) !=
77+
finished_keyscans.end();
78+
}),
79+
m_keyscans.end());
8080

81-
// Marginalize keyframe we have too many keyframes
81+
// Marginalize keyscan we have too many keyscans
8282
// This should ideally never be reached in actuality
83-
if ((m_params.max_num_keyframes > 0 &&
84-
m_keyframes.size() > m_params.max_num_keyframes)) {
85-
const auto kf = m_keyframes.front();
86-
m_keyframes.pop_front();
83+
if ((m_params.max_num_keyscans > 0 &&
84+
m_keyscans.size() > m_params.max_num_keyscans)) {
85+
const auto kf = m_keyscans.front();
86+
m_keyscans.pop_front();
8787
marg_results.push_back(kf.idx);
8888
}
8989

form/mapping/keyscanner.hpp

Lines changed: 36 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -27,18 +27,18 @@
2727

2828
namespace form {
2929

30-
using FrameIndex = size_t;
30+
using ScanIndex = size_t;
3131

3232
/// @brief Scan representation
3333
struct Scan {
34-
/// @brief Index of the frame
34+
/// @brief Index of the scan
3535
size_t idx;
3636

37-
/// @brief Number of times the frame has gone unconnected to recent frames
38-
/// (only used if scan becomes a keyframe)
37+
/// @brief Number of times the scan has gone unconnected to recent scans
38+
/// (only used if scan becomes a keyscan)
3939
size_t unused_count = 0;
4040

41-
/// @brief Size of the frame (number of features)
41+
/// @brief Size of the scan (number of features)
4242
size_t size = 0;
4343

4444
/// @brief Constructor
@@ -47,18 +47,18 @@ struct Scan {
4747

4848
/// @brief Keyscan manager
4949
///
50-
/// Maintains a set of recent frames and keyframes, adding/removing them based on
51-
/// connectivity to recent frames
50+
/// Maintains a set of recent scans and keyscans, adding/removing them based on
51+
/// connectivity to recent scans
5252
class KeyScanner {
5353
public:
5454
/// @brief Parameters for the keyscanner
5555
struct Params {
56-
/// @brief Maximum number of keyframes to keep
57-
int64_t max_num_keyframes = 50;
58-
/// @brief Maximum number of steps a keyframe can go unused before being removed
59-
int64_t max_steps_unused_keyframe = 10;
60-
/// @brief Maximum number of recent frames to keep
61-
size_t max_num_recent_frames = 10;
56+
/// @brief Maximum number of keyscans to keep
57+
int64_t max_num_keyscans = 50;
58+
/// @brief Maximum number of steps a keyscan can go unused before being removed
59+
int64_t max_steps_unused_keyscan = 10;
60+
/// @brief Maximum number of recent scans to keep
61+
size_t max_num_recent_scans = 10;
6262
/// @brief Keyscan matching ratio
6363
double keyscan_match_ratio = 0.1;
6464
};
@@ -67,11 +67,11 @@ class KeyScanner {
6767
/// @brief Parameters
6868
Params m_params;
6969

70-
/// @brief Recent frames
71-
std::deque<Scan> m_recent_frames;
70+
/// @brief Recent scans
71+
std::deque<Scan> m_recent_scans;
7272

73-
/// @brief Key frames
74-
std::deque<Scan> m_keyframes;
73+
/// @brief Key scans
74+
std::deque<Scan> m_keyscans;
7575

7676
public:
7777
/// @brief Default constructor
@@ -81,36 +81,35 @@ class KeyScanner {
8181
KeyScanner(const Params &params) : m_params(params) {}
8282

8383
// ------------------------- Doers ------------------------- //
84-
/// @brief Update the keyscanner with a new frame.
84+
/// @brief Update the keyscanner with a new scan.
8585
///
86-
/// Will perform all the transitions from recent frame to keyframe and
86+
/// Will perform all the transitions from recent scan to keyscan and
8787
/// marginalization checks.
8888
///
89-
/// @param idx Index of the new frame
90-
/// @param size Size of the new frame (number of features)
91-
/// @param connections Function that returns the number of connections a frame
92-
/// has to recent frames
93-
/// @return Vector of frame indices that need to be marginalized out
94-
std::vector<FrameIndex>
95-
step(FrameIndex idx, size_t size,
96-
std::function<size_t(FrameIndex)> connections) noexcept;
89+
/// @param idx Index of the new scan
90+
/// @param size Size of the new scan (number of features)
91+
/// @param connections Function that returns the number of connections a scan
92+
/// has to recent scans
93+
/// @return Vector of scan indices that need to be marginalized out
94+
std::vector<ScanIndex> step(ScanIndex idx, size_t size,
95+
std::function<size_t(ScanIndex)> connections) noexcept;
9796

9897
// ------------------------- Getters ------------------------- //
99-
/// @brief Get the number of frames being tracked
98+
/// @brief Get the number of scans being tracked
10099
const size_t size() const noexcept {
101-
return m_keyframes.size() + m_recent_frames.size();
100+
return m_keyscans.size() + m_recent_scans.size();
102101
}
103-
/// @brief Get newest recent frame index
104-
const size_t newest_rf() const noexcept { return m_recent_frames.back().idx; }
102+
/// @brief Get newest recent scan index
103+
const size_t newest_rf() const noexcept { return m_recent_scans.back().idx; }
105104

106-
/// @brief Get oldest recent frame index
107-
const size_t oldest_rf() const noexcept { return m_recent_frames.front().idx; }
105+
/// @brief Get oldest recent scan index
106+
const size_t oldest_rf() const noexcept { return m_recent_scans.front().idx; }
108107

109-
/// @brief Get newest keyframe index
110-
const size_t newest_kf() const noexcept { return m_keyframes.back().idx; }
108+
/// @brief Get newest keyscan index
109+
const size_t newest_kf() const noexcept { return m_keyscans.back().idx; }
111110

112-
/// @brief Get oldest keyframe index
113-
const size_t oldest_kf() const noexcept { return m_keyframes.front().idx; }
111+
/// @brief Get oldest keyscan index
112+
const size_t oldest_kf() const noexcept { return m_keyscans.front().idx; }
114113
};
115114

116115
} // namespace form

form/mapping/map.hpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -99,21 +99,21 @@ struct KeypointMapParams {
9999
double min_dist_map = 0.1;
100100
};
101101

102-
/// @brief A map of keypoints for each frame
102+
/// @brief A map of keypoints for each scan
103103
///
104-
/// Stores a mapping from frame index to a vector of keypoints
104+
/// Stores a mapping from scan index to a vector of keypoints
105105
/// All keypoints are stored in their local frames
106106
/// When matching is needed, the keypoints can be transformed to the global
107-
/// frame into a voxel map using the current pose estimates.
107+
/// scan into a voxel map using the current pose estimates.
108108
template <typename Point> class KeypointMap {
109-
using FrameIndex = size_t;
109+
using ScanIndex = size_t;
110110

111111
private:
112112
/// @brief Parameters
113113
KeypointMapParams m_params;
114114

115-
/// @brief The data structure storing the keypoints for each frame
116-
tsl::robin_map<FrameIndex, std::vector<Point>> m_frame_keypoints;
115+
/// @brief The data structure storing the keypoints for each scan
116+
tsl::robin_map<ScanIndex, std::vector<Point>> m_scan_keypoints;
117117

118118
public:
119119
/// @brief Default constructor
@@ -122,17 +122,17 @@ template <typename Point> class KeypointMap {
122122
/// @brief Constructor with parameters
123123
KeypointMap(const KeypointMapParams &params) noexcept;
124124

125-
/// @brief Get a reference keypoints for a given frame, adding it in if it doesn't
125+
/// @brief Get a reference keypoints for a given scan, adding it in if it doesn't
126126
/// exist yet
127-
std::vector<Point> &get(const FrameIndex &frame_j) noexcept;
127+
std::vector<Point> &get(const ScanIndex &scan_j) noexcept;
128128

129-
/// @brief Remove the keypoints for a given frame, if they exist
130-
void remove(const FrameIndex &frame_j) noexcept;
129+
/// @brief Remove the keypoints for a given scan, if they exist
130+
void remove(const ScanIndex &scan_j) noexcept;
131131

132-
/// @brief Remove the keypoints for a list of frames, if they exist
132+
/// @brief Remove the keypoints for a list of scans, if they exist
133133
template <typename Iter> void remove(const Iter &iter) noexcept;
134134

135-
/// @brief Transform all keypoints to the global frame and insert them into a
135+
/// @brief Transform all keypoints to the global scan and insert them into a
136136
/// voxel map
137137
VoxelMap<Point> to_voxel_map(const gtsam::Values &values,
138138
double voxel_width) const noexcept;

0 commit comments

Comments
 (0)