Line |
Branch |
Exec |
Source |
1 |
|
|
// Copyright (c) 2014, 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_GRAPHCOMPONENT_HH |
30 |
|
|
#define HPP_MANIPULATION_GRAPH_GRAPHCOMPONENT_HH |
31 |
|
|
|
32 |
|
|
#include <ostream> |
33 |
|
|
#include <string> |
34 |
|
|
|
35 |
|
|
#include "hpp/manipulation/config.hh" |
36 |
|
|
#include "hpp/manipulation/deprecated.hh" |
37 |
|
|
#include "hpp/manipulation/fwd.hh" |
38 |
|
|
#include "hpp/manipulation/graph/dot.hh" |
39 |
|
|
#include "hpp/manipulation/graph/fwd.hh" |
40 |
|
|
|
41 |
|
|
namespace hpp { |
42 |
|
|
namespace manipulation { |
43 |
|
|
typedef constraints::ImplicitPtr_t ImplicitPtr_t; |
44 |
|
|
namespace graph { |
45 |
|
|
/// \defgroup constraint_graph Constraint Graph |
46 |
|
|
|
47 |
|
|
/// \addtogroup constraint_graph |
48 |
|
|
/// \{ |
49 |
|
|
|
50 |
|
|
/// Define common methods of the graph components. |
51 |
|
|
class HPP_MANIPULATION_DLLAPI GraphComponent { |
52 |
|
|
public: |
53 |
|
4 |
virtual ~GraphComponent() {}; |
54 |
|
|
|
55 |
|
|
/// Get the component name. |
56 |
|
|
const std::string& name() const; |
57 |
|
|
|
58 |
|
|
/// Return the component id. |
59 |
|
✗ |
const std::size_t& id() const { return id_; } |
60 |
|
|
|
61 |
|
|
/// Add constraint to the component. |
62 |
|
|
virtual void addNumericalConstraint(const ImplicitPtr_t& numConstraint); |
63 |
|
|
|
64 |
|
|
/// Add a cost function Implicit to the component. |
65 |
|
|
virtual void addNumericalCost(const ImplicitPtr_t& numCost); |
66 |
|
|
|
67 |
|
|
/// Reset the numerical constraints stored in the component. |
68 |
|
|
virtual void resetNumericalConstraints(); |
69 |
|
|
|
70 |
|
|
/// Insert the numerical constraints in a ConfigProjector |
71 |
|
|
/// \return true is at least one ImplicitPtr_t was inserted. |
72 |
|
|
bool insertNumericalConstraints(ConfigProjectorPtr_t& proj) const; |
73 |
|
|
|
74 |
|
|
/// Get a reference to the NumericalConstraints_t |
75 |
|
|
const NumericalConstraints_t& numericalConstraints() const; |
76 |
|
|
|
77 |
|
|
/// Get a reference to the NumericalConstraints_t |
78 |
|
|
const NumericalConstraints_t& numericalCosts() const; |
79 |
|
|
|
80 |
|
|
/// Set the parent graph. |
81 |
|
|
void parentGraph(const GraphWkPtr_t& parent); |
82 |
|
|
|
83 |
|
|
/// Set the parent graph. |
84 |
|
|
GraphPtr_t parentGraph() const; |
85 |
|
|
|
86 |
|
|
/// Print the component in DOT language. |
87 |
|
|
virtual std::ostream& dotPrint( |
88 |
|
|
std::ostream& os, |
89 |
|
|
dot::DrawingAttributes da = dot::DrawingAttributes()) const; |
90 |
|
|
|
91 |
|
|
/// Invalidate the component |
92 |
|
|
/// The component needs to be initialized again. |
93 |
|
6 |
virtual void invalidate() { isInit_ = false; } |
94 |
|
|
|
95 |
|
|
/// Set whether hierachical constraints are solved level by level |
96 |
|
|
/// \sa hpp::constraints::solver::HierarchicalIterative |
97 |
|
|
void solveLevelByLevel(bool solveLevelByLevel) { |
98 |
|
|
solveLevelByLevel_ = solveLevelByLevel; |
99 |
|
|
} |
100 |
|
|
|
101 |
|
|
/// Get whether hierachical constraints are solved level by level |
102 |
|
|
/// \sa hpp::constraints::solver::HierarchicalIterative |
103 |
|
20 |
bool solveLevelByLevel() const { return solveLevelByLevel_; } |
104 |
|
|
|
105 |
|
|
protected: |
106 |
|
|
/// Initialize the component |
107 |
|
|
void init(const GraphComponentWkPtr_t& weak); |
108 |
|
|
|
109 |
|
14 |
GraphComponent(const std::string& name) |
110 |
1/2
✓ Branch 4 taken 14 times.
✗ Branch 5 not taken.
|
14 |
: isInit_(false), name_(name), id_(-1), solveLevelByLevel_(false) {} |
111 |
|
|
|
112 |
|
|
/// Stores the numerical constraints. |
113 |
|
|
NumericalConstraints_t numericalConstraints_; |
114 |
|
|
/// Stores the numerical costs. |
115 |
|
|
NumericalConstraints_t numericalCosts_; |
116 |
|
|
/// A weak pointer to the parent graph. |
117 |
|
|
GraphWkPtr_t graph_; |
118 |
|
|
|
119 |
|
|
bool isInit_; |
120 |
|
|
|
121 |
|
|
void throwIfNotInitialized() const; |
122 |
|
|
|
123 |
|
|
/// Print the object in a stream. |
124 |
|
|
virtual std::ostream& print(std::ostream& os) const; |
125 |
|
|
friend std::ostream& operator<<(std::ostream&, const GraphComponent&); |
126 |
|
|
|
127 |
|
|
/// Populate DrawingAttributes tooltip |
128 |
|
|
virtual void populateTooltip(dot::Tooltip& tp) const; |
129 |
|
|
|
130 |
|
|
virtual void initialize() = 0; |
131 |
|
|
|
132 |
|
|
private: |
133 |
|
|
/// Name of the component. |
134 |
|
|
std::string name_; |
135 |
|
|
/// Weak pointer to itself. |
136 |
|
|
GraphComponentWkPtr_t wkPtr_; |
137 |
|
|
/// ID of the component (index in components vector). |
138 |
|
|
std::size_t id_; |
139 |
|
|
/// Whether the constraints are solved level by level |
140 |
|
|
bool solveLevelByLevel_; |
141 |
|
|
friend class Graph; |
142 |
|
|
}; |
143 |
|
|
|
144 |
|
|
std::ostream& operator<<(std::ostream& os, const GraphComponent& graphComp); |
145 |
|
|
|
146 |
|
|
/// \} |
147 |
|
|
} // namespace graph |
148 |
|
|
} // namespace manipulation |
149 |
|
|
|
150 |
|
|
} // namespace hpp |
151 |
|
|
|
152 |
|
|
#endif // HPP_MANIPULATION_GRAPH_GRAPHCOMPONENT_HH |
153 |
|
|
|