| 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_ROADMAP_HH |
| 30 |
|
|
#define HPP_MANIPULATION_ROADMAP_HH |
| 31 |
|
|
|
| 32 |
|
|
#include <hpp/core/roadmap.hh> |
| 33 |
|
|
#include <hpp/manipulation/deprecated.hh> |
| 34 |
|
|
#include <hpp/manipulation/leaf-connected-comp.hh> |
| 35 |
|
|
|
| 36 |
|
|
#include "hpp/manipulation/config.hh" |
| 37 |
|
|
#include "hpp/manipulation/fwd.hh" |
| 38 |
|
|
#include "hpp/manipulation/graph/fwd.hh" |
| 39 |
|
|
|
| 40 |
|
|
namespace hpp { |
| 41 |
|
|
namespace manipulation { |
| 42 |
|
|
/// \addtogroup roadmap |
| 43 |
|
|
/// \{ |
| 44 |
|
|
|
| 45 |
|
|
/// Extension of hpp::core::Roadmap. It adds the ability of doing |
| 46 |
|
|
/// statistics on the graph |
| 47 |
|
|
class HPP_MANIPULATION_DLLAPI Roadmap : public core::Roadmap { |
| 48 |
|
|
public: |
| 49 |
|
|
typedef core::Roadmap Parent; |
| 50 |
|
|
|
| 51 |
|
|
/// Return a shared pointer to a new instance |
| 52 |
|
|
static RoadmapPtr_t create(const core::DistancePtr_t& distance, |
| 53 |
|
|
const core::DevicePtr_t& robot); |
| 54 |
|
|
|
| 55 |
|
|
/// Register histogram so that each time a node is added to the roadmap, |
| 56 |
|
|
/// it is also added to the histogram |
| 57 |
|
|
void insertHistogram(const graph::HistogramPtr_t hist); |
| 58 |
|
|
|
| 59 |
|
|
/// Register the constraint graph to do statistics. |
| 60 |
|
|
void constraintGraph(const graph::GraphPtr_t& graph); |
| 61 |
|
|
|
| 62 |
|
|
/// Clear the histograms and call parent implementation. |
| 63 |
|
|
void clear(); |
| 64 |
|
|
|
| 65 |
|
|
/// Catch event 'New node added' |
| 66 |
|
|
void push_node(const core::NodePtr_t& n); |
| 67 |
|
|
|
| 68 |
|
|
/// Get the nearest neighbor in a given graph::Node and in a given |
| 69 |
|
|
/// ConnectedComponent. |
| 70 |
|
|
RoadmapNodePtr_t nearestNodeInState( |
| 71 |
|
|
ConfigurationIn_t configuration, |
| 72 |
|
|
const ConnectedComponentPtr_t& connectedComponent, |
| 73 |
|
|
const graph::StatePtr_t& state, value_type& minDistance) const; |
| 74 |
|
|
|
| 75 |
|
|
/// Update the graph of connected components after new connection |
| 76 |
|
|
/// \param cc1, cc2 the two connected components that have just been |
| 77 |
|
|
/// connected. |
| 78 |
|
|
void connect(const LeafConnectedCompPtr_t& cc1, |
| 79 |
|
|
const LeafConnectedCompPtr_t& cc2); |
| 80 |
|
|
|
| 81 |
|
|
/// Merge two connected components |
| 82 |
|
|
/// \param cc1 the connected component to merge into |
| 83 |
|
|
/// \param the connected components to merge into cc1. |
| 84 |
|
|
void merge(const LeafConnectedCompPtr_t& cc1, |
| 85 |
|
|
LeafConnectedComp::LeafConnectedComps_t& ccs); |
| 86 |
|
|
|
| 87 |
|
|
/// Get graph state corresponding to given roadmap node |
| 88 |
|
|
graph::StatePtr_t getState(RoadmapNodePtr_t node); |
| 89 |
|
|
|
| 90 |
|
|
/// Get leaf connected components |
| 91 |
|
|
/// |
| 92 |
|
|
/// Leaf connected components are composed of nodes |
| 93 |
|
|
/// \li belonging to the same connected component of the roadmap and, |
| 94 |
|
|
/// \li lying in the same leaf of a transition. |
| 95 |
|
|
const LeafConnectedComps_t& leafConnectedComponents() const { |
| 96 |
|
|
return leafCCs_; |
| 97 |
|
|
} |
| 98 |
|
|
|
| 99 |
|
|
protected: |
| 100 |
|
|
/// Register a new configuration. |
| 101 |
|
|
void statInsert(const RoadmapNodePtr_t& n); |
| 102 |
|
|
|
| 103 |
|
|
/// Constructor |
| 104 |
|
|
Roadmap(const core::DistancePtr_t& distance, const core::DevicePtr_t& robot); |
| 105 |
|
|
|
| 106 |
|
|
/// Node factory |
| 107 |
|
|
core::NodePtr_t createNode(ConfigurationIn_t config) const; |
| 108 |
|
|
|
| 109 |
|
✗ |
void init(const RoadmapPtr_t& shPtr) { |
| 110 |
|
✗ |
Parent::init(shPtr); |
| 111 |
|
✗ |
weak_ = shPtr; |
| 112 |
|
|
} |
| 113 |
|
|
|
| 114 |
|
|
virtual void impl_addEdge(const core::EdgePtr_t& edge); |
| 115 |
|
|
|
| 116 |
|
|
private: |
| 117 |
|
|
typedef graph::Histograms_t Histograms_t; |
| 118 |
|
|
/// Keep track of the leaf that are explored. |
| 119 |
|
|
/// There should be one histogram per foliation. |
| 120 |
|
|
Histograms_t histograms_; |
| 121 |
|
|
graph::GraphPtr_t graph_; |
| 122 |
|
|
RoadmapWkPtr_t weak_; |
| 123 |
|
|
LeafConnectedComps_t leafCCs_; |
| 124 |
|
|
|
| 125 |
|
✗ |
Roadmap() {} |
| 126 |
|
|
HPP_SERIALIZABLE(); |
| 127 |
|
|
}; |
| 128 |
|
|
/// \} |
| 129 |
|
|
} // namespace manipulation |
| 130 |
|
|
} // namespace hpp |
| 131 |
|
|
|
| 132 |
|
|
#endif // HPP_MANIPULATION_ROADMAP_HH |
| 133 |
|
|
|