WB-Toolbox  5.6.1
ASimulinkToolboxforWholeBodyControl
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
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
wbt
Definition: Configuration.h:17
wbt::base::WBBlock::m_robotInterface
std::shared_ptr< wbt::base::RobotInterface > m_robotInterface
Definition: WBBlock.h:69
wbt::base::WBBlock::numberOfParameters
unsigned numberOfParameters() override
Definition: WBBlock.cpp:180
wbt::base::WBBlock::getKinDynComputations
std::shared_ptr< iDynTree::KinDynComputations > getKinDynComputations() const
Helper for retrieving the iDynTree::KinDynComputations object.
Definition: WBBlock.cpp:64
wbt::base::WBBlock::m_robotState
std::unique_ptr< iDynTreeRobotState > m_robotState
Definition: WBBlock.h:66
Signal
@ Signal
Definition: YarpRead.cpp:49
wbt::base::WBBlock::NumberOfParameters
static constexpr unsigned NumberOfParameters
The number of parameters WBBlock requires.
Definition: WBBlock.h:103
wbt::base::WBBlock::~WBBlock
~WBBlock() override
wbt::base::WBBlock::m_confBlockName
std::string m_confBlockName
Definition: WBBlock.h:68
wbt::base::WBBlock::WBBlock
WBBlock()
Definition: WBBlock.cpp:174
iDynTree
Definition: RobotInterface.h:33
blockfactory
Definition: WBBlock.h:16
wbt::base::WBBlock::setRobotState
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
wbt::base::WBBlock::getRobotInterface
const std::shared_ptr< wbt::base::RobotInterface > getRobotInterface() const
Helper for retrieving the wbt::RobotInterface object.
Definition: WBBlock.cpp:69
wbt::base::WBBlock::initialize
bool initialize(blockfactory::core::BlockInformation *blockInfo) override
Definition: WBBlock.cpp:243
wbt::base::WBBlock::parseParameters
bool parseParameters(blockfactory::core::BlockInformation *blockInfo) override
Definition: WBBlock.cpp:185
wbt::base::WBBlock::configureSizeAndPorts
bool configureSizeAndPorts(blockfactory::core::BlockInformation *blockInfo) override
Definition: WBBlock.cpp:208
wbt::base::WBBlock::iDynTreeRobotState
Container for data structures used for using iDynTree::KinDynComputations::setRobotState
Definition: WBBlock.cpp:44
wbt::base::InputSignalPtr
std::shared_ptr< const blockfactory::core::Signal > InputSignalPtr
Definition: WBBlock.h:27
wbt::base::WBBlock
Extension of blockfactory::core::Block for simplifying the development of whole-body blocks.
Definition: WBBlock.h:62