Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions teaser/src/registration.cc
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,14 @@ void teaser::ScalarTLSEstimator::estimate(const Eigen::RowVectorXd& X,

// calculate weights
Eigen::RowVectorXd weights = ranges.array().square();
// the unit is m^2
double ranges_inverse_sum = weights.sum();
weights = weights.array().inverse();
int nr_centers = 2 * N;
Eigen::RowVectorXd x_hat = Eigen::MatrixXd::Zero(1, nr_centers);
Eigen::RowVectorXd x_cost = Eigen::MatrixXd::Zero(1, nr_centers);

double ranges_inverse_sum = ranges.sum();

double dot_X_weights = 0;
double dot_weights_consensus = 0;
int consensus_set_cardinal = 0;
Expand All @@ -62,13 +64,15 @@ void teaser::ScalarTLSEstimator::estimate(const Eigen::RowVectorXd& X,
consensus_set_cardinal += epsilon;
dot_weights_consensus += epsilon * weights(idx);
dot_X_weights += epsilon * weights(idx) * X(idx);
ranges_inverse_sum -= epsilon * ranges(idx);
// the unit is m^2
ranges_inverse_sum -= epsilon * ranges(idx) * ranges(idx);
sum_xi += epsilon * X(idx);
sum_xi_square += epsilon * X(idx) * X(idx);

x_hat(i) = dot_X_weights / dot_weights_consensus;

// the unit is m^2
double residual = consensus_set_cardinal * x_hat(i) * x_hat(i) + sum_xi_square - 2 * sum_xi * x_hat(i);
// the unit is m^2
x_cost(i) = residual + ranges_inverse_sum;

}
Expand Down