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
fb8cd627
Commit
fb8cd627
authored
5 years ago
by
Médéric Fourmy
Browse files
Options
Downloads
Patches
Plain Diff
Small correction: oposite residual, jacobians changed accordingly
parent
a4bb01f4
No related branches found
No related tags found
1 merge request
!336
New factor block difference
Pipeline
#4895
passed
5 years ago
Stage: build
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
include/core/factor/factor_block_difference.h
+16
-16
16 additions, 16 deletions
include/core/factor/factor_block_difference.h
test/gtest_factor_block_difference.cpp
+3
-3
3 additions, 3 deletions
test/gtest_factor_block_difference.cpp
with
19 additions
and
19 deletions
include/core/factor/factor_block_difference.h
+
16
−
16
View file @
fb8cd627
...
...
@@ -26,8 +26,8 @@ class FactorBlockDifference : public FactorAnalytic
SizeEigen
sb1_constrained_size_
;
// the size of sb1 the state segment that is constrained
SizeEigen
sb2_constrained_start_
;
// the index of the first state element of sb2 that is constrained
SizeEigen
sb2_constrained_size_
;
// the size of sb2 the state segment that is constrained
Eigen
::
MatrixXd
J1_
;
// Jacobian
Eigen
::
MatrixXd
J2_
;
// Jacobian
Eigen
::
MatrixXd
J
_res_sb
1_
;
// Jacobian
Eigen
::
MatrixXd
J
_res_sb
2_
;
// Jacobian
public:
...
...
@@ -69,11 +69,11 @@ class FactorBlockDifference : public FactorAnalytic
assert
(
sb1_constrained_size_
==
sb2_constrained_size_
);
// precompute Jacobian (Identity with zero columns if the stateblock part is not constrained)
J1_
=
Eigen
::
MatrixXd
::
Zero
(
sb1_constrained_size_
,
sb1_size_
);
J1_
.
middleCols
(
sb1_constrained_start_
,
sb1_constrained_size_
)
=
-
Eigen
::
MatrixXd
::
Identity
(
sb1_constrained_size_
,
sb1_constrained_size_
);
J
_res_sb
1_
=
Eigen
::
MatrixXd
::
Zero
(
sb1_constrained_size_
,
sb1_size_
);
J
_res_sb
1_
.
middleCols
(
sb1_constrained_start_
,
sb1_constrained_size_
)
=
Eigen
::
MatrixXd
::
Identity
(
sb1_constrained_size_
,
sb1_constrained_size_
);
J2_
=
Eigen
::
MatrixXd
::
Zero
(
sb2_constrained_size_
,
sb2_size_
);
J2_
.
middleCols
(
sb2_constrained_start_
,
sb1_constrained_size_
)
=
Eigen
::
MatrixXd
::
Identity
(
sb2_constrained_size_
,
sb2_constrained_size_
);
J
_res_sb
2_
=
Eigen
::
MatrixXd
::
Zero
(
sb2_constrained_size_
,
sb2_size_
);
J
_res_sb
2_
.
middleCols
(
sb2_constrained_start_
,
sb1_constrained_size_
)
=
-
Eigen
::
MatrixXd
::
Identity
(
sb2_constrained_size_
,
sb2_constrained_size_
);
}
virtual
~
FactorBlockDifference
()
=
default
;
...
...
@@ -131,8 +131,8 @@ inline Eigen::VectorXd FactorBlockDifference::evaluateResiduals(const std::vecto
assert
(
getMeasurement
().
size
()
==
sb2_constrained_size_
);
// residual: meas -> measurement of the difference between partial stateblocks
return
getMeasurementSquareRootInformationUpper
()
*
((
_st_vector
[
1
].
segment
(
sb
1
_constrained_start_
,
sb
1
_constrained_size_
)
-
_st_vector
[
0
].
segment
(
sb
2
_constrained_start_
,
sb
2
_constrained_size_
))
-
getMeasurement
()
);
return
getMeasurementSquareRootInformationUpper
()
*
(
getMeasurement
()
-
(
_st_vector
[
1
].
segment
(
sb
2
_constrained_start_
,
sb
2
_constrained_size_
)
-
_st_vector
[
0
].
segment
(
sb
1
_constrained_start_
,
sb
1
_constrained_size_
)));
}
inline
void
FactorBlockDifference
::
evaluateJacobians
(
const
std
::
vector
<
Eigen
::
Map
<
const
Eigen
::
VectorXd
>
>&
_st_vector
,
...
...
@@ -148,8 +148,8 @@ inline void FactorBlockDifference::evaluateJacobians(const std::vector<Eigen::Ma
assert
(
_st_vector
[
1
].
size
()
>=
getMeasurement
().
size
()
&&
"StateBlock size and measurement size should match"
);
// normalized jacobian
_jacobians
[
0
]
=
getMeasurementSquareRootInformationUpper
()
*
J1_
;
_jacobians
[
1
]
=
getMeasurementSquareRootInformationUpper
()
*
J2_
;
_jacobians
[
0
]
=
getMeasurementSquareRootInformationUpper
()
*
J
_res_sb
1_
;
_jacobians
[
1
]
=
getMeasurementSquareRootInformationUpper
()
*
J
_res_sb
2_
;
}
inline
void
FactorBlockDifference
::
evaluateJacobians
(
const
std
::
vector
<
Eigen
::
Map
<
const
Eigen
::
VectorXd
>>&
_st_vector
,
...
...
@@ -165,16 +165,16 @@ inline void FactorBlockDifference::evaluateJacobians(const std::vector<Eigen::Ma
assert
(
_st_vector
[
1
].
size
()
>=
getMeasurement
().
size
()
&&
"StateBlock size and measurement size should match"
);
// normalized jacobian
_jacobians
[
0
]
=
getMeasurementSquareRootInformationUpper
()
*
J1_
;
_jacobians
[
1
]
=
getMeasurementSquareRootInformationUpper
()
*
J2_
;
_jacobians
[
0
]
=
getMeasurementSquareRootInformationUpper
()
*
J
_res_sb
1_
;
_jacobians
[
1
]
=
getMeasurementSquareRootInformationUpper
()
*
J
_res_sb
2_
;
}
inline
void
FactorBlockDifference
::
evaluatePureJacobians
(
std
::
vector
<
Eigen
::
MatrixXd
>&
jacobians
)
const
inline
void
FactorBlockDifference
::
evaluatePureJacobians
(
std
::
vector
<
Eigen
::
MatrixXd
>&
_pure_
jacobians
)
const
{
assert
(
jacobians
.
size
()
==
1
&&
"Wrong number of jacobians!"
);
assert
(
_pure_
jacobians
.
size
()
==
1
&&
"Wrong number of jacobians!"
);
jacobians
[
0
]
=
J1_
;
jacobians
[
1
]
=
J2_
;
_pure_
jacobians
[
0
]
=
J
_res_sb
1_
;
_pure_
jacobians
[
1
]
=
J
_res_sb
2_
;
}
inline
unsigned
int
FactorBlockDifference
::
getSize
()
const
...
...
This diff is collapsed.
Click to expand it.
test/gtest_factor_block_difference.cpp
+
3
−
3
View file @
fb8cd627
...
...
@@ -202,10 +202,10 @@ TEST_F(FixtureFactorBlockDifference, DiffPyz)
KF0_
->
getP
()
->
setState
(
Vector3d
::
Random
());
KF1_
->
getP
()
->
setState
(
Vector3d
::
Random
());
//
problem_->print(4,true,true,true);
problem_
->
print
(
4
,
true
,
true
,
true
);
std
::
string
report
=
ceres_manager_
->
solve
(
SolverManager
::
ReportVerbosity
::
BRIEF
);
//
std::cout << report << std::endl;
//
problem_->print(4,true,true,true);
std
::
cout
<<
report
<<
std
::
endl
;
problem_
->
print
(
4
,
true
,
true
,
true
);
ASSERT_MATRIX_APPROX
(
KF1_
->
getP
()
->
getState
().
segment
<
2
>
(
1
)
-
KF0_
->
getP
()
->
getState
().
segment
<
2
>
(
1
),
diff
,
1e-8
);
}
...
...
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