Skip to content
Snippets Groups Projects
Commit e99cfc7e authored by Joseph Mirabel's avatar Joseph Mirabel
Browse files

Check that the order of the state is good.

parent fb36b4ed
Branches
Tags
No related merge requests found
...@@ -37,6 +37,17 @@ ...@@ -37,6 +37,17 @@
namespace hpp { namespace hpp {
namespace manipulation { namespace manipulation {
namespace graph { namespace graph {
bool stateAIncludedInStateB (const StatePtr_t& A, const StatePtr_t& B)
{
const NumericalConstraints_t& Ancs = A->numericalConstraints();
const NumericalConstraints_t& Bncs = B->numericalConstraints();
for (NumericalConstraints_t::const_iterator _nc = Ancs.begin();
_nc != Ancs.end(); ++_nc)
if (std::find (Bncs.begin(), Bncs.end(), *_nc) == Bncs.end())
return false;
return true;
}
std::ostream& Validation::print (std::ostream& os) const std::ostream& Validation::print (std::ostream& os) const
{ {
for (std::size_t i = 0; i < warnings_.size(); ++i) { for (std::size_t i = 0; i < warnings_.size(); ++i) {
...@@ -164,10 +175,25 @@ namespace hpp { ...@@ -164,10 +175,25 @@ namespace hpp {
if (!graph) return false; if (!graph) return false;
bool success = true; bool success = true;
States_t states = graph->stateSelector()->getStates();
for (std::size_t i = 1; i < graph->nbComponents(); ++i) for (std::size_t i = 1; i < graph->nbComponents(); ++i)
if (!validate(graph->get(i).lock())) success = false; if (!validate(graph->get(i).lock())) success = false;
// Check that no state is included in a state which has a higher priority.
States_t states = graph->stateSelector()->getStates();
for (States_t::const_iterator _state = states.begin();
_state != states.end(); ++_state) {
for (States_t::const_iterator _stateHO = states.begin();
_stateHO != _state; ++_stateHO) {
if (stateAIncludedInStateB (*_state, *_stateHO)) {
std::ostringstream oss;
oss << "State " << (*_state)->name() << " is included in state "
<< (*_stateHO)->name() << " but the latter has a higher priority.";
addError (*_state, oss.str());
success = false;
}
}
}
return success; return success;
} }
} // namespace graph } // namespace graph
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment