-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enforce g2o formatting #5
Open
adthoms
wants to merge
3
commits into
mit-acl:main
Choose a base branch
from
adthoms:enforce_g2o_formatting
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -113,10 +113,10 @@ Cartan-Sync: https://bitbucket.org/jesusbriales/cartan-sync/src | |
std::vector<RelativeSEMeasurement> read_g2o_file(const std::string &filename, | ||
size_t &num_poses) { | ||
// Preallocate output vector | ||
std::vector<DPGO::RelativeSEMeasurement> measurements; | ||
std::vector<RelativeSEMeasurement> measurements; | ||
|
||
// A single measurement, whose values we will fill in | ||
DPGO::RelativeSEMeasurement measurement; | ||
RelativeSEMeasurement measurement; | ||
measurement.weight = 1.0; | ||
|
||
// A string used to contain the contents of a single line | ||
|
@@ -128,13 +128,13 @@ std::vector<RelativeSEMeasurement> read_g2o_file(const std::string &filename, | |
// Preallocate various useful quantities | ||
double dx, dy, dz, dtheta, dqx, dqy, dqz, dqw, I11, I12, I13, I14, I15, I16, | ||
I22, I23, I24, I25, I26, I33, I34, I35, I36, I44, I45, I46, I55, I56, I66; | ||
|
||
size_t i, j; | ||
|
||
// Open the file for reading | ||
std::ifstream infile(filename); | ||
|
||
num_poses = 0; | ||
// Create Pose ID set | ||
std::set<size_t> pose_ids; | ||
|
||
while (std::getline(infile, line)) { | ||
// Construct a stream from the string | ||
|
@@ -172,7 +172,6 @@ std::vector<RelativeSEMeasurement> read_g2o_file(const std::string &filename, | |
Eigen::Matrix2d TranCov; | ||
TranCov << I11, I12, I12, I22; | ||
measurement.tau = 2 / TranCov.inverse().trace(); | ||
|
||
measurement.kappa = I33; | ||
|
||
if (i+1 == j) { | ||
|
@@ -224,7 +223,6 @@ std::vector<RelativeSEMeasurement> read_g2o_file(const std::string &filename, | |
|
||
// Compute and store the optimal (information-divergence-minimizing value | ||
// of the parameter kappa | ||
|
||
Eigen::Matrix3d RotCov; | ||
RotCov << I44, I45, I46, I45, I55, I56, I46, I56, I66; | ||
measurement.kappa = 3 / (2 * RotCov.inverse().trace()); | ||
|
@@ -238,20 +236,48 @@ std::vector<RelativeSEMeasurement> read_g2o_file(const std::string &filename, | |
} else if ((token == "VERTEX_SE2") || (token == "VERTEX_SE3:QUAT")) { | ||
// This is just initialization information, so do nothing | ||
continue; | ||
} else if ((token == "FIX")) { | ||
LOG(WARNING) << "[read_g2o_file] FIX ID_SET is not supported. Skipping line..."; | ||
continue; | ||
} else { | ||
LOG(FATAL) << "Error: unrecognized type: " << token << "!"; | ||
LOG(FATAL) << "[read_g2o_file] Unrecognized type: " << token << "!"; | ||
} | ||
|
||
// Update maximum value of poses found so far | ||
size_t max_pair = std::max<double>(measurement.p1, measurement.p2); | ||
// Update pose IDs | ||
pose_ids.emplace(measurement.p1); | ||
pose_ids.emplace(measurement.p2); | ||
|
||
num_poses = ((max_pair > num_poses) ? max_pair : num_poses); | ||
measurements.push_back(measurement); | ||
} // while | ||
|
||
infile.close(); | ||
|
||
num_poses++; // Account for the use of zero-based indexing | ||
// Get first pose ID | ||
const size_t first_pose_id = *pose_ids.begin(); | ||
|
||
// Check for consecutive sequencing of pose IDs | ||
size_t prev_pose_id = first_pose_id - 1; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @adthoms This will cause overflow because |
||
for (const size_t& pose_id : pose_ids) { | ||
if (pose_id != prev_pose_id + 1) { | ||
LOG(FATAL) << "[read_g2o_file] Invalid pose ID sequencing: [" << prev_pose_id << "," << pose_id << "]. " | ||
<< "The set of pose IDs must be consecutive!"; | ||
} | ||
prev_pose_id = pose_id; | ||
} | ||
|
||
// Reindex Pose IDs from zero if necessary | ||
if (first_pose_id != 0) { | ||
LOG(WARNING) << "[read_g2o_file] Invalid first pose ID: " << first_pose_id << ". " | ||
<< "Pose IDs will be re-indexed starting from zero."; | ||
|
||
// Decrement all pose IDs by the first pose ID | ||
for (RelativeSEMeasurement& measurement : measurements) { | ||
measurement.p1 -= first_pose_id; | ||
measurement.p2 -= first_pose_id; | ||
} | ||
} | ||
|
||
num_poses = pose_ids.size(); | ||
|
||
return measurements; | ||
} | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure about adding this edge because it will change the optimal cost and solution (although probably in a negligible way), and so might confuse others who just want to access the original dataset to test other solvers.
For now, I think leaving the dataset unchanged but printing the errors in dpgo as you have implemented is a better way to go.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, it's possible that the consecutive ID assumption is only needed by odometry initialization and chordal initialization. So one could potentially just improve these initialization implementations without changing the dataset, but I will need to confirm this is the case.