Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
gnss
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Model registry
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor 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
plugins
gnss
Commits
ce5a1600
Commit
ce5a1600
authored
9 years ago
by
Joan Vallvé Navarro
Browse files
Options
Downloads
Patches
Plain Diff
Added getFrameCovariance and getLandmarkCovariance via return and ref
parent
197810d5
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/problem.cpp
+38
-14
38 additions, 14 deletions
src/problem.cpp
src/problem.h
+11
-4
11 additions, 4 deletions
src/problem.h
with
49 additions
and
18 deletions
src/problem.cpp
+
38
−
14
View file @
ce5a1600
...
...
@@ -172,6 +172,7 @@ void Problem::addLandmarkList(LandmarkBaseList _lmk_list)
StateBlock
*
Problem
::
addStateBlockPtr
(
StateBlock
*
_state_ptr
)
{
std
::
cout
<<
"addStateBlock"
<<
std
::
endl
;
// add the state unit to the list
state_block_ptr_list_
.
push_back
(
_state_ptr
);
// queue for solver manager
...
...
@@ -221,34 +222,27 @@ void Problem::addCovarianceBlock(StateBlock* _state1, StateBlock* _state2, const
covariances_
[
std
::
pair
<
StateBlock
*
,
StateBlock
*>
(
_state1
,
_state2
)]
=
_cov
;
}
bool
Problem
::
getCovarianceBlock
(
StateBlock
*
_state1
,
StateBlock
*
_state2
,
Eigen
::
MatrixXs
&
_cov_block
)
{
if
(
covariances_
.
find
(
std
::
pair
<
StateBlock
*
,
StateBlock
*>
(
_state1
,
_state2
))
!=
covariances_
.
end
())
_cov_block
=
covariances_
[
std
::
pair
<
StateBlock
*
,
StateBlock
*>
(
_state1
,
_state2
)];
else
if
(
covariances_
.
find
(
std
::
pair
<
StateBlock
*
,
StateBlock
*>
(
_state2
,
_state1
))
!=
covariances_
.
end
())
_cov_block
=
covariances_
[
std
::
pair
<
StateBlock
*
,
StateBlock
*>
(
_state2
,
_state1
)].
transpose
();
else
return
false
;
return
true
;
}
bool
Problem
::
getCovarianceBlock
(
StateBlock
*
_state1
,
StateBlock
*
_state2
,
Eigen
::
MatrixXs
&
_cov
,
const
int
_row
,
const
int
_col
)
{
//std::cout << "entire cov " << std::endl << _cov << std::endl;
//std::cout << "entire cov
to be filled:
" << std::endl << _cov << std::endl;
//std::cout << "_row " << _row << std::endl;
//std::cout << "_col " << _col << std::endl;
//std::cout << "_state1 size: " << _state1->getSize() << std::endl;
//std::cout << "_state2 size: " << _state2->getSize() << std::endl;
//std::cout << "part of cov to be filled:" << std::endl << _cov.block(_row, _col, _state1->getSize(), _state2->getSize()) << std::endl;
//if (covariances_.find(std::pair<StateBlock*, StateBlock*>(_state1, _state2)) != covariances_.end())
// std::cout << "stored cov" << std::endl << covariances_[std::pair<StateBlock*, StateBlock*>(_state1, _state2)] << std::endl;
//else if (covariances_.find(std::pair<StateBlock*, StateBlock*>(_state2, _state1)) != covariances_.end())
// std::cout << "stored cov" << std::endl << covariances_[std::pair<StateBlock*, StateBlock*>(_state2, _state1)].transpose() << std::endl;
assert
(
_row
+
_state1
->
getSize
()
<=
_cov
.
rows
()
&&
_col
+
_state2
->
getSize
()
<=
_cov
.
cols
()
&&
"Problem::getCovarianceBlock: Bad matrix covariance size!"
);
if
(
covariances_
.
find
(
std
::
pair
<
StateBlock
*
,
StateBlock
*>
(
_state1
,
_state2
))
!=
covariances_
.
end
())
_cov
.
block
(
_row
,
_col
,
_state1
->
getSize
(),
_state2
->
getSize
())
=
covariances_
[
std
::
pair
<
StateBlock
*
,
StateBlock
*>
(
_state1
,
_state2
)];
else
if
(
covariances_
.
find
(
std
::
pair
<
StateBlock
*
,
StateBlock
*>
(
_state2
,
_state1
))
!=
covariances_
.
end
())
_cov
.
block
(
_row
,
_col
,
_state1
->
getSize
(),
_state2
->
getSize
())
=
_cov
.
block
(
_row
,
_col
,
_state1
->
getSize
(),
_state2
->
getSize
())
=
covariances_
[
std
::
pair
<
StateBlock
*
,
StateBlock
*>
(
_state2
,
_state1
)].
transpose
();
else
return
false
;
...
...
@@ -256,6 +250,36 @@ bool Problem::getCovarianceBlock(StateBlock* _state1, StateBlock* _state2, Eigen
return
true
;
}
bool
Problem
::
getFrameCovariance
(
FrameBase
*
_frame_ptr
,
Eigen
::
MatrixXs
&
_covariance
)
{
return
getCovarianceBlock
(
_frame_ptr
->
getPPtr
(),
_frame_ptr
->
getPPtr
(),
_covariance
,
0
,
0
)
&&
getCovarianceBlock
(
_frame_ptr
->
getPPtr
(),
_frame_ptr
->
getOPtr
(),
_covariance
,
0
,
_frame_ptr
->
getPPtr
()
->
getSize
())
&&
getCovarianceBlock
(
_frame_ptr
->
getOPtr
(),
_frame_ptr
->
getPPtr
(),
_covariance
,
_frame_ptr
->
getPPtr
()
->
getSize
(),
0
)
&&
getCovarianceBlock
(
_frame_ptr
->
getOPtr
(),
_frame_ptr
->
getOPtr
(),
_covariance
,
_frame_ptr
->
getPPtr
()
->
getSize
()
,
_frame_ptr
->
getPPtr
()
->
getSize
());
}
Eigen
::
MatrixXs
Problem
::
getFrameCovariance
(
FrameBase
*
_frame_ptr
)
{
Eigen
::
MatrixXs
covariance
=
Eigen
::
MatrixXs
::
Zero
(
_frame_ptr
->
getPPtr
()
->
getSize
()
+
_frame_ptr
->
getOPtr
()
->
getSize
(),
_frame_ptr
->
getPPtr
()
->
getSize
()
+
_frame_ptr
->
getOPtr
()
->
getSize
());
getFrameCovariance
(
_frame_ptr
,
covariance
);
return
covariance
;
}
bool
Problem
::
getLandmarkCovariance
(
LandmarkBase
*
_landmark_ptr
,
Eigen
::
MatrixXs
&
_covariance
)
{
return
getCovarianceBlock
(
_landmark_ptr
->
getPPtr
(),
_landmark_ptr
->
getPPtr
(),
_covariance
,
0
,
0
)
&&
getCovarianceBlock
(
_landmark_ptr
->
getPPtr
(),
_landmark_ptr
->
getOPtr
(),
_covariance
,
0
,
_landmark_ptr
->
getPPtr
()
->
getSize
())
&&
getCovarianceBlock
(
_landmark_ptr
->
getOPtr
(),
_landmark_ptr
->
getPPtr
(),
_covariance
,
_landmark_ptr
->
getPPtr
()
->
getSize
(),
0
)
&&
getCovarianceBlock
(
_landmark_ptr
->
getOPtr
(),
_landmark_ptr
->
getOPtr
(),
_covariance
,
_landmark_ptr
->
getPPtr
()
->
getSize
()
,
_landmark_ptr
->
getPPtr
()
->
getSize
());
}
Eigen
::
MatrixXs
Problem
::
getFrameCovariance
(
LandmarkBase
*
_landmark_ptr
)
{
Eigen
::
MatrixXs
covariance
=
Eigen
::
MatrixXs
::
Zero
(
_landmark_ptr
->
getPPtr
()
->
getSize
()
+
_landmark_ptr
->
getOPtr
()
->
getSize
(),
_landmark_ptr
->
getPPtr
()
->
getSize
()
+
_landmark_ptr
->
getOPtr
()
->
getSize
());
getLandmarkCovariance
(
_landmark_ptr
,
covariance
);
return
covariance
;
}
MapBase
*
Problem
::
addMap
(
MapBase
*
_map_ptr
)
{
// TODO: not necessary but update map maybe..
...
...
This diff is collapsed.
Click to expand it.
src/problem.h
+
11
−
4
View file @
ce5a1600
...
...
@@ -159,11 +159,18 @@ class Problem : public NodeBase
/** \brief Gets a covariance block
*/
bool
getCovarianceBlock
(
StateBlock
*
_state1
,
StateBlock
*
_state2
,
Eigen
::
MatrixXs
&
_cov_block
);
/** \brief Gets a covariance block
bool
getCovarianceBlock
(
StateBlock
*
_state1
,
StateBlock
*
_state2
,
Eigen
::
MatrixXs
&
_cov
,
const
int
_row
=
0
,
const
int
_col
=
0
);
/** \brief Gets the covariance of a frame
*/
bool
getFrameCovariance
(
FrameBase
*
_frame_ptr
,
Eigen
::
MatrixXs
&
_covariance
);
Eigen
::
MatrixXs
getFrameCovariance
(
FrameBase
*
_frame_ptr
);
/** \brief Gets the covariance of a frame
*/
bool
getCovariance
Block
(
StateBlock
*
_state1
,
StateBlock
*
_state2
,
Eigen
::
MatrixXs
&
_cov
,
const
int
_row
,
const
int
_col
);
bool
get
Landmark
Covariance
(
LandmarkBase
*
_landmark_ptr
,
Eigen
::
MatrixXs
&
_cov
ariance
);
Eigen
::
MatrixXs
getFrameCovariance
(
LandmarkBase
*
_landmark_ptr
);
/** \brief Adds a map
*/
...
...
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