WB-Toolbox  6.0.1
A Simulink Toolbox for Whole Body Control
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
WBBlock.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_WBBLOCK_H
10 #define WBT_WBBLOCK_H
11 
12 #include <BlockFactory/Core/Block.h>
13 #include <memory>
14 #include <string>
15 
16 namespace blockfactory {
17  namespace core {
18  class BlockInformation;
19  class Signal;
20  } // namespace core
21 } // namespace blockfactory
22 
23 namespace wbt {
24  namespace base {
25  class WBBlock;
26  class RobotInterface;
27  using InputSignalPtr = std::shared_ptr<const blockfactory::core::Signal>;
28  } // namespace base
29 } // namespace wbt
30 
31 namespace iDynTree {
32  class KinDynComputations;
33 } // namespace iDynTree
34 
62 class wbt::base::WBBlock : public blockfactory::core::Block
63 {
64 protected:
65  // TODO: pImpl
66  struct iDynTreeRobotState;
67  std::unique_ptr<iDynTreeRobotState> m_robotState;
68  std::string m_confBlockName;
69  std::shared_ptr<wbt::base::RobotInterface> m_robotInterface;
70 
75  std::shared_ptr<iDynTree::KinDynComputations> getKinDynComputations() const;
76 
81  const std::shared_ptr<wbt::base::RobotInterface> getRobotInterface() const;
82 
96  wbt::base::InputSignalPtr jointsPos,
97  wbt::base::InputSignalPtr baseVelocity,
98  wbt::base::InputSignalPtr jointsVelocity,
99  iDynTree::KinDynComputations* kinDyn);
100 
101 public:
103  static constexpr unsigned NumberOfParameters = Block::NumberOfParameters + 2;
104 
105  WBBlock();
106  ~WBBlock() override;
107  unsigned numberOfParameters() override;
108  bool parseParameters(blockfactory::core::BlockInformation* blockInfo) override;
109  bool configureSizeAndPorts(blockfactory::core::BlockInformation* blockInfo) override;
110  bool initialize(blockfactory::core::BlockInformation* blockInfo) override;
111 };
112 
113 #endif // WBT_WBBLOCK_H
@ Signal
Definition: YarpRead.cpp:49
Extension of blockfactory::core::Block for simplifying the development of whole-body blocks.
Definition: WBBlock.h:63
bool setRobotState(wbt::base::InputSignalPtr basePose, wbt::base::InputSignalPtr jointsPos, wbt::base::InputSignalPtr baseVelocity, wbt::base::InputSignalPtr jointsVelocity, iDynTree::KinDynComputations *kinDyn)
Helper for setting the robot state inside the iDynTree::KinDynComputations object.
Definition: WBBlock.cpp:74
bool parseParameters(blockfactory::core::BlockInformation *blockInfo) override
Definition: WBBlock.cpp:185
~WBBlock() override
unsigned numberOfParameters() override
Definition: WBBlock.cpp:180
std::unique_ptr< iDynTreeRobotState > m_robotState
Definition: WBBlock.h:66
std::shared_ptr< iDynTree::KinDynComputations > getKinDynComputations() const
Helper for retrieving the iDynTree::KinDynComputations object.
Definition: WBBlock.cpp:64
bool initialize(blockfactory::core::BlockInformation *blockInfo) override
Definition: WBBlock.cpp:243
static constexpr unsigned NumberOfParameters
The number of parameters WBBlock requires.
Definition: WBBlock.h:103
std::string m_confBlockName
Definition: WBBlock.h:68
const std::shared_ptr< wbt::base::RobotInterface > getRobotInterface() const
Helper for retrieving the wbt::RobotInterface object.
Definition: WBBlock.cpp:69
WBBlock()
Definition: WBBlock.cpp:174
bool configureSizeAndPorts(blockfactory::core::BlockInformation *blockInfo) override
Definition: WBBlock.cpp:208
std::shared_ptr< wbt::base::RobotInterface > m_robotInterface
Definition: WBBlock.h:69
Definition: WBBlock.h:16
Definition: RobotInterface.h:33
std::shared_ptr< const blockfactory::core::Signal > InputSignalPtr
Definition: WBBlock.h:27
Definition: Configuration.h:17
Container for data structures used for using iDynTree::KinDynComputations::setRobotState
Definition: WBBlock.cpp:45