| 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_STATE_SELECTOR_HH |
| 30 |
|
|
#define HPP_MANIPULATION_GRAPH_STATE_SELECTOR_HH |
| 31 |
|
|
|
| 32 |
|
|
#include "hpp/manipulation/config.hh" |
| 33 |
|
|
#include "hpp/manipulation/fwd.hh" |
| 34 |
|
|
#include "hpp/manipulation/graph/graph.hh" |
| 35 |
|
|
#include "hpp/manipulation/graph/state.hh" |
| 36 |
|
|
|
| 37 |
|
|
namespace hpp { |
| 38 |
|
|
namespace manipulation { |
| 39 |
|
|
namespace graph { |
| 40 |
|
|
/// This class is used to get the state of a configuration. States have to |
| 41 |
|
|
/// be ordered because a configuration can be in several states. |
| 42 |
|
|
class HPP_MANIPULATION_DLLAPI StateSelector { |
| 43 |
|
|
public: |
| 44 |
|
✗ |
virtual ~StateSelector() {}; |
| 45 |
|
|
|
| 46 |
|
|
/// Create a new StateSelector. |
| 47 |
|
|
static StateSelectorPtr_t create(const std::string& name); |
| 48 |
|
|
|
| 49 |
|
|
const std::string& name() const { return name_; } |
| 50 |
|
|
|
| 51 |
|
|
/// Create an empty state |
| 52 |
|
|
StatePtr_t createState(const std::string& name, bool waypoint = false, |
| 53 |
|
|
const int w = 0); |
| 54 |
|
|
|
| 55 |
|
|
/// Returns the state of a configuration. |
| 56 |
|
|
StatePtr_t getState(ConfigurationIn_t config) const; |
| 57 |
|
|
|
| 58 |
|
|
/// Returns the state of a roadmap state |
| 59 |
|
|
StatePtr_t getState(RoadmapNodePtr_t node) const; |
| 60 |
|
|
|
| 61 |
|
|
/// Returns a list of all the states |
| 62 |
|
|
States_t getStates() const; |
| 63 |
|
|
|
| 64 |
|
|
/// Returns a list of all the states |
| 65 |
|
|
States_t getWaypointStates() const; |
| 66 |
|
|
|
| 67 |
|
|
/// Select randomly an outgoing edge of the given state. |
| 68 |
|
|
virtual EdgePtr_t chooseEdge(RoadmapNodePtr_t from) const; |
| 69 |
|
|
|
| 70 |
|
|
/// Print the object in a stream. |
| 71 |
|
|
virtual std::ostream& dotPrint( |
| 72 |
|
|
std::ostream& os, |
| 73 |
|
|
dot::DrawingAttributes da = dot::DrawingAttributes()) const; |
| 74 |
|
|
|
| 75 |
|
|
/// Set the parent graph. |
| 76 |
|
|
void parentGraph(const GraphWkPtr_t& parent); |
| 77 |
|
|
|
| 78 |
|
|
/// Set the parent graph. |
| 79 |
|
|
GraphPtr_t parentGraph() const; |
| 80 |
|
|
|
| 81 |
|
|
protected: |
| 82 |
|
|
/// Initialization of the object. |
| 83 |
|
|
void init(const StateSelectorPtr_t& weak); |
| 84 |
|
|
|
| 85 |
|
|
/// Constructor |
| 86 |
1/2
✓ Branch 3 taken 4 times.
✗ Branch 4 not taken.
|
4 |
StateSelector(const std::string& name) : name_(name) {} |
| 87 |
|
|
|
| 88 |
|
|
/// Print the object in a stream. |
| 89 |
|
|
virtual std::ostream& print(std::ostream& os) const; |
| 90 |
|
|
|
| 91 |
|
|
/// List of the states of one end-effector, ordered by priority. |
| 92 |
|
|
typedef std::pair<int, StatePtr_t> WeighedState_t; |
| 93 |
|
|
typedef std::list<WeighedState_t> WeighedStates_t; |
| 94 |
|
|
WeighedStates_t orderedStates_; |
| 95 |
|
|
States_t waypoints_; |
| 96 |
|
|
|
| 97 |
|
|
private: |
| 98 |
|
|
/// Name of the component. |
| 99 |
|
|
std::string name_; |
| 100 |
|
|
/// A weak pointer to the parent graph. |
| 101 |
|
|
GraphWkPtr_t graph_; |
| 102 |
|
|
/// Weak pointer to itself. |
| 103 |
|
|
StateSelectorPtr_t wkPtr_; |
| 104 |
|
|
|
| 105 |
|
|
friend std::ostream& operator<<(std::ostream& os, const StateSelector& ss); |
| 106 |
|
|
}; // Class StateSelector |
| 107 |
|
|
|
| 108 |
|
✗ |
inline std::ostream& operator<<(std::ostream& os, const StateSelector& ss) { |
| 109 |
|
✗ |
return ss.print(os); |
| 110 |
|
|
} |
| 111 |
|
|
} // namespace graph |
| 112 |
|
|
} // namespace manipulation |
| 113 |
|
|
} // namespace hpp |
| 114 |
|
|
|
| 115 |
|
|
#endif // HPP_MANIPULATION_GRAPH_STATE_SELECTOR_HH |
| 116 |
|
|
|