class mrpt::bayes::CParticleFilter
Python API: mrpt.bayes.CParticleFilter
Overview
This class acts as a common interface to the different interfaces (see CParticleFilter::TParticleFilterAlgorithm) any bayes::CParticleFilterCapable class can implement: it is the invoker of particle filter algorithms.
The particle filter is executed on a probability density function (PDF) described by a CParticleFilterCapable object, passed in the constructor or alternatively through the CParticleFilter::executeOn method.
For a complete example and further details, see the Particle Filter tutorial.
The basic SIR algorithm (pfStandardProposal) consists of:
Execute a prediction with the given “action”.
Update the weights of the particles using the likelihood of the “observation”.
Normalize weights.
Perform resampling if the ESS is below the threshold options.BETA.
See also:
mrpt::poses::CPoseParticlesPDF
#include <mrpt/bayes/CParticleFilter.h> class CParticleFilter: public mrpt::system::COutputLogger { public: // enums enum TParticleFilterAlgorithm; enum TParticleResamplingAlgorithm; // structs struct TParticleFilterOptions; struct TParticleFilterStats; // fields static constexpr TParticleFilterAlgorithm pfStandardProposal = TParticleFilterAlgorithm::StandardProposal; static constexpr TParticleFilterAlgorithm pfAuxiliaryPFStandard = TParticleFilterAlgorithm::AuxiliaryPFStandard; static constexpr TParticleFilterAlgorithm pfOptimalProposal = TParticleFilterAlgorithm::OptimalProposal; static constexpr TParticleFilterAlgorithm pfAuxiliaryPFOptimal = TParticleFilterAlgorithm::AuxiliaryPFOptimal; static constexpr TParticleResamplingAlgorithm prMultinomial = TParticleResamplingAlgorithm::Multinomial; static constexpr TParticleResamplingAlgorithm prResidual = TParticleResamplingAlgorithm::Residual; static constexpr TParticleResamplingAlgorithm prStratified = TParticleResamplingAlgorithm::Stratified; static constexpr TParticleResamplingAlgorithm prSystematic = TParticleResamplingAlgorithm::Systematic; CParticleFilter::TParticleFilterOptions m_options; // construction CParticleFilter(); // methods void executeOn(CParticleFilterCapable& obj, const mrpt::obs::CActionCollection* action, const mrpt::obs::CSensoryFrame* observation, TParticleFilterStats* stats = nullptr) const; };
Inherited Members
public: // structs struct TMsg; // fields bool logging_enable_console_output {true}; bool logging_enable_keep_record {false}; // methods void logStr(const VerbosityLevel level, std::string_view msg_str) const; void logFmt(const VerbosityLevel level, const char* fmt, ...) const; void void logCond(const VerbosityLevel level, bool cond, const std::string& msg_str) const; void setLoggerName(const std::string& name); std::string getLoggerName() const; void setVerbosityLevel(const VerbosityLevel level); void setVerbosityLevelForCallbacks(const VerbosityLevel level); void setMinLoggingLevel(const VerbosityLevel level); VerbosityLevel getMinLoggingLevel() const; VerbosityLevel getMinLoggingLevelForCallbacks() const; bool isLoggingLevelVisible(VerbosityLevel level) const; void getLogAsString(std::string& log_contents) const; std::string getLogAsString() const; void writeLogToFile(const std::optional<std::string>& fname_in = std::nullopt) const; void dumpLogToConsole() const; std::string getLoggerLastMsg() const; void getLoggerLastMsg(std::string& msg_str) const; void loggerReset(); void logRegisterCallback(output_logger_callback_t userFunc); bool logDeregisterCallback(output_logger_callback_t userFunc); COutputLogger& operator = (const COutputLogger&); COutputLogger& operator = (COutputLogger&&); static std::array<mrpt::system::ConsoleForegroundColor, NUMBER_OF_VERBOSITY_LEVELS>& logging_levels_to_colors(); static const std::array<const char*, NUMBER_OF_VERBOSITY_LEVELS>& logging_levels_to_names();
Fields
CParticleFilter::TParticleFilterOptions m_options
The options to be used in the PF, must be set before executing any step of the particle filter.
Construction
CParticleFilter()
Default constructor.
After creating the PF object, set the options in CParticleFilter::m_options, then execute steps through CParticleFilter::executeOn.
Methods
void executeOn(CParticleFilterCapable& obj, const mrpt::obs::CActionCollection* action, const mrpt::obs::CSensoryFrame* observation, TParticleFilterStats* stats = nullptr) const
Executes a complete prediction + update step of the selected particle filtering algorithm.
The member CParticleFilter::m_options must be set before calling this to settle the algorithm parameters.
Parameters:
obj |
The object representing the probability distribution function (PDF) which apply the particle filter algorithm to. |
action |
A pointer to an action in the form of a CActionCollection, or nullptr if there is no action. |
observation |
A pointer to observations in the form of a CSensoryFrame, or nullptr if there is no observation. |
stats |
An output structure for gathering statistics of the particle filter execution, or set to nullptr if you do not need it (see CParticleFilter::TParticleFilterStats). |
See also: