Skip to content
Snippets Groups Projects
Commit 33160bdf authored by Diane Bury's avatar Diane Bury Committed by Florent Lamiraux
Browse files

[GraphValidation] Add method to get collision list for a node

parent a4f03d71
No related branches found
No related tags found
No related merge requests found
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
# include <hpp/manipulation/config.hh> # include <hpp/manipulation/config.hh>
# include <hpp/manipulation/fwd.hh> # include <hpp/manipulation/fwd.hh>
# include <hpp/manipulation/graph/fwd.hh> # include <hpp/manipulation/graph/fwd.hh>
# include <hpp/manipulation/graph/graph.hh>
namespace hpp { namespace hpp {
namespace manipulation { namespace manipulation {
...@@ -38,6 +39,9 @@ namespace hpp { ...@@ -38,6 +39,9 @@ namespace hpp {
class HPP_MANIPULATION_DLLAPI Validation class HPP_MANIPULATION_DLLAPI Validation
{ {
public: public:
typedef std::vector<std::string> Collision;
typedef std::vector<Collision> CollisionList;
typedef std::map<std::string, CollisionList> CollisionMap;
Validation(const core::ProblemPtr_t& problem) Validation(const core::ProblemPtr_t& problem)
: problem_ (problem) {} : problem_ (problem) {}
...@@ -76,6 +80,11 @@ namespace hpp { ...@@ -76,6 +80,11 @@ namespace hpp {
/// \note Even if true is returned, the report can contain warnings. /// \note Even if true is returned, the report can contain warnings.
bool validateGraph (const GraphPtr_t& graph); bool validateGraph (const GraphPtr_t& graph);
CollisionList getCollisionsForNode (const std::string& nodeName)
{
return collisions_[nodeName];
}
private: private:
void addWarning (const GraphComponentPtr_t& c, const std::string& w) void addWarning (const GraphComponentPtr_t& c, const std::string& w)
...@@ -88,8 +97,16 @@ namespace hpp { ...@@ -88,8 +97,16 @@ namespace hpp {
errors_.push_back (Message (c, w)); errors_.push_back (Message (c, w));
} }
void addCollision (const GraphComponentPtr_t& c, const std::string& obj1,
const std::string& obj2)
{
Collision coll = Collision{obj1, obj2};
collisions_[c->name()].push_back(coll);
}
typedef std::pair<GraphComponentPtr_t, std::string> Message; typedef std::pair<GraphComponentPtr_t, std::string> Message;
std::vector<Message> warnings_, errors_; std::vector<Message> warnings_, errors_;
CollisionMap collisions_;
core::ProblemPtr_t problem_; core::ProblemPtr_t problem_;
}; };
......
...@@ -25,9 +25,9 @@ ...@@ -25,9 +25,9 @@
#include <hpp/core/collision-validation.hh> #include <hpp/core/collision-validation.hh>
#include <hpp/core/configuration-shooter.hh> #include <hpp/core/configuration-shooter.hh>
#include <hpp/core/relative-motion.hh> #include <hpp/core/relative-motion.hh>
#include <hpp/core/collision-validation-report.hh>
#include "hpp/manipulation/problem.hh" #include "hpp/manipulation/problem.hh"
#include "hpp/manipulation/graph/graph.hh"
#include "hpp/manipulation/graph/edge.hh" #include "hpp/manipulation/graph/edge.hh"
#include "hpp/manipulation/graph/state.hh" #include "hpp/manipulation/graph/state.hh"
#include "hpp/manipulation/graph/state-selector.hh" #include "hpp/manipulation/graph/state-selector.hh"
...@@ -157,6 +157,10 @@ namespace hpp { ...@@ -157,6 +157,10 @@ namespace hpp {
oss << incindent << "The following collision pairs will always " oss << incindent << "The following collision pairs will always "
"collide." << incendl << *colReport << decindent; "collide." << incendl << *colReport << decindent;
addError (state, oss.str()); addError (state, oss.str());
if (HPP_DYNAMIC_PTR_CAST(core::CollisionValidationReport, colReport)) {
std::pair<std::string, std::string> names = HPP_DYNAMIC_PTR_CAST(core::CollisionValidationReport, colReport)->getObjectNames();
addCollision (state, names.first, names.second);
}
success = false; success = false;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment