| Line |
Branch |
Exec |
Source |
| 1 |
|
|
// Copyright (c) 2014 CNRS |
| 2 |
|
|
// Author: Florent Lamiraux, Joseph Mirabel |
| 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_PROBLEM_SOLVER_HH |
| 30 |
|
|
#define HPP_MANIPULATION_PROBLEM_SOLVER_HH |
| 31 |
|
|
|
| 32 |
|
|
#include <hpp/core/container.hh> |
| 33 |
|
|
#include <hpp/core/problem-solver.hh> |
| 34 |
|
|
#include <hpp/pinocchio/device.hh> |
| 35 |
|
|
#include <map> |
| 36 |
|
|
|
| 37 |
|
|
#include "hpp/manipulation/constraint-set.hh" |
| 38 |
|
|
#include "hpp/manipulation/deprecated.hh" |
| 39 |
|
|
#include "hpp/manipulation/device.hh" |
| 40 |
|
|
#include "hpp/manipulation/fwd.hh" |
| 41 |
|
|
#include "hpp/manipulation/graph/fwd.hh" |
| 42 |
|
|
|
| 43 |
|
|
namespace hpp { |
| 44 |
|
|
namespace manipulation { |
| 45 |
|
|
class HPP_MANIPULATION_DLLAPI ProblemSolver : public core::ProblemSolver { |
| 46 |
|
|
public: |
| 47 |
|
|
typedef core::ProblemSolver parent_t; |
| 48 |
|
|
typedef std::vector<std::string> Names_t; |
| 49 |
|
|
|
| 50 |
|
|
/// Destructor |
| 51 |
|
✗ |
virtual ~ProblemSolver() {} |
| 52 |
|
|
|
| 53 |
|
|
ProblemSolver(); |
| 54 |
|
|
|
| 55 |
|
|
static ProblemSolverPtr_t create(); |
| 56 |
|
|
|
| 57 |
|
|
/// Set robot |
| 58 |
|
|
/// Check that robot is of type hpp::manipulation::Device |
| 59 |
|
✗ |
virtual void robot(const core::DevicePtr_t& robot) { |
| 60 |
|
✗ |
robot_ = HPP_DYNAMIC_PTR_CAST(Device, robot); |
| 61 |
|
✗ |
assert(robot_); |
| 62 |
|
✗ |
parent_t::robot(robot); |
| 63 |
|
|
} |
| 64 |
|
|
|
| 65 |
|
|
/// Get robot |
| 66 |
|
✗ |
const DevicePtr_t& robot() const { return robot_; } |
| 67 |
|
|
|
| 68 |
|
|
/// \name Constraint graph |
| 69 |
|
|
/// \{ |
| 70 |
|
|
|
| 71 |
|
|
/// Set the constraint graph |
| 72 |
|
|
void constraintGraph(const std::string& graph); |
| 73 |
|
|
|
| 74 |
|
|
/// Get the constraint graph |
| 75 |
|
|
graph::GraphPtr_t constraintGraph() const; |
| 76 |
|
|
|
| 77 |
|
|
/// Should be called before any call on the graph is made. |
| 78 |
|
|
void initConstraintGraph(); |
| 79 |
|
|
/// \} |
| 80 |
|
|
|
| 81 |
|
|
/// Create placement constraint |
| 82 |
|
|
/// \param name name of the placement constraint, |
| 83 |
|
|
/// \param triangleName name of the first list of triangles, |
| 84 |
|
|
/// \param envContactName name of the second list of triangles. |
| 85 |
|
|
/// \param margin see hpp::constraints::ConvexShapeContact::setNormalMargin |
| 86 |
|
|
/// |
| 87 |
|
|
void createPlacementConstraint(const std::string& name, |
| 88 |
|
|
const Strings_t& surface1, |
| 89 |
|
|
const Strings_t& surface2, |
| 90 |
|
|
const value_type& margin = 1e-4); |
| 91 |
|
|
|
| 92 |
|
|
/// Create pre-placement constraint |
| 93 |
|
|
/// \param name name of the placement constraint, |
| 94 |
|
|
/// \param triangleName name of the first list of triangles, |
| 95 |
|
|
/// \param envContactName name of the second list of triangles. |
| 96 |
|
|
/// \param width approaching distance. |
| 97 |
|
|
/// \param margin see hpp::constraints::ConvexShapeContact::setNormalMargin |
| 98 |
|
|
/// |
| 99 |
|
|
void createPrePlacementConstraint(const std::string& name, |
| 100 |
|
|
const Strings_t& surface1, |
| 101 |
|
|
const Strings_t& surface2, |
| 102 |
|
|
const value_type& width, |
| 103 |
|
|
const value_type& margin = 1e-4); |
| 104 |
|
|
|
| 105 |
|
|
/// Create the grasp constraint and its complement |
| 106 |
|
|
/// \param name name of the grasp constraint, |
| 107 |
|
|
/// \param gripper gripper's name |
| 108 |
|
|
/// \param handle handle's name |
| 109 |
|
|
/// |
| 110 |
|
|
/// Two constraints are created: |
| 111 |
|
|
/// - "name" corresponds to the grasp constraint. |
| 112 |
|
|
/// - "name/complement" corresponds to the complement. |
| 113 |
|
|
void createGraspConstraint(const std::string& name, |
| 114 |
|
|
const std::string& gripper, |
| 115 |
|
|
const std::string& handle); |
| 116 |
|
|
|
| 117 |
|
|
/// Create pre-grasp constraint |
| 118 |
|
|
/// \param name name of the grasp constraint, |
| 119 |
|
|
/// \param gripper gripper's name |
| 120 |
|
|
/// \param handle handle's name |
| 121 |
|
|
/// |
| 122 |
|
|
void createPreGraspConstraint(const std::string& name, |
| 123 |
|
|
const std::string& gripper, |
| 124 |
|
|
const std::string& handle); |
| 125 |
|
|
|
| 126 |
|
|
virtual void pathValidationType(const std::string& type, |
| 127 |
|
|
const value_type& tolerance); |
| 128 |
|
|
|
| 129 |
|
|
/// Create a new problem. |
| 130 |
|
|
virtual void resetProblem(); |
| 131 |
|
|
|
| 132 |
|
|
/// Create a new Roadmap |
| 133 |
|
|
virtual void resetRoadmap(); |
| 134 |
|
|
|
| 135 |
|
|
/// Get pointer to problem |
| 136 |
|
✗ |
ProblemPtr_t problem() const { return problem_; } |
| 137 |
|
|
|
| 138 |
|
|
void setTargetState(const graph::StatePtr_t state); |
| 139 |
|
|
|
| 140 |
|
|
core::Container<graph::GraphPtr_t> graphs; |
| 141 |
|
|
|
| 142 |
|
|
ConstraintsAndComplements_t constraintsAndComplements; |
| 143 |
|
|
|
| 144 |
|
|
protected: |
| 145 |
|
|
virtual void initializeProblem(ProblemPtr_t problem); |
| 146 |
|
|
|
| 147 |
|
|
private: |
| 148 |
|
|
/// Keep track of the created components in order to retrieve them |
| 149 |
|
|
/// easily. |
| 150 |
|
|
graph::GraphComponents_t components_; |
| 151 |
|
|
|
| 152 |
|
|
DevicePtr_t robot_; |
| 153 |
|
|
/// The pointer should point to the same object as core::Problem. |
| 154 |
|
|
ProblemPtr_t problem_; |
| 155 |
|
|
graph::GraphPtr_t constraintGraph_; |
| 156 |
|
|
}; // class ProblemSolver |
| 157 |
|
|
} // namespace manipulation |
| 158 |
|
|
} // namespace hpp |
| 159 |
|
|
|
| 160 |
|
|
#endif // HPP_MANIPULATION_PROBLEM_SOLVER_HH |
| 161 |
|
|
|