Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
wolf
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mobile_robotics
wolf_projects
wolf_lib
wolf
Commits
1a95699e
There was a problem fetching the pipeline metadata.
Commit
1a95699e
authored
7 years ago
by
Joan Vallvé Navarro
Browse files
Options
Downloads
Patches
Plain Diff
Changed avoidSingularCovariance
parent
6e923a62
No related branches found
No related tags found
1 merge request
!207
FeatureBase: covariance, information, square root information upper matrices
Pipeline
#
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/feature_base.cpp
+21
-9
21 additions, 9 deletions
src/feature_base.cpp
src/feature_base.h
+1
-1
1 addition, 1 deletion
src/feature_base.h
with
22 additions
and
10 deletions
src/feature_base.cpp
+
21
−
9
View file @
1a95699e
...
@@ -96,7 +96,7 @@ void FeatureBase::setMeasurementCovariance(const Eigen::MatrixXs & _meas_cov)
...
@@ -96,7 +96,7 @@ void FeatureBase::setMeasurementCovariance(const Eigen::MatrixXs & _meas_cov)
measurement_covariance_
=
_meas_cov
.
selfadjointView
<
Eigen
::
Upper
>
();
measurement_covariance_
=
_meas_cov
.
selfadjointView
<
Eigen
::
Upper
>
();
// Avoid singular covariance
// Avoid singular covariance
avoidSing
le
Covariance
();
avoidSing
ular
Covariance
();
// compute square root information upper matrix
// compute square root information upper matrix
measurement_sqrt_information_upper_
=
computeSqrtUpper
(
measurement_covariance_
.
inverse
());
measurement_sqrt_information_upper_
=
computeSqrtUpper
(
measurement_covariance_
.
inverse
());
...
@@ -111,7 +111,7 @@ void FeatureBase::setMeasurementInformation(const Eigen::MatrixXs & _meas_info)
...
@@ -111,7 +111,7 @@ void FeatureBase::setMeasurementInformation(const Eigen::MatrixXs & _meas_info)
measurement_covariance_
=
_meas_info
.
inverse
().
selfadjointView
<
Eigen
::
Upper
>
();
measurement_covariance_
=
_meas_info
.
inverse
().
selfadjointView
<
Eigen
::
Upper
>
();
// Avoid singular covariance
// Avoid singular covariance
avoidSing
le
Covariance
();
avoidSing
ular
Covariance
();
// compute square root information upper matrix
// compute square root information upper matrix
measurement_sqrt_information_upper_
=
computeSqrtUpper
(
_meas_info
);
measurement_sqrt_information_upper_
=
computeSqrtUpper
(
_meas_info
);
...
@@ -119,9 +119,6 @@ void FeatureBase::setMeasurementInformation(const Eigen::MatrixXs & _meas_info)
...
@@ -119,9 +119,6 @@ void FeatureBase::setMeasurementInformation(const Eigen::MatrixXs & _meas_info)
Eigen
::
MatrixXs
FeatureBase
::
computeSqrtUpper
(
const
Eigen
::
MatrixXs
&
_info
)
const
Eigen
::
MatrixXs
FeatureBase
::
computeSqrtUpper
(
const
Eigen
::
MatrixXs
&
_info
)
const
{
{
assert
(
_info
.
determinant
()
>
Constants
::
EPS_SMALL
&&
"Matrix is not positive definite!"
);
assert
((
_info
-
_info
.
transpose
()).
cwiseAbs
().
maxCoeff
()
<
Constants
::
EPS
&&
"Matrix is not symmetric!"
);
// impose symmetry
// impose symmetry
Eigen
::
MatrixXs
info
=
((
_info
+
_info
.
transpose
())
/
2
);
Eigen
::
MatrixXs
info
=
((
_info
+
_info
.
transpose
())
/
2
);
info
=
info
.
selfadjointView
<
Eigen
::
Upper
>
();
info
=
info
.
selfadjointView
<
Eigen
::
Upper
>
();
...
@@ -143,15 +140,30 @@ Eigen::MatrixXs FeatureBase::computeSqrtUpper(const Eigen::MatrixXs & _info) con
...
@@ -143,15 +140,30 @@ Eigen::MatrixXs FeatureBase::computeSqrtUpper(const Eigen::MatrixXs & _info) con
return
R
;
return
R
;
}
}
void
FeatureBase
::
avoidSing
le
Covariance
()
void
FeatureBase
::
avoidSing
ular
Covariance
()
{
{
Scalar
eps_scalar
=
1e-10
;
Eigen
::
SelfAdjointEigenSolver
<
Eigen
::
MatrixXs
>
eigensolver
(
measurement_covariance_
);
if
(
eigensolver
.
info
()
==
Eigen
::
Success
)
{
// All eigenvalues must be >= 0:
//std::cout << "pre\n" << measurement_covariance_ << std::endl;
if
((
eigensolver
.
eigenvalues
().
array
()
<
Constants
::
EPS
).
all
())
measurement_covariance_
=
eigensolver
.
eigenvectors
()
*
(
eigensolver
.
eigenvalues
().
array
()
>
Constants
::
EPS
).
select
(
eigensolver
.
eigenvalues
(),
Constants
::
EPS
).
asDiagonal
()
*
eigensolver
.
eigenvectors
().
transpose
();
//std::cout << "post\n" << measurement_covariance_ << std::endl;
}
else
WOLF_ERROR
(
"Couldn't compute covariance eigen decomposition"
);
/*Scalar eps_scalar = 1e-10;
while (measurement_covariance_.determinant() < Constants::EPS_SMALL && eps_scalar < 1e-3)
while (measurement_covariance_.determinant() < Constants::EPS_SMALL && eps_scalar < 1e-3)
{
{
measurement_covariance_ += Eigen::MatrixXs::Identity(measurement_covariance_.rows(), measurement_covariance_.cols()) * eps_scalar; // avoid singular covariance
measurement_covariance_ += Eigen::MatrixXs::Identity(measurement_covariance_.rows(), measurement_covariance_.cols()) * eps_scalar; // avoid singular covariance
eps_scalar*=10;
eps_scalar*=10;
}
}
*/
assert
(
measurement_covariance_
.
determinant
()
>
Constants
::
EPS_SMALL
&&
"Couldn't avoid singular covariance"
);
assert
(
measurement_covariance_
.
determinant
()
>
0
&&
"Couldn't avoid singular covariance"
);
}
}
}
// namespace wolf
}
// namespace wolf
This diff is collapsed.
Click to expand it.
src/feature_base.h
+
1
−
1
View file @
1a95699e
...
@@ -91,7 +91,7 @@ class FeatureBase : public NodeBase, public std::enable_shared_from_this<Feature
...
@@ -91,7 +91,7 @@ class FeatureBase : public NodeBase, public std::enable_shared_from_this<Feature
private
:
private
:
Eigen
::
MatrixXs
computeSqrtUpper
(
const
Eigen
::
MatrixXs
&
_M
)
const
;
Eigen
::
MatrixXs
computeSqrtUpper
(
const
Eigen
::
MatrixXs
&
_M
)
const
;
void
avoidSing
le
Covariance
();
void
avoidSing
ular
Covariance
();
};
};
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment