WB-Toolbox  6.0.0
ASimulinkToolboxforWholeBodyControl
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
RobotInterface.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_ROBOTINTERFACE_H
10 #define WBT_ROBOTINTERFACE_H
11 
12 #include <memory>
13 #include <string>
14 #include <unordered_map>
15 #include <utility>
16 
17 namespace yarp {
18  namespace dev {
19  class IPositionControl;
20  class IPositionDirect;
21  class IVelocityControl;
22  class ITorqueControl;
23  class IPWMControl;
24  class IControlMode;
25  class ICurrentControl;
26  class IEncoders;
27  class IMotorEncoders;
28  class IControlLimits;
29  class IPidControl;
30  } // namespace dev
31 } // namespace yarp
32 
33 namespace iDynTree {
34  class KinDynComputations;
35 }
36 
37 namespace wbt {
38  namespace base {
39  class RobotInterface;
40  class Configuration;
41 
42  using JointIndex_Yarp = int;
43  using JointIndex_iDynTree = int;
44  using JointName = std::string;
45  } // namespace base
46 } // namespace wbt
47 
58 {
59 private:
60  class impl;
61  std::unique_ptr<impl> pImpl;
62 
63 public:
64  // CONSTRUCTOR / DESTRUCTOR
65  // ========================
66 
67  RobotInterface() = delete;
70 
71  // GET METHODS
72  // ===========
73 
80 
86  const std::shared_ptr<iDynTree::KinDynComputations> getKinDynComputations();
87 
97  template <typename T>
98  bool getInterface(T*& interface);
99 };
100 
101 // Specialize the getInterface template
102 namespace wbt {
103  namespace base {
104  template <>
105  bool RobotInterface::getInterface(yarp::dev::IControlMode*& interface);
106  template <>
107  bool RobotInterface::getInterface(yarp::dev::IPositionControl*& interface);
108  template <>
109  bool RobotInterface::getInterface(yarp::dev::IPositionDirect*& interface);
110  template <>
111  bool RobotInterface::getInterface(yarp::dev::IVelocityControl*& interface);
112  template <>
113  bool RobotInterface::getInterface(yarp::dev::ITorqueControl*& interface);
114  template <>
115  bool RobotInterface::getInterface(yarp::dev::IPWMControl*& interface);
116  template <>
117  bool RobotInterface::getInterface(yarp::dev::ICurrentControl*& interface);
118  template <>
119  bool RobotInterface::getInterface(yarp::dev::IEncoders*& interface);
120  template <>
121  bool RobotInterface::getInterface(yarp::dev::IMotorEncoders*& interface);
122  template <>
123  bool RobotInterface::getInterface(yarp::dev::IControlLimits*& interface);
124  template <>
125  bool RobotInterface::getInterface(yarp::dev::IPidControl*& interface);
126  } // namespace base
127 } // namespace wbt
128 
129 #endif // WBT_ROBOTINTERFACE_H
wbt::base::RobotInterface::getKinDynComputations
const std::shared_ptr< iDynTree::KinDynComputations > getKinDynComputations()
Get the object to operate on the configured model.
Definition: RobotInterface.cpp:237
wbt::base::RobotInterface::~RobotInterface
~RobotInterface()
Definition: RobotInterface.cpp:221
wbt
Definition: Configuration.h:17
wbt::base::JointName
std::string JointName
Definition: RobotInterface.h:44
wbt::base::RobotInterface::getConfiguration
const wbt::base::Configuration & getConfiguration() const
Get the stored configuration.
Definition: RobotInterface.cpp:232
wbt::base::RobotInterface::impl
Definition: RobotInterface.cpp:54
wbt::base::RobotInterface::pImpl
std::unique_ptr< impl > pImpl
Definition: RobotInterface.h:60
iDynTree
Definition: RobotInterface.h:33
yarp
Definition: RobotInterface.h:17
wbt::base::Configuration
Store the configuration for whole-body blocks.
Definition: Configuration.h:36
wbt::base::RobotInterface
Class for handling model and robot resources.
Definition: RobotInterface.h:57
wbt::base::JointIndex_iDynTree
int JointIndex_iDynTree
Definition: RobotInterface.h:43
wbt::base::RobotInterface::RobotInterface
RobotInterface()=delete
wbt::base::JointIndex_Yarp
int JointIndex_Yarp
Definition: RobotInterface.h:42
wbt::base::RobotInterface::getInterface
bool getInterface(T *&interface)
Get a Yarp interface.