WB-Toolbox  6.0.1
A Simulink Toolbox for Whole Body Control
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
WholeBodySingleton.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2018 Istituto Italiano di Tecnologia (IIT)
3  * All rights reserved.
4  *
5  * This software may be modified and distributed under the terms of the
6  * GNU Lesser General Public License v2.1 or any later version.
7  */
8 
9 #ifndef WBT_WHOLEBODYSINGLETON_H
10 #define WBT_WHOLEBODYSINGLETON_H
11 
12 #include <memory>
13 #include <string>
14 #include <unordered_map>
15 
16 namespace wbt {
17  namespace base {
18  class WholeBodySingleton;
19  class RobotInterface;
20  class Configuration;
21  } // namespace base
22 } // namespace wbt
23 
24 namespace blockfactory {
25  namespace core {
26  class Parameters;
27  } // namespace core
28 } // namespace blockfactory
29 
30 namespace iDynTree {
31  class KinDynComputations;
32 }
33 
45 {
46 private:
50  std::unordered_map<std::string, std::weak_ptr<wbt::base::RobotInterface>> m_interfaces;
51 
52 public:
53  // CONSTRUCTOR / DESTRUCTOR
54  // ========================
55 
58 
61 
62  // UTILITIES
63  // =========
64 
72  bool isKeyValid(const std::string& confKey) const;
73 
80  int numberOfDoFs(const std::string& confKey) const;
81 
82  // GET METHODS
83  // ===========
84 
95 
104  const Configuration& getConfiguration(const std::string& confKey) const;
105 
113  const std::shared_ptr<RobotInterface> getRobotInterface(const std::string& confKey) const;
114 
123  const std::shared_ptr<iDynTree::KinDynComputations>
124  getKinDynComputations(const std::string& confKey) const;
125 
126  // WHOLEBODYSINGLETON CONFIGURATION
127  // ================================
128 
144  std::shared_ptr<RobotInterface> createRobotInterface(const Configuration& config);
145 
155  std::shared_ptr<RobotInterface>
156  storeConfiguration(const blockfactory::core::Parameters& parameters);
157 
163  void eraseConfiguration(const std::string& confKey);
164 };
165 
166 #endif // WBT_WHOLEBODYSINGLETON_H
Store the configuration for whole-body blocks.
Definition: Configuration.h:37
Definition: WholeBodySingleton.h:45
void eraseConfiguration(const std::string &confKey)
Definition: WholeBodySingleton.cpp:215
const std::shared_ptr< RobotInterface > getRobotInterface(const std::string &confKey) const
Definition: WholeBodySingleton.cpp:77
WholeBodySingleton(const WholeBodySingleton &)=delete
bool isKeyValid(const std::string &confKey) const
Definition: WholeBodySingleton.cpp:46
static wbt::base::WholeBodySingleton & sharedInstance()
Definition: WholeBodySingleton.cpp:65
const std::shared_ptr< iDynTree::KinDynComputations > getKinDynComputations(const std::string &confKey) const
Definition: WholeBodySingleton.cpp:87
WholeBodySingleton & operator=(const WholeBodySingleton &)=delete
std::shared_ptr< RobotInterface > storeConfiguration(const blockfactory::core::Parameters &parameters)
Definition: WholeBodySingleton.cpp:187
std::unordered_map< std::string, std::weak_ptr< wbt::base::RobotInterface > > m_interfaces
Definition: WholeBodySingleton.h:50
const Configuration & getConfiguration(const std::string &confKey) const
Definition: WholeBodySingleton.cpp:71
int numberOfDoFs(const std::string &confKey) const
Definition: WholeBodySingleton.cpp:37
std::shared_ptr< RobotInterface > createRobotInterface(const Configuration &config)
Definition: WholeBodySingleton.cpp:100
Definition: WBBlock.h:16
Definition: RobotInterface.h:33
Definition: Configuration.h:17