-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Add odometry term to optimization problem (wip) #456
Add odometry term to optimization problem (wip) #456
Conversation
@@ -164,6 +164,15 @@ void SparsePoseGraph::AddImuData(const int trajectory_id, | |||
}); | |||
} | |||
|
|||
void SparsePoseGraph::AddOdometerData(const int trajectory_id, | |||
const sensor::OdometryData odometry_data) { | |||
|
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.
Remove empty line?
@@ -97,6 +97,9 @@ class SparsePoseGraph : public mapping::SparsePoseGraph { | |||
override EXCLUDES(mutex_); | |||
std::vector<Constraint> constraints() override EXCLUDES(mutex_); | |||
|
|||
void AddOdometerData(const int trajectory_id, |
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.
Move right after AddImuData()
similar to the .cc
file?
@@ -23,6 +23,7 @@ | |||
#include <memory> | |||
#include <string> | |||
#include <vector> | |||
#include <cartographer/sensor/odometry_data.h> |
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.
Style: This belongs to the next group of includes in alphabetical order.
@@ -78,6 +79,9 @@ class OptimizationProblem { | |||
int num_trimmed_nodes(int trajectory_id) const; | |||
int num_trimmed_submaps(int trajectory_id) const; | |||
|
|||
void AddOdometerData(const int trajectory_id, |
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.
Move right after to AddImuData()
as in the .cc
?
@@ -22,6 +22,7 @@ | |||
#include <map> | |||
#include <set> | |||
#include <vector> | |||
#include <cartographer/sensor/odometry_data.h> |
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.
Style: Move to the next block of includes.
.pose, | ||
0.3, 30.})), | ||
nullptr /* loss function */, | ||
C_nodes[trajectory_id][odometry_data_index - 1].data(), |
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.
This seems wrong: indices of nodes and odometry data are different in general since usually odometry has a higher frequency. I think what you want to do is look at the time stamps of two consecutive nodes, then use the data in odometry_data_
to compute the relative change expected according to odometry. Since you most likely do not have the exact timestamp in the odometry data, you'd have to interpolate between two odometry poses, once for the timestamp of the first node and once for the timestamp of the second node.
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.
Yes, thanks. I'm currently working on it.
@@ -81,6 +81,56 @@ class SpaCostFunction { | |||
const Constraint::Pose pose_; | |||
}; | |||
|
|||
class WarpedSpaCostFunction { |
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 suggest leaving this out for now. Let's keep the focus of this PR on introducing odometry to the optimization. Adding scaling factors can be done in a follow up PR.
C_odometry[trajectory_id].data()); | ||
} | ||
} | ||
|
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.
Since we now tie together consecutive scans using odometry, the following code should be dropped/changed. As I see it odometry can take the place of
node_data_[trajectory_id][node_data_index - 1]
.initial_point_cloud_pose.inverse() *
node_data_[trajectory_id][node_data_index]
.initial_point_cloud_pose
I'd suggest changing the code to have one loop and either use a new computation of this relative pose using odometry if available, or the old code otherwise.
If you would like to merge a smaller PR sooner, feel free to send a PR containing just the code that moves odometry data to the optimization problem without making use of it yet. |
Please take another look :) |
@@ -78,6 +78,8 @@ class SparsePoseGraph : public mapping::SparsePoseGraph { | |||
|
|||
// Adds new IMU data to be used in the optimization. | |||
void AddImuData(int trajectory_id, const sensor::ImuData& imu_data); | |||
void AddOdometerData(const int trajectory_id, | |||
const sensor::OdometryData data); |
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.
Take by const&
? And please use the same argument name as in the implementation for readability: odometry_data
. Similar in the optimization problem.
@@ -78,6 +78,8 @@ class SparsePoseGraph : public mapping::SparsePoseGraph { | |||
|
|||
// Adds new IMU data to be used in the optimization. | |||
void AddImuData(int trajectory_id, const sensor::ImuData& imu_data); | |||
void AddOdometerData(const int trajectory_id, |
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.
Drop the const
of the const int
argument? It is an implementation detail not needed in the header file. Similar in the optimization problem.
node_data_[trajectory_id][node_data_index].time) && | ||
odometry_data_[trajectory_id].Has( | ||
node_data_[trajectory_id][node_data_index - 1].time)) { | ||
problem.AddResidualBlock( |
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.
This is a lot of duplication. How about extracting the relative_pose
, e.g.
const transform::Rigid2d relative_pose = odometry_available ? ... : ...
problem.AddResidualBlock(
...
Ok ready for another round :) |
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.
Just two nits.
@@ -59,6 +61,8 @@ class OptimizationProblem { | |||
OptimizationProblem& operator=(const OptimizationProblem&) = delete; | |||
|
|||
void AddImuData(int trajectory_id, const sensor::ImuData& imu_data); | |||
void AddOdometerData(int trajectory_id, | |||
const sensor::OdometryData odometry_data); |
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.
const&
?
for (size_t trajectory_id = 0; trajectory_id != node_data_.size(); | ||
++trajectory_id) { | ||
for (size_t node_data_index = 1; | ||
node_data_index < node_data_[trajectory_id].size(); | ||
++node_data_index) { | ||
bool odometry_available = |
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.
const
?
Done |
Implementation of cartographer-project#422 by @ojura. Original feature idea and implementation by @jihoonl.
This is to address #370 , but it's still work in progress. However since there are a lot of changes related to odometry happening these days I felt it's better to come forward with some intermediate state to avoid double work.
A detailed review on this is probably a waste of time but i'm happy for some directions
Unaddressed problems are: