Skip to content

Commit

Permalink
Rebased DiscreteFilter block on WB3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
diegoferigo authored and unknown committed Dec 6, 2017
1 parent fafaaf1 commit 580e430
Show file tree
Hide file tree
Showing 5 changed files with 494 additions and 302 deletions.
1 change: 1 addition & 0 deletions toolbox/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ if (WBT_USES_ICUB)
#
# include_directories(SYSTEM ${iKin_INCLUDE_DIRS})
# endif()

configure_block(BLOCK_NAME "Discrete Filter"
GROUP "Utilities"
LIST_PREFIX WBT
Expand Down
43 changes: 30 additions & 13 deletions toolbox/include/DiscreteFilter.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "Block.h"
#include <string>
#include <vector>
#include <memory>

#ifndef WBT_FILTER_H
#define WBT_FILTER_H
Expand All @@ -24,25 +25,41 @@ namespace yarp {
class wbt::DiscreteFilter : public wbt::Block {
private:
unsigned inputSignalWidth;
iCub::ctrl::IFilter* filter;
yarp::sig::Vector* y0;
yarp::sig::Vector* u0;
yarp::sig::Vector* inputSignalVector;
std::unique_ptr<iCub::ctrl::IFilter> filter;
std::unique_ptr<yarp::sig::Vector> y0;
std::unique_ptr<yarp::sig::Vector> u0;
std::unique_ptr<yarp::sig::Vector> inputSignalVector;

static void stringToYarpVector(const std::string s, yarp::sig::Vector& v);

// Parameters
static const unsigned PARAM_IDX_FLT_TYPE;
static const unsigned PARAM_IDX_NUMCOEFF;
static const unsigned PARAM_IDX_DENCOEFF;
static const unsigned PARAM_IDX_1LOWP_FC;
static const unsigned PARAM_IDX_1LOWP_TS;
static const unsigned PARAM_IDX_MD_ORDER;
static const unsigned PARAM_IDX_INIT_Y0;
static const unsigned PARAM_IDX_INIT_U0;
// Inputs
static const unsigned INPUT_IDX_SIGNAL;
// Outputs
static const unsigned OUTPUT_IDX_SIGNAL;
// Other defines
static const int SIGNAL_DYNAMIC_SIZE;

public:
static std::string ClassName;
static const std::string ClassName;

DiscreteFilter();
~DiscreteFilter() = default;

virtual unsigned numberOfParameters();
virtual bool configureSizeAndPorts(BlockInformation* blockInfo, wbt::Error* error);
virtual bool initialize(BlockInformation* blockInfo, wbt::Error* error);
virtual bool initializeInitialConditions(BlockInformation *blockInfo, wbt::Error *error);
virtual bool terminate(BlockInformation* blockInfo, wbt::Error* error);
virtual bool output(BlockInformation* blockInfo, wbt::Error* error);
~DiscreteFilter() override = default;

unsigned numberOfParameters() override;
bool configureSizeAndPorts(BlockInformation* blockInfo) override;
bool initialize(const BlockInformation* blockInfo) override;
bool initializeInitialConditions(const BlockInformation* blockInfo) override;
bool terminate(const BlockInformation* blockInfo) override;
bool output(const BlockInformation* blockInfo) override;
};

#endif // WBT_FILTER_H
Loading

0 comments on commit 580e430

Please sign in to comment.