hpp-manipulation
9.0.2
Classes for manipulation planning.
Toggle main menu visibility
Loading...
Searching...
No Matches
validation.hh
Go to the documentation of this file.
1
// Copyright (c) 2019, LAAS-CNRS
2
// Authors: Joseph Mirabel (joseph.mirabel@laas.fr)
3
//
4
5
// Redistribution and use in source and binary forms, with or without
6
// modification, are permitted provided that the following conditions are
7
// met:
8
//
9
// 1. Redistributions of source code must retain the above copyright
10
// notice, this list of conditions and the following disclaimer.
11
//
12
// 2. Redistributions in binary form must reproduce the above copyright
13
// notice, this list of conditions and the following disclaimer in the
14
// documentation and/or other materials provided with the distribution.
15
//
16
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20
// HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
27
// DAMAGE.
28
29
#ifndef HPP_MANIPULATION_GRAPH_VALIDATION_REPORT_HH
30
#define HPP_MANIPULATION_GRAPH_VALIDATION_REPORT_HH
31
32
#include <
hpp/core/validation-report.hh
>
33
#include <
hpp/manipulation/config.hh
>
34
#include <
hpp/manipulation/fwd.hh
>
35
#include <
hpp/manipulation/graph/fwd.hh
>
36
#include <
hpp/manipulation/graph/graph.hh
>
37
#include <string>
38
#include <vector>
39
40
namespace
hpp
{
41
namespace
manipulation
{
42
namespace
graph
{
45
50
class
HPP_MANIPULATION_DLLAPI
Validation
{
51
public
:
52
typedef
std::vector<std::string>
Collision
;
53
typedef
std::vector<Collision>
CollisionList
;
54
typedef
std::map<std::string, CollisionList>
CollisionMap
;
55
Validation
(
const
core::ProblemPtr_t
&
problem
) : problem_(
problem
) {}
56
57
void
clear
() {
58
warnings_.clear();
59
errors_.clear();
60
}
61
62
bool
hasWarnings
()
const
{
return
!warnings_.empty(); }
63
64
bool
hasErrors
()
const
{
return
!errors_.empty(); }
65
66
virtual
std::ostream&
print
(std::ostream& os)
const
;
67
74
bool
validate
(
const
GraphComponentPtr_t
& comp);
75
79
bool
validateState
(
const
StatePtr_t
& state);
80
84
bool
validateEdge
(
const
EdgePtr_t
& edge);
85
89
bool
validateGraph
(
const
GraphPtr_t
&
graph
);
90
91
CollisionList
getCollisionsForNode
(
const
std::string& nodeName) {
92
return
collisions_[nodeName];
93
}
94
95
private
:
96
void
addWarning(
const
GraphComponentPtr_t
& c,
const
std::string& w) {
97
warnings_.push_back(Message(c, w));
98
}
99
100
void
addError(
const
GraphComponentPtr_t& c,
const
std::string& w) {
101
errors_.push_back(Message(c, w));
102
}
103
104
void
addCollision(
const
GraphComponentPtr_t& c,
const
std::string& obj1,
105
const
std::string& obj2) {
106
Collision coll = Collision{obj1, obj2};
107
collisions_[c->name()].push_back(coll);
108
}
109
110
typedef
std::pair<GraphComponentPtr_t, std::string> Message;
111
std::vector<Message> warnings_, errors_;
112
CollisionMap collisions_;
113
114
core::ProblemPtr_t problem_;
115
};
116
117
inline
std::ostream&
operator<<
(std::ostream& os,
const
Validation
& v) {
118
return
v.
print
(os);
119
}
120
122
}
// namespace graph
123
}
// namespace manipulation
124
125
}
// namespace hpp
126
127
#endif
// HPP_MANIPULATION_GRAPH_VALIDATION_REPORT_HH
hpp::manipulation::graph::Validation
Definition
validation.hh:50
hpp::manipulation::graph::Validation::print
virtual std::ostream & print(std::ostream &os) const
hpp::manipulation::graph::Validation::CollisionList
std::vector< Collision > CollisionList
Definition
validation.hh:53
hpp::manipulation::graph::Validation::validateGraph
bool validateGraph(const GraphPtr_t &graph)
hpp::manipulation::graph::Validation::validateState
bool validateState(const StatePtr_t &state)
hpp::manipulation::graph::Validation::getCollisionsForNode
CollisionList getCollisionsForNode(const std::string &nodeName)
Definition
validation.hh:91
hpp::manipulation::graph::Validation::Validation
Validation(const core::ProblemPtr_t &problem)
Definition
validation.hh:55
hpp::manipulation::graph::Validation::validateEdge
bool validateEdge(const EdgePtr_t &edge)
hpp::manipulation::graph::Validation::clear
void clear()
Definition
validation.hh:57
hpp::manipulation::graph::Validation::validate
bool validate(const GraphComponentPtr_t &comp)
hpp::manipulation::graph::Validation::CollisionMap
std::map< std::string, CollisionList > CollisionMap
Definition
validation.hh:54
hpp::manipulation::graph::Validation::Collision
std::vector< std::string > Collision
Definition
validation.hh:52
hpp::manipulation::graph::Validation::hasErrors
bool hasErrors() const
Definition
validation.hh:64
hpp::manipulation::graph::Validation::hasWarnings
bool hasWarnings() const
Definition
validation.hh:62
config.hh
HPP_MANIPULATION_DLLAPI
#define HPP_MANIPULATION_DLLAPI
Definition
config.hh:88
fwd.hh
fwd.hh
graph.hh
hpp::manipulation::graph::operator<<
std::ostream & operator<<(std::ostream &os, const GraphComponent &graphComp)
problem
ProblemConstPtr_t problem() const
hpp::core::ProblemPtr_t
shared_ptr< Problem > ProblemPtr_t
hpp::manipulation::graph
Definition
dot.hh:39
hpp::manipulation::graph::EdgePtr_t
shared_ptr< Edge > EdgePtr_t
Definition
fwd.hh:49
hpp::manipulation::graph::StatePtr_t
shared_ptr< State > StatePtr_t
Definition
fwd.hh:48
hpp::manipulation::graph::GraphComponentPtr_t
shared_ptr< GraphComponent > GraphComponentPtr_t
Definition
fwd.hh:54
hpp::manipulation::graph::GraphPtr_t
shared_ptr< Graph > GraphPtr_t
Definition
fwd.hh:47
hpp::manipulation
Definition
main.hh:2
hpp
validation-report.hh
include
hpp
manipulation
graph
validation.hh
Generated by
1.17.0