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
0ca047a7
Commit
0ca047a7
authored
4 years ago
by
Joan Solà Ortega
Browse files
Options
Downloads
Patches
Plain Diff
WIP fixing applyPriorOptions()
parent
b1b79b65
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!366
Resolve "Complete state vector new data structure?"
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/problem/problem.cpp
+51
-18
51 additions, 18 deletions
src/problem/problem.cpp
with
51 additions
and
18 deletions
src/problem/problem.cpp
+
51
−
18
View file @
0ca047a7
...
@@ -1016,35 +1016,37 @@ FrameBasePtr Problem::applyPriorOptions(const TimeStamp& _ts)
...
@@ -1016,35 +1016,37 @@ FrameBasePtr Problem::applyPriorOptions(const TimeStamp& _ts)
{
{
prior_keyframe
=
emplaceFrame
(
KEY
,
prior_keyframe
=
emplaceFrame
(
KEY
,
_ts
,
_ts
,
this
->
getFrameStructure
(),
prior_options_
->
state__
);
this
->
getDim
(),
prior_options_
->
state
);
if
(
prior_options_
->
mode
==
"fix"
)
if
(
prior_options_
->
mode
==
"fix"
)
prior_keyframe
->
fix
();
prior_keyframe
->
fix
();
else
if
(
prior_options_
->
mode
==
"factor"
)
else
if
(
prior_options_
->
mode
==
"factor"
)
{
{
// FIXME: change whenever state is changed to a map<string,vector>
// ASSUMPTION: Independent measurements (non-correlated block-diagonal covariance matrix)
// ASSUMPTION: Independent measurements (non-correlated block-diagonal covariance matrix)
// Emplace a capture
// Emplace a capture
auto
prior_cap
=
CaptureBase
::
emplace
<
CaptureVoid
>
(
prior_keyframe
,
_ts
,
nullptr
);
auto
prior_cap
=
CaptureBase
::
emplace
<
CaptureVoid
>
(
prior_keyframe
,
_ts
,
nullptr
);
// Emplace a feature and a factor for each state block
// Emplace a feature and a factor for each state block
int
state_idx
=
0
;
for
(
const
auto
&
pair_key_sb
:
prior_keyframe
->
getStateBlockMap
())
int
cov_idx
=
0
;
for
(
auto
sb
:
prior_keyframe
->
getStateBlockVec
())
{
{
assert
(
sb
!=
nullptr
);
const
auto
&
key
=
pair_key_sb
.
first
;
assert
(
state_idx
+
sb
->
getSize
()
<=
prior_options_
->
state
.
size
()
&&
"prior_options state wrong size (dimension too small)"
);
const
auto
&
sb
=
pair_key_sb
.
second
;
assert
(
cov_idx
+
sb
->
getLocalSize
()
<=
prior_options_
->
cov
.
rows
()
&&
"prior_options cov wrong size (dimension too small)"
);
// state block segment
const
auto
&
state_blk
=
prior_options_
->
state__
.
at
(
key
);
Eigen
::
VectorXd
state_segment
=
prior_options_
->
state
.
segment
(
state_idx
,
sb
->
getSize
());
const
auto
&
covar_blk
=
prior_options_
->
cov__
.
at
(
key
,
key
);
Eigen
::
MatrixXd
cov_block
=
prior_options_
->
cov
.
block
(
cov_idx
,
cov_idx
,
sb
->
getLocalSize
(),
sb
->
getLocalSize
());
assert
(
sb
->
getSize
()
==
state_blk
.
size
()
&&
"prior_options state wrong size"
);
assert
(
sb
->
getLocalSize
()
==
covar_blk
.
rows
()
&&
"prior_options cov. wrong size"
);
WOLF_DEBUG
(
"key: "
,
key
);
WOLF_DEBUG
(
"vec: "
,
state_blk
);
WOLF_DEBUG
(
"cov: "
,
covar_blk
);
WOLF_DEBUG
(
"sb : "
,
sb
->
getState
());
WOLF_DEBUG
(
"----------------------: "
);
// feature
// feature
auto
prior_fea
=
FeatureBase
::
emplace
<
FeatureBase
>
(
prior_cap
,
"prior"
,
state_
segment
,
cov_bl
oc
k
);
auto
prior_fea
=
FeatureBase
::
emplace
<
FeatureBase
>
(
prior_cap
,
"prior"
,
state_
blk
,
cov
ar
_blk
);
// factor
// factor
if
(
sb
->
hasLocalParametrization
())
if
(
sb
->
hasLocalParametrization
())
...
@@ -1060,11 +1062,42 @@ FrameBasePtr Problem::applyPriorOptions(const TimeStamp& _ts)
...
@@ -1060,11 +1062,42 @@ FrameBasePtr Problem::applyPriorOptions(const TimeStamp& _ts)
{
{
auto
prior_fac
=
FactorBase
::
emplace
<
FactorBlockAbsolute
>
(
prior_fea
,
sb
,
nullptr
,
false
);
auto
prior_fac
=
FactorBase
::
emplace
<
FactorBlockAbsolute
>
(
prior_fea
,
sb
,
nullptr
,
false
);
}
}
state_idx
+=
sb
->
getSize
();
cov_idx
+=
sb
->
getLocalSize
();
}
}
assert
(
state_idx
==
prior_options_
->
state
.
size
()
&&
"prior_options state wrong size (dimension too big)"
);
assert
(
cov_idx
==
prior_options_
->
cov
.
rows
()
&&
"prior_options cov wrong size (dimension too big)"
);
// for (auto sb : prior_keyframe->getStateBlockVec())
// {
// assert(sb != nullptr);
// assert(state_idx+sb->getSize() <= prior_options_->state.size() && "prior_options state wrong size (dimension too small)");
// assert(cov_idx+sb->getLocalSize() <= prior_options_->cov.rows() && "prior_options cov wrong size (dimension too small)");
//
// // state block segment
// Eigen::VectorXd state_segment = prior_options_->state.segment(state_idx, sb->getSize());
// Eigen::MatrixXd cov_block = prior_options_->cov.block(cov_idx, cov_idx, sb->getLocalSize(), sb->getLocalSize());
//
// // feature
// auto prior_fea = FeatureBase::emplace<FeatureBase>(prior_cap, "prior", state_segment, cov_block);
//
// // factor
// if (sb->hasLocalParametrization())
// {
// if (std::dynamic_pointer_cast<StateQuaternion>(sb) != nullptr)
// auto prior_fac = FactorBase::emplace<FactorQuaternionAbsolute>(prior_fea, sb, nullptr, false);
// else if (std::dynamic_pointer_cast<StateAngle>(sb) != nullptr)
// auto prior_fac = FactorBase::emplace<FactorBlockAbsolute>(prior_fea, sb, nullptr, false);
// else
// throw std::runtime_error("not implemented...!");
// }
// else
// {
// auto prior_fac = FactorBase::emplace<FactorBlockAbsolute>(prior_fea, sb, nullptr, false);
// }
// state_idx += sb->getSize();
// cov_idx += sb->getLocalSize();
// }
// assert(state_idx == prior_options_->state.size() && "prior_options state wrong size (dimension too big)");
// assert(cov_idx == prior_options_->cov.rows() && "prior_options cov wrong size (dimension too big)");
}
}
else
else
assert
(
prior_options_
->
mode
==
"initial_guess"
&&
"wrong prior_options->mode"
);
assert
(
prior_options_
->
mode
==
"initial_guess"
&&
"wrong prior_options->mode"
);
...
...
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