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
35019c35
Commit
35019c35
authored
5 years ago
by
Médéric Fourmy
Browse files
Options
Downloads
Patches
Plain Diff
Simplification of has_stateblock changes
parent
019bb423
No related branches found
No related tags found
1 merge request
!339
Adapting to multiple processor motion 285
Pipeline
#4942
passed
5 years ago
Stage: build
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
include/core/state_block/has_state_blocks.h
+25
-43
25 additions, 43 deletions
include/core/state_block/has_state_blocks.h
with
25 additions
and
43 deletions
include/core/state_block/has_state_blocks.h
+
25
−
43
View file @
35019c35
...
@@ -64,15 +64,11 @@ class HasStateBlocks
...
@@ -64,15 +64,11 @@ class HasStateBlocks
void
removeStateBlocks
(
ProblemPtr
_problem
);
void
removeStateBlocks
(
ProblemPtr
_problem
);
// States
// States
virtual
void
setState
(
const
Eigen
::
VectorXd
&
_state
,
const
bool
_notify
=
true
);
inline
void
setState
(
const
Eigen
::
VectorXd
&
_state
,
std
::
string
_sub_structure
=
""
,
const
bool
_notify
=
true
);
void
getState
(
std
::
string
structure
,
Eigen
::
VectorXd
&
_state
)
const
;
void
getState
(
Eigen
::
VectorXd
&
_state
,
std
::
string
structure
=
""
)
const
;
Eigen
::
VectorXd
getState
(
std
::
string
structure
)
const
;
Eigen
::
VectorXd
getState
(
std
::
string
structure
=
""
)
const
;
Eigen
::
VectorXd
getState
()
const
;
unsigned
int
getSize
(
std
::
string
_sub_structure
=
""
)
const
;
void
getState
(
Eigen
::
VectorXd
&
_state
)
const
;
unsigned
int
getLocalSize
(
std
::
string
_sub_structure
=
""
)
const
;
unsigned
int
getSize
()
const
;
unsigned
int
getSize
(
std
::
string
_sub_structure
)
const
;
unsigned
int
getLocalSize
()
const
;
unsigned
int
getLocalSize
(
std
::
string
_sub_structure
)
const
;
private
:
private
:
std
::
string
structure_
;
std
::
string
structure_
;
...
@@ -219,17 +215,21 @@ inline bool HasStateBlocks::isFixed() const
...
@@ -219,17 +215,21 @@ inline bool HasStateBlocks::isFixed() const
return
fixed
;
return
fixed
;
}
}
inline
void
HasStateBlocks
::
setState
(
const
Eigen
::
VectorXd
&
_state
,
const
bool
_notify
)
inline
void
HasStateBlocks
::
setState
(
const
Eigen
::
VectorXd
&
_state
,
std
::
string
_sub_structure
,
const
bool
_notify
)
{
{
int
size
=
getSize
();
if
(
_sub_structure
==
""
){
_sub_structure
=
structure_
;
}
int
size
=
getSize
(
_sub_structure
);
assert
(
_state
.
size
()
==
size
&&
"In FrameBase::setState wrong state size"
);
assert
(
_state
.
size
()
==
size
&&
"In FrameBase::setState wrong state size"
);
unsigned
int
index
=
0
;
unsigned
int
index
=
0
;
for
(
const
char
key
:
getS
tructure
()
)
for
(
const
char
key
:
_sub_s
tructure
)
{
{
const
auto
&
sb
=
getStateBlock
(
key
);
const
auto
&
sb
=
getStateBlock
(
key
);
if
(
!
sb
){
WOLF_ERROR
(
"Stateblock key "
,
key
,
" not in the structure"
);
}
sb
->
setState
(
_state
.
segment
(
index
,
sb
->
getSize
()),
_notify
);
// do not notify if state block is not estimated by the solver
sb
->
setState
(
_state
.
segment
(
index
,
sb
->
getSize
()),
_notify
);
// do not notify if state block is not estimated by the solver
index
+=
sb
->
getSize
();
index
+=
sb
->
getSize
();
}
}
...
@@ -237,20 +237,20 @@ inline void HasStateBlocks::setState(const Eigen::VectorXd& _state, const bool _
...
@@ -237,20 +237,20 @@ inline void HasStateBlocks::setState(const Eigen::VectorXd& _state, const bool _
}
}
// _sub_structure can be either stateblock structure of the node or a subset of this structure
// _sub_structure can be either stateblock structure of the node or a subset of this structure
inline
void
HasStateBlocks
::
getState
(
std
::
string
_sub_structur
e
,
Eigen
::
VectorXd
&
_stat
e
)
const
inline
void
HasStateBlocks
::
getState
(
Eigen
::
VectorXd
&
_state
,
std
::
string
_sub_structure
)
const
{
{
if
(
_sub_structure
==
""
){
_sub_structure
=
structure_
;
}
_state
.
resize
(
getSize
(
_sub_structure
));
_state
.
resize
(
getSize
(
_sub_structure
));
unsigned
int
index
=
0
;
unsigned
int
index
=
0
;
for
(
const
char
key
:
_sub_structure
)
for
(
const
char
key
:
_sub_structure
)
{
{
const
auto
&
sb
=
getStateBlock
(
key
);
const
auto
&
sb
=
getStateBlock
(
key
);
if
(
!
sb
){
if
(
!
sb
){
WOLF_ERROR
(
"Stateblock key "
,
key
,
" not in the structure"
);
WOLF_ERROR
(
"Stateblock key "
,
key
,
" not in the structure"
);
}
}
_state
.
segment
(
index
,
sb
->
getSize
())
=
sb
->
getState
();
_state
.
segment
(
index
,
sb
->
getSize
())
=
sb
->
getState
();
index
+=
sb
->
getSize
();
index
+=
sb
->
getSize
();
}
}
...
@@ -261,33 +261,17 @@ inline Eigen::VectorXd HasStateBlocks::getState(std::string _sub_structure) cons
...
@@ -261,33 +261,17 @@ inline Eigen::VectorXd HasStateBlocks::getState(std::string _sub_structure) cons
{
{
Eigen
::
VectorXd
state
;
Eigen
::
VectorXd
state
;
getState
(
_sub_structure
,
state
);
getState
(
state
,
_sub_structure
);
return
state
;
return
state
;
}
}
inline
void
HasStateBlocks
::
getState
(
Eigen
::
VectorXd
&
_state
)
const
{
getState
(
getStructure
(),
_state
);
}
inline
Eigen
::
VectorXd
HasStateBlocks
::
getState
()
const
{
Eigen
::
VectorXd
state
;
getState
(
state
);
return
state
;
}
inline
unsigned
int
HasStateBlocks
::
getSize
()
const
{
return
getSize
(
structure_
);
}
inline
unsigned
int
HasStateBlocks
::
getSize
(
std
::
string
_sub_structure
)
const
inline
unsigned
int
HasStateBlocks
::
getSize
(
std
::
string
_sub_structure
)
const
{
{
if
(
_sub_structure
==
""
){
_sub_structure
=
structure_
;
}
unsigned
int
size
=
0
;
unsigned
int
size
=
0
;
for
(
const
char
key
:
_sub_structure
)
for
(
const
char
key
:
_sub_structure
)
{
{
...
@@ -301,13 +285,11 @@ inline unsigned int HasStateBlocks::getSize(std::string _sub_structure) const
...
@@ -301,13 +285,11 @@ inline unsigned int HasStateBlocks::getSize(std::string _sub_structure) const
return
size
;
return
size
;
}
}
inline
unsigned
int
HasStateBlocks
::
getLocalSize
()
const
{
return
getLocalSize
(
structure_
);
}
inline
unsigned
int
HasStateBlocks
::
getLocalSize
(
std
::
string
_sub_structure
)
const
inline
unsigned
int
HasStateBlocks
::
getLocalSize
(
std
::
string
_sub_structure
)
const
{
{
if
(
_sub_structure
==
""
){
_sub_structure
=
structure_
;
}
unsigned
int
size
=
0
;
unsigned
int
size
=
0
;
for
(
const
char
key
:
_sub_structure
)
for
(
const
char
key
:
_sub_structure
)
{
{
...
...
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