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
0baa44f7
Commit
0baa44f7
authored
5 years ago
by
Joan Solà Ortega
Browse files
Options
Downloads
Patches
Plain Diff
Rename sub_structure -> structure
parent
8c09ad7c
No related branches found
No related tags found
1 merge request
!379
Resolve "Problem::getState(structure) doesn't care about structure"
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
include/core/state_block/has_state_blocks.h
+31
-22
31 additions, 22 deletions
include/core/state_block/has_state_blocks.h
with
31 additions
and
22 deletions
include/core/state_block/has_state_blocks.h
+
31
−
22
View file @
0baa44f7
...
@@ -74,12 +74,12 @@ class HasStateBlocks
...
@@ -74,12 +74,12 @@ class HasStateBlocks
VectorComposite
getState
(
const
StateStructure
&
structure
=
""
)
const
;
VectorComposite
getState
(
const
StateStructure
&
structure
=
""
)
const
;
void
setState
(
const
VectorComposite
&
_state
,
const
bool
_notify
=
true
);
void
setState
(
const
VectorComposite
&
_state
,
const
bool
_notify
=
true
);
void
setState
(
const
Eigen
::
VectorXd
&
_state
,
const
StateStructure
&
_structure
,
const
std
::
list
<
SizeEigen
>&
_sizes
,
const
bool
_notify
=
true
);
void
setState
(
const
Eigen
::
VectorXd
&
_state
,
const
StateStructure
&
_structure
,
const
std
::
list
<
SizeEigen
>&
_sizes
,
const
bool
_notify
=
true
);
void
setState
(
const
Eigen
::
VectorXd
&
_state
,
const
StateStructure
&
_sub
_structure
=
""
,
const
bool
_notify
=
true
);
void
setState
(
const
Eigen
::
VectorXd
&
_state
,
const
StateStructure
&
_structure
=
""
,
const
bool
_notify
=
true
);
void
setState
(
const
StateStructure
&
_structure
,
const
std
::
list
<
VectorXd
>&
_vectors
,
const
bool
_notify
=
true
);
void
setState
(
const
StateStructure
&
_structure
,
const
std
::
list
<
VectorXd
>&
_vectors
,
const
bool
_notify
=
true
);
VectorXd
getStateVector
(
const
StateStructure
&
structure
=
""
)
const
;
VectorXd
getStateVector
(
const
StateStructure
&
structure
=
""
)
const
;
unsigned
int
getSize
(
const
StateStructure
&
_sub
_structure
=
""
)
const
;
unsigned
int
getSize
(
const
StateStructure
&
_structure
=
""
)
const
;
unsigned
int
getLocalSize
(
const
StateStructure
&
_sub
_structure
=
""
)
const
;
unsigned
int
getLocalSize
(
const
StateStructure
&
_structure
=
""
)
const
;
// Perturb state
// Perturb state
void
perturb
(
double
amplitude
=
0.01
);
void
perturb
(
double
amplitude
=
0.01
);
...
@@ -225,13 +225,13 @@ inline void HasStateBlocks::setState(const VectorComposite& _state, const bool _
...
@@ -225,13 +225,13 @@ inline void HasStateBlocks::setState(const VectorComposite& _state, const bool _
}
}
}
}
inline
void
HasStateBlocks
::
setState
(
const
Eigen
::
VectorXd
&
_state
,
const
StateStructure
&
_sub
_structure
,
const
bool
_notify
)
inline
void
HasStateBlocks
::
setState
(
const
Eigen
::
VectorXd
&
_state
,
const
StateStructure
&
_structure
,
const
bool
_notify
)
{
{
StateStructure
structure
;
StateStructure
structure
;
if
(
_
sub_
structure
==
""
)
if
(
_structure
==
""
)
structure
=
structure_
;
structure
=
structure_
;
else
else
structure
=
_sub
_structure
;
structure
=
_structure
;
int
size
=
getSize
(
structure
);
int
size
=
getSize
(
structure
);
assert
(
_state
.
size
()
==
size
&&
"In FrameBase::setState wrong state size"
);
assert
(
_state
.
size
()
==
size
&&
"In FrameBase::setState wrong state size"
);
...
@@ -286,14 +286,14 @@ inline void HasStateBlocks::setState(const StateStructure& _structure, const std
...
@@ -286,14 +286,14 @@ inline void HasStateBlocks::setState(const StateStructure& _structure, const std
}
}
////
_sub
_structure can be either stateblock structure of the node or a subset of this structure
//// _structure can be either stateblock structure of the node or a subset of this structure
inline
VectorXd
HasStateBlocks
::
getStateVector
(
const
StateStructure
&
_sub
_structure
)
const
inline
VectorXd
HasStateBlocks
::
getStateVector
(
const
StateStructure
&
_structure
)
const
{
{
StateStructure
structure
;
StateStructure
structure
;
if
(
_
sub_
structure
==
""
)
if
(
_structure
==
""
)
structure
=
structure_
;
structure
=
structure_
;
else
else
structure
=
_sub
_structure
;
structure
=
_structure
;
VectorXd
state
(
getSize
(
structure
));
VectorXd
state
(
getSize
(
structure
));
...
@@ -312,21 +312,31 @@ inline VectorXd HasStateBlocks::getStateVector(const StateStructure& _sub_struct
...
@@ -312,21 +312,31 @@ inline VectorXd HasStateBlocks::getStateVector(const StateStructure& _sub_struct
inline
VectorComposite
HasStateBlocks
::
getState
(
const
StateStructure
&
_structure
)
const
inline
VectorComposite
HasStateBlocks
::
getState
(
const
StateStructure
&
_structure
)
const
{
{
const
StateStructure
&
structure
=
(
_structure
==
""
?
structure_
:
_structure
);
VectorComposite
state
;
VectorComposite
state
;
for
(
auto
&
pair_key_sb
:
state_block_map_
)
for
(
const
auto
ckey
:
structure
)
{
{
state
.
emplace
(
pair_key_sb
.
first
,
pair_key_sb
.
second
->
getState
());
const
auto
&
key
=
string
(
1
,
ckey
);
// ckey is char
auto
state_it
=
state_block_map_
.
find
(
key
);
if
(
state_it
!=
state_block_map_
.
end
())
state
.
emplace
(
key
,
state_it
->
second
->
getState
());
}
}
// for (auto& pair_key_sb : state_block_map_)
// {
// state.emplace(pair_key_sb.first, pair_key_sb.second->getState());
// }
return
state
;
return
state
;
}
}
inline
unsigned
int
HasStateBlocks
::
getSize
(
const
StateStructure
&
_sub
_structure
)
const
inline
unsigned
int
HasStateBlocks
::
getSize
(
const
StateStructure
&
_structure
)
const
{
{
StateStructure
structure
;
const
StateStructure
&
structure
=
(
_structure
==
""
?
structure_
:
_structure
);
if
(
_sub_structure
==
""
)
structure
=
structure_
;
else
structure
=
_sub_structure
;
unsigned
int
size
=
0
;
unsigned
int
size
=
0
;
for
(
const
char
key
:
structure
)
for
(
const
char
key
:
structure
)
...
@@ -341,7 +351,6 @@ inline unsigned int HasStateBlocks::getSize(const StateStructure& _sub_structure
...
@@ -341,7 +351,6 @@ inline unsigned int HasStateBlocks::getSize(const StateStructure& _sub_structure
return
size
;
return
size
;
}
}
//<<<<<<< HEAD
inline
std
::
unordered_map
<
std
::
string
,
StateBlockPtr
>::
const_iterator
HasStateBlocks
::
find
(
const
StateBlockPtr
&
_sb
)
const
inline
std
::
unordered_map
<
std
::
string
,
StateBlockPtr
>::
const_iterator
HasStateBlocks
::
find
(
const
StateBlockPtr
&
_sb
)
const
{
{
const
auto
&
it
=
std
::
find_if
(
state_block_map_
.
begin
(),
const
auto
&
it
=
std
::
find_if
(
state_block_map_
.
begin
(),
...
@@ -380,13 +389,13 @@ inline bool HasStateBlocks::stateBlockKey(const StateBlockPtr &_sb, std::string&
...
@@ -380,13 +389,13 @@ inline bool HasStateBlocks::stateBlockKey(const StateBlockPtr &_sb, std::string&
}
}
}
}
inline
unsigned
int
HasStateBlocks
::
getLocalSize
(
const
StateStructure
&
_sub
_structure
)
const
inline
unsigned
int
HasStateBlocks
::
getLocalSize
(
const
StateStructure
&
_structure
)
const
{
{
StateStructure
structure
;
StateStructure
structure
;
if
(
_
sub_
structure
==
""
)
if
(
_structure
==
""
)
structure
=
structure_
;
structure
=
structure_
;
else
else
structure
=
_sub
_structure
;
structure
=
_structure
;
unsigned
int
size
=
0
;
unsigned
int
size
=
0
;
for
(
const
char
key
:
structure
)
for
(
const
char
key
:
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