hpp-core  4.9.0
Implement basic classes for canonical path planning for kinematic chains.
roadmap-factory.hh
Go to the documentation of this file.
1 // Copyright (c) 2015 CNRS
2 // Authors: Joseph Mirabel
3 //
4 // This file is part of hpp-core
5 // hpp-core is free software: you can redistribute it
6 // and/or modify it under the terms of the GNU Lesser General Public
7 // License as published by the Free Software Foundation, either version
8 // 3 of the License, or (at your option) any later version.
9 //
10 // hpp-core is distributed in the hope that it will be
11 // useful, but WITHOUT ANY WARRANTY; without even the implied warranty
12 // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 // General Lesser Public License for more details. You should have
14 // received a copy of the GNU Lesser General Public License along with
15 // hpp-core If not, see
16 // <http://www.gnu.org/licenses/>.
17 
18 #ifndef HPP_CORE_PARSER_ROADMAP_FACTORY_HH
19 # define HPP_CORE_PARSER_ROADMAP_FACTORY_HH
20 
21 # include <hpp/util/parser.hh>
22 
23 # include <hpp/util/factories/sequence.hh>
24 
25 # include <hpp/core/fwd.hh>
26 # include <hpp/core/config.hh>
27 
28 namespace hpp {
29  namespace core {
30  namespace parser {
33 
39 
41  void writeRoadmap (std::ostream& o, const ProblemPtr_t& problem,
42  const RoadmapPtr_t& roadmap);
43 
45  RoadmapPtr_t readRoadmap (const std::string& filename,
46  const ProblemPtr_t& problem);
47 
49  RoadmapPtr_t readRoadmap (const std::string& filename,
50  const RoadmapPtr_t& roadmap, const ProblemPtr_t& problem);
51 
52  class HPP_CORE_DLLAPI RoadmapFactory : public ObjectFactory {
53  public:
54  typedef ::hpp::util::parser::ObjectFactory Parent_t;
55 
58  const RoadmapPtr_t& roadmap, const ProblemPtr_t& problem,
59  ObjectFactory* parent, const XMLElement* element);
60 
61  RoadmapPtr_t roadmap () const {
62  return roadmap_;
63  }
64 
66  const RoadmapPtr_t& r, const ProblemPtr_t& p,
67  ObjectFactory* parent, const XMLElement* el)
68  {
69  return new RoadmapFactory (r, p, parent, el);
70  }
71 
72  virtual bool finishAttributes ();
73 
74  virtual void finishTags ();
75 
76  RoadmapFactory (const ProblemPtr_t& problem,
77  const RoadmapPtr_t& roadmap, ObjectFactory* parent = NULL);
78 
79  private:
80  ProblemPtr_t problem_;
81 
82  void computePermutation (const std::vector <std::string>& jointNames);
83  ConfigurationPtr_t permuteAndCreateConfiguration
84  (const std::vector <double>& config);
85 
86  size_type getNodeIdFromRoadmap (const NodePtr_t& node) const;
87 
88  RoadmapPtr_t roadmap_;
89 
90  typedef std::vector <std::size_t> SizeVector_t;
91  SizeVector_t permutation_;
92 
93  size_type extraCSsize_;
94 
95  typedef std::vector <NodePtr_t> Nodes_t;
96  typedef std::vector <EdgePtr_t> Edges_t;
97  Nodes_t nodes_;
98  Edges_t edges_;
99  }; // class RoadmapVisitor
101  } // namespace parser
102  } // namespace core
103 } // namespace hpp
104 #endif // HPP_CORE_PARSER_ROADMAP_FACTORY_HH
void writeRoadmap(std::ostream &o, const ProblemPtr_t &problem, const RoadmapPtr_t &roadmap)
Write roadmap to a text file.
RoadmapPtr_t readRoadmap(const std::string &filename, const ProblemPtr_t &problem)
Create a new roadmap from a file.
hpp::util::parser::SequenceFactory< std::string > StringSequence
Definition: roadmap-factory.hh:36
pinocchio::size_type size_type
Definition: fwd.hh:156
FCL_REAL r
TiXmlElement XMLElement
static ObjectFactory * create(const RoadmapPtr_t &r, const ProblemPtr_t &p, ObjectFactory *parent, const XMLElement *el)
Definition: roadmap-factory.hh:65
Definition: node.hh:34
RoadmapPtr_t roadmap() const
Definition: roadmap-factory.hh:61
std::list< NodePtr_t > Nodes_t
Definition: fwd.hh:164
hpp::util::parser::SequenceFactory< unsigned int > IdSequence
Definition: roadmap-factory.hh:38
hpp::util::parser::SequenceFactory< double > ConfigurationFactory
Definition: roadmap-factory.hh:37
pinocchio::ConfigurationPtr_t ConfigurationPtr_t
Definition: fwd.hh:99
std::list< Edge * > Edges_t
Definition: fwd.hh:127
boost::shared_ptr< Roadmap > RoadmapPtr_t
Definition: fwd.hh:181
::hpp::util::parser::ObjectFactory Parent_t
Definition: roadmap-factory.hh:54
boost::shared_ptr< Problem > ProblemPtr_t
Definition: fwd.hh:179
Definition: roadmap-factory.hh:52
Vec3f o