setup.h
Go to the documentation of this file.
1 //
2 // Copyright (c) 2018-2020, University of Edinburgh, University of Oxford
3 // All rights reserved.
4 //
5 // Redistribution and use in source and binary forms, with or without
6 // modification, are permitted provided that the following conditions are met:
7 //
8 // * Redistributions of source code must retain the above copyright notice,
9 // this list of conditions and the following disclaimer.
10 // * Redistributions in binary form must reproduce the above copyright
11 // notice, this list of conditions and the following disclaimer in the
12 // documentation and/or other materials provided with the distribution.
13 // * Neither the name of nor the names of its contributors may be used to
14 // endorse or promote products derived from this software without specific
15 // prior written permission.
16 //
17 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
21 // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22 // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23 // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24 // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25 // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26 // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27 // POSSIBILITY OF SUCH DAMAGE.
28 //
29 
30 #ifndef EXOTICA_CORE_SETUP_H_
31 #define EXOTICA_CORE_SETUP_H_
32 
33 #include <memory>
34 #include <vector>
35 
37 #include <exotica_core/factory.h>
39 #include <exotica_core/object.h>
41 #include <exotica_core/property.h>
42 
43 #include <pluginlib/class_loader.h>
44 
45 namespace exotica
46 {
47 class Setup : public Object, Uncopyable
48 {
49 public:
50  ~Setup() noexcept
51  {
52  Destroy();
53  }
54 
55  static std::shared_ptr<Setup> Instance()
56  {
59  }
60 
61  static void Destroy();
62 
63  static void PrintSupportedClasses();
64  static std::shared_ptr<exotica::MotionSolver> CreateSolver(const std::string& type, bool prepend = true) { return ToStdPtr(Instance()->solvers_.createInstance((prepend ? "exotica/" : "") + type)); }
65  static std::shared_ptr<exotica::TaskMap> CreateMap(const std::string& type, bool prepend = true) { return ToStdPtr(Instance()->maps_.createInstance((prepend ? "exotica/" : "") + type)); }
66  static std::shared_ptr<exotica::PlanningProblem> CreateProblem(const std::string& type, bool prepend = true) { return Instance()->problems_.CreateInstance((prepend ? "exotica/" : "") + type); }
67  static std::shared_ptr<exotica::CollisionScene> CreateCollisionScene(const std::string& type, bool prepend = true) { return ToStdPtr(Instance()->collision_scenes_.createInstance((prepend ? "exotica/" : "") + type)); }
68  static std::shared_ptr<exotica::DynamicsSolver> CreateDynamicsSolver(const std::string& type, bool prepend = true) { return ToStdPtr(Instance()->dynamics_solvers_.createInstance((prepend ? "exotica/" : "") + type)); }
69  static std::vector<std::string> GetSolvers();
70  static std::vector<std::string> GetProblems();
71  static std::vector<std::string> GetMaps();
72  static std::vector<std::string> GetCollisionScenes();
73  static std::vector<std::string> GetDynamicsSolvers();
74  static std::vector<Initializer> GetInitializers();
75 
76  static std::shared_ptr<exotica::MotionSolver> CreateSolver(const Initializer& init)
77  {
78  std::shared_ptr<exotica::MotionSolver> ret = ToStdPtr(Instance()->solvers_.createInstance(init.GetName()));
79  ret->InstantiateInternal(init);
80  return ret;
81  }
82  static std::shared_ptr<exotica::PlanningProblem> CreateProblem(const Initializer& init)
83  {
84  std::shared_ptr<exotica::PlanningProblem> ret = Instance()->problems_.CreateInstance(init.GetName());
85  ret->InstantiateInternal(init);
86  return ret;
87  }
88 
99  {
100  exotica::ScenePtr ret = std::make_shared<exotica::Scene>();
101  ret->InstantiateInternal(init);
102  return ret;
103  }
104 
105  static std::shared_ptr<exotica::DynamicsSolver> CreateDynamicsSolver(const Initializer& init)
106  {
107  auto ret = ToStdPtr(Instance()->dynamics_solvers_.createInstance(init.GetName()));
108  ret->InstantiateInternal(init);
109  return ret;
110  }
111 
112  static std::shared_ptr<exotica::CollisionScene> CreateCollisionScene(const Initializer& init)
113  {
114  auto ret = ToStdPtr(Instance()->collision_scenes_.createInstance(init.GetName()));
115  ret->InstantiateInternal(init);
116  return ret;
117  }
118 
119 private:
121  Setup();
122  static std::shared_ptr<Setup> singleton_initialiser_;
123  // Make sure the singleton does not get copied
124  Setup(Setup const&) = delete;
125  void operator=(Setup const&) = delete;
126 
127  static std::shared_ptr<exotica::TaskMap> CreateMap(const Initializer& init)
128  {
129  std::shared_ptr<exotica::TaskMap> ret = ToStdPtr(Instance()->maps_.createInstance(init.GetName()));
130  ret->InstantiateInternal(init);
131  return ret;
132  }
133 
139 };
140 
141 typedef std::shared_ptr<Setup> SetupPtr;
142 } // namespace exotica
143 
144 #endif // EXOTICA_CORE_SETUP_H_
exotica::Setup::solvers_
pluginlib::ClassLoader< exotica::MotionSolver > solvers_
Definition: setup.h:134
exotica::Object::type
virtual std::string type() const
Type Information wrapper: must be virtual so that it is polymorphic...
Definition: object.h:61
ToStdPtr
std::shared_ptr< T > ToStdPtr(const boost::shared_ptr< T > &p)
Definition: tools.h:148
exotica::Setup::CreateMap
static std::shared_ptr< exotica::TaskMap > CreateMap(const Initializer &init)
Definition: setup.h:127
exotica::Setup::collision_scenes_
pluginlib::ClassLoader< exotica::CollisionScene > collision_scenes_
Definition: setup.h:136
exotica::Uncopyable
Definition: uncopyable.h:35
class_loader.h
factory.h
planning_problem.h
exotica::Setup::CreateDynamicsSolver
static std::shared_ptr< exotica::DynamicsSolver > CreateDynamicsSolver(const std::string &type, bool prepend=true)
Definition: setup.h:68
property.h
exotica::Setup::~Setup
~Setup() noexcept
Definition: setup.h:50
exotica::Setup::operator=
void operator=(Setup const &)=delete
exotica::Setup::CreateProblem
static std::shared_ptr< exotica::PlanningProblem > CreateProblem(const Initializer &init)
Definition: setup.h:82
exotica::Setup::Destroy
static void Destroy()
Definition: setup.cpp:42
exotica::Factory< PlanningProblem >
exotica
Definition: collision_scene.h:46
exotica::Setup::GetMaps
static std::vector< std::string > GetMaps()
Definition: setup.cpp:163
exotica::SetupPtr
std::shared_ptr< Setup > SetupPtr
Definition: setup.h:141
exotica::Setup::CreateDynamicsSolver
static std::shared_ptr< exotica::DynamicsSolver > CreateDynamicsSolver(const Initializer &init)
Definition: setup.h:105
exotica::Setup::CreateProblem
static std::shared_ptr< exotica::PlanningProblem > CreateProblem(const std::string &type, bool prepend=true)
Definition: setup.h:66
exotica::Setup::GetDynamicsSolvers
static std::vector< std::string > GetDynamicsSolvers()
Definition: setup.cpp:165
exotica::ScenePtr
std::shared_ptr< Scene > ScenePtr
Definition: scene.h:246
exotica::Setup
Definition: setup.h:47
exotica::Object
Definition: object.h:44
exotica::Setup::CreateScene
static exotica::ScenePtr CreateScene(const Initializer &init)
CreateScene instantiate a scene from an initialiser The returned scene is independent of the internal...
Definition: setup.h:98
exotica::Setup::maps_
pluginlib::ClassLoader< exotica::TaskMap > maps_
Definition: setup.h:135
exotica::Setup::CreateCollisionScene
static std::shared_ptr< exotica::CollisionScene > CreateCollisionScene(const std::string &type, bool prepend=true)
Definition: setup.h:67
exotica::Setup::CreateCollisionScene
static std::shared_ptr< exotica::CollisionScene > CreateCollisionScene(const Initializer &init)
Definition: setup.h:112
exotica::Setup::GetInitializers
static std::vector< Initializer > GetInitializers()
Definition: setup.cpp:103
exotica::Initializer
Definition: property.h:70
exotica::Setup::Setup
Setup()
Definition: setup.cpp:166
pluginlib::ClassLoader< exotica::MotionSolver >
exotica::Setup::CreateSolver
static std::shared_ptr< exotica::MotionSolver > CreateSolver(const Initializer &init)
Definition: setup.h:76
exotica::Setup::dynamics_solvers_
pluginlib::ClassLoader< exotica::DynamicsSolver > dynamics_solvers_
Definition: setup.h:137
exotica::Setup::Instance
static std::shared_ptr< Setup > Instance()
Definition: setup.h:55
exotica::Setup::CreateMap
static std::shared_ptr< exotica::TaskMap > CreateMap(const std::string &type, bool prepend=true)
Definition: setup.h:65
motion_solver.h
pluginlib::ClassLoader::createInstance
boost::shared_ptr< T > createInstance(const std::string &lookup_name)
exotica::Setup::singleton_initialiser_
static std::shared_ptr< Setup > singleton_initialiser_
Definition: setup.h:122
exotica::Setup::GetCollisionScenes
static std::vector< std::string > GetCollisionScenes()
Definition: setup.cpp:164
exotica::Setup::problems_
PlanningProblemFac problems_
Definition: setup.h:138
exotica::Setup::PrintSupportedClasses
static void PrintSupportedClasses()
Definition: setup.cpp:48
init
void init(const M_string &remappings)
exotica::Setup::CreateSolver
static std::shared_ptr< exotica::MotionSolver > CreateSolver(const std::string &type, bool prepend=true)
Definition: setup.h:64
exotica::Setup::PlanningProblem
friend PlanningProblem
Definition: setup.h:120
dynamics_solver.h
exotica::Setup::GetProblems
static std::vector< std::string > GetProblems()
Definition: setup.cpp:162
object.h
exotica::Setup::GetSolvers
static std::vector< std::string > GetSolvers()
Definition: setup.cpp:161


exotica_core
Author(s): Yiming Yang, Michael Camilleri
autogenerated on Sun Jun 2 2024 02:58:18