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
2a4fce5e
Commit
2a4fce5e
authored
3 years ago
by
Mederic Fourmy
Browse files
Options
Downloads
Patches
Plain Diff
Add an error when getState is called with wrong stateblock
parent
2ce80a8e
No related branches found
No related tags found
1 merge request
!450
Resolve "HasStateBlocks::getState behaves in a non predictible way"
Pipeline
#11503
failed
3 years ago
Stage: deploy_plugins
Stage: deploy_ros
Changes
2
Pipelines
3
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
include/core/state_block/has_state_blocks.h
+6
-4
6 additions, 4 deletions
include/core/state_block/has_state_blocks.h
test/gtest_has_state_blocks.cpp
+0
-9
0 additions, 9 deletions
test/gtest_has_state_blocks.cpp
with
6 additions
and
13 deletions
include/core/state_block/has_state_blocks.h
+
6
−
4
View file @
2a4fce5e
...
@@ -349,8 +349,9 @@ inline VectorXd HasStateBlocks::getStateVector(const StateStructure& _structure)
...
@@ -349,8 +349,9 @@ inline VectorXd HasStateBlocks::getStateVector(const StateStructure& _structure)
for
(
const
char
key
:
structure
)
for
(
const
char
key
:
structure
)
{
{
const
auto
&
sb
=
getStateBlock
(
key
);
const
auto
&
sb
=
getStateBlock
(
key
);
if
(
sb
==
nullptr
){
assert
(
sb
!=
nullptr
&&
"Requested StateBlock key not in the structure"
);
throw
std
::
runtime_error
(
"Requested StateBlock 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
();
...
@@ -367,8 +368,9 @@ inline VectorComposite HasStateBlocks::getState(const StateStructure& _structure
...
@@ -367,8 +368,9 @@ inline VectorComposite HasStateBlocks::getState(const StateStructure& _structure
for
(
const
auto
key
:
structure
)
for
(
const
auto
key
:
structure
)
{
{
const
auto
&
sb
=
getStateBlock
(
key
);
const
auto
&
sb
=
getStateBlock
(
key
);
if
(
sb
==
nullptr
){
assert
(
sb
!=
nullptr
&&
"Requested StateBlock key not in the structure"
);
throw
std
::
runtime_error
(
"Requested StateBlock key not in the structure"
);
}
state
.
emplace
(
key
,
sb
->
getState
());
state
.
emplace
(
key
,
sb
->
getState
());
}
}
...
...
This diff is collapsed.
Click to expand it.
test/gtest_has_state_blocks.cpp
+
0
−
9
View file @
2a4fce5e
...
@@ -209,15 +209,6 @@ TEST_F(HasStateBlocksTest, getState_structure)
...
@@ -209,15 +209,6 @@ TEST_F(HasStateBlocksTest, getState_structure)
ASSERT_TRUE
(
state0
.
count
(
'P'
));
ASSERT_TRUE
(
state0
.
count
(
'P'
));
ASSERT_FALSE
(
state0
.
count
(
'O'
));
ASSERT_FALSE
(
state0
.
count
(
'O'
));
ASSERT_TRUE
(
state0
.
count
(
'V'
));
ASSERT_TRUE
(
state0
.
count
(
'V'
));
state0
=
F0
->
getState
(
"OW"
);
// W does not exist
WOLF_DEBUG
(
"getState(
\"
OW
\"
) = "
,
state0
);
ASSERT_EQ
(
state0
.
size
(),
1
);
ASSERT_FALSE
(
state0
.
count
(
'P'
));
ASSERT_TRUE
(
state0
.
count
(
'O'
));
ASSERT_FALSE
(
state0
.
count
(
'V'
));
ASSERT_FALSE
(
state0
.
count
(
'W'
));
}
}
...
...
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