PX4 Firmware
PX4 Autopilot Software http://px4.io
control::BlockDerivative Class Reference

A simple derivative approximation. More...

#include <BlockDerivative.hpp>

Inheritance diagram for control::BlockDerivative:
Collaboration diagram for control::BlockDerivative:

Public Member Functions

 BlockDerivative (SuperBlock *parent, const char *name)
 
virtual ~BlockDerivative ()=default
 
float update (float input)
 Update the state and get current derivative. More...
 
void setU (float u)
 
void reset ()
 
float getU ()
 
float getLP ()
 
float getO ()
 
- Public Member Functions inherited from control::SuperBlock
 SuperBlock (SuperBlock *parent, const char *name)
 
 ~SuperBlock ()=default
 
 SuperBlock (const SuperBlock &)=delete
 
SuperBlockoperator= (const SuperBlock &)=delete
 
 SuperBlock (SuperBlock &&)=delete
 
SuperBlockoperator= (SuperBlock &&)=delete
 
void setDt (float dt) override
 
void updateParams () override
 
- Public Member Functions inherited from control::Block
 Block (SuperBlock *parent, const char *name)
 
virtual ~Block ()=default
 
 Block (const Block &)=delete
 
Blockoperator= (const Block &)=delete
 
 Block (Block &&)=delete
 
Blockoperator= (Block &&)=delete
 
void getName (char *name, size_t n)
 
float getDt ()
 
- Public Member Functions inherited from ListNode< Block *>
void setSibling (Block * sibling)
 
const Block * getSibling () const
 

Protected Attributes

float _u
 previous input More...
 
bool _initialized
 
BlockLowPass _lowPass
 low pass filter More...
 
- Protected Attributes inherited from control::SuperBlock
List< Block * > _children
 
- Protected Attributes inherited from control::Block
const char * _name
 
SuperBlock_parent
 
float _dt {0.0f}
 
List< BlockParamBase * > _params
 
- Protected Attributes inherited from ListNode< Block *>
Block * _list_node_sibling
 

Additional Inherited Members

- Protected Member Functions inherited from control::SuperBlock
List< Block * > & getChildren ()
 
void updateChildParams ()
 
- Protected Member Functions inherited from control::Block
virtual void updateParamsSubclass ()
 
SuperBlockgetParent ()
 
List< BlockParamBase * > & getParams ()
 

Detailed Description

A simple derivative approximation.

This uses the previous and current input. This has a built in low pass filter.

See also
LowPass

Definition at line 61 of file BlockDerivative.hpp.

Constructor & Destructor Documentation

◆ BlockDerivative()

control::BlockDerivative::BlockDerivative ( SuperBlock parent,
const char *  name 
)
inline

Definition at line 65 of file BlockDerivative.hpp.

◆ ~BlockDerivative()

virtual control::BlockDerivative::~BlockDerivative ( )
virtualdefault

Member Function Documentation

◆ getLP()

float control::BlockDerivative::getLP ( )
inline

Definition at line 92 of file BlockDerivative.hpp.

Referenced by control::blockDerivativeTest(), blockDerivativeTest(), blockPDTest(), control::blockPDTest(), control::blockPIDTest(), and blockPIDTest().

Here is the caller graph for this function:

◆ getO()

float control::BlockDerivative::getO ( )
inline

Definition at line 93 of file BlockDerivative.hpp.

◆ getU()

float control::BlockDerivative::getU ( )
inline

Definition at line 91 of file BlockDerivative.hpp.

Referenced by control::blockDerivativeTest(), blockDerivativeTest(), blockPDTest(), control::blockPDTest(), blockPIDTest(), control::blockPIDTest(), and update().

Here is the caller graph for this function:

◆ reset()

void control::BlockDerivative::reset ( void  )
inline

Definition at line 90 of file BlockDerivative.hpp.

Referenced by MulticopterPositionControl::Run().

Here is the caller graph for this function:

◆ setU()

void control::BlockDerivative::setU ( float  u)
inline

Definition at line 89 of file BlockDerivative.hpp.

Referenced by control::blockDerivativeTest(), blockDerivativeTest(), blockPDTest(), control::blockPDTest(), blockPIDTest(), control::blockPIDTest(), and update().

Here is the caller graph for this function:

◆ update()

float control::BlockDerivative::update ( float  input)

Update the state and get current derivative.

This call updates the state and gets the current derivative. As the derivative is only valid on the second call to update, it will return no change (0) on the first. To get a closer estimate of the derivative on the first call, call setU() one time step before using the return value of update().

Parameters
inputthe variable to calculate the derivative of
Returns
the current derivative

Definition at line 48 of file BlockDerivative.cpp.

References _initialized, _lowPass, f(), control::Block::getDt(), getU(), setU(), and control::BlockLowPass::update().

Referenced by control::blockDerivativeTest(), blockDerivativeTest(), control::blockPDTest(), blockPDTest(), blockPIDTest(), control::blockPIDTest(), and MulticopterPositionControl::set_vehicle_states().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ _initialized

bool control::BlockDerivative::_initialized
protected

Definition at line 97 of file BlockDerivative.hpp.

Referenced by update().

◆ _lowPass

BlockLowPass control::BlockDerivative::_lowPass
protected

low pass filter

Definition at line 98 of file BlockDerivative.hpp.

Referenced by update().

◆ _u

float control::BlockDerivative::_u
protected

previous input

Definition at line 96 of file BlockDerivative.hpp.


The documentation for this class was generated from the following files: