mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-28 03:33:33 +08:00
add more accessors for 2nd order lp block and derivative block
This commit is contained in:
@@ -200,10 +200,15 @@ int blockHighPassTest()
|
|||||||
|
|
||||||
float BlockLowPass2::update(float input)
|
float BlockLowPass2::update(float input)
|
||||||
{
|
{
|
||||||
|
if (!isfinite(getState())) {
|
||||||
|
setState(input);
|
||||||
|
}
|
||||||
|
|
||||||
if (_lp.get_cutoff_freq() != getFCutParam()) {
|
if (_lp.get_cutoff_freq() != getFCutParam()) {
|
||||||
_lp.set_cutoff_frequency(_fs, getFCutParam());
|
_lp.set_cutoff_frequency(_fs, getFCutParam());
|
||||||
}
|
}
|
||||||
return _lp.apply(input);
|
_state = _lp.apply(input);
|
||||||
|
return _state;
|
||||||
}
|
}
|
||||||
|
|
||||||
float BlockIntegral::update(float input)
|
float BlockIntegral::update(float input)
|
||||||
|
|||||||
@@ -173,6 +173,7 @@ public:
|
|||||||
// methods
|
// methods
|
||||||
BlockLowPass2(SuperBlock *parent, const char *name, float sample_freq) :
|
BlockLowPass2(SuperBlock *parent, const char *name, float sample_freq) :
|
||||||
Block(parent, name),
|
Block(parent, name),
|
||||||
|
_state(0.0 / 0.0 /* initialize to invalid val, force into is_finite() check on first call */),
|
||||||
_fCut(this, ""), // only one parameter, no need to name
|
_fCut(this, ""), // only one parameter, no need to name
|
||||||
_fs(sample_freq),
|
_fs(sample_freq),
|
||||||
_lp(_fs, _fCut.get())
|
_lp(_fs, _fCut.get())
|
||||||
@@ -180,10 +181,12 @@ public:
|
|||||||
virtual ~BlockLowPass2() {};
|
virtual ~BlockLowPass2() {};
|
||||||
float update(float input);
|
float update(float input);
|
||||||
// accessors
|
// accessors
|
||||||
|
float getState() { return _state; }
|
||||||
float getFCutParam() { return _fCut.get(); }
|
float getFCutParam() { return _fCut.get(); }
|
||||||
void setState(float state) { _lp.reset(state); }
|
void setState(float state) { _state = _lp.reset(state); }
|
||||||
protected:
|
protected:
|
||||||
// attributes
|
// attributes
|
||||||
|
float _state;
|
||||||
control::BlockParamFloat _fCut;
|
control::BlockParamFloat _fCut;
|
||||||
float _fs;
|
float _fs;
|
||||||
math::LowPassFilter2p _lp;
|
math::LowPassFilter2p _lp;
|
||||||
@@ -291,6 +294,7 @@ public:
|
|||||||
void setU(float u) {_u = u;}
|
void setU(float u) {_u = u;}
|
||||||
float getU() {return _u;}
|
float getU() {return _u;}
|
||||||
float getLP() {return _lowPass.getFCut();}
|
float getLP() {return _lowPass.getFCut();}
|
||||||
|
float getO() { return _lowPass.getState(); }
|
||||||
protected:
|
protected:
|
||||||
// attributes
|
// attributes
|
||||||
float _u; /**< previous input */
|
float _u; /**< previous input */
|
||||||
|
|||||||
Reference in New Issue
Block a user