LinearDigitalFilter factory function help

Does anyone have a C++ example using the static factory functions in LinearDigitalFilter (i.e. MovingAverage)?

I expected the factory functions to return a pointer new LinearDigitalFilterObject but it returns an object directly.



Use the factory methods like so:

#include <Encoder.h>
#include <Filters/LinearDigitalFilter.h>
#include <TimedRobot.h>

class Robot : public frc::TimedRobot {
  Encoder encoder{1, 2};
  LinearDigitalFilter filter = LinearDigitalFilter::MovingAverage(encoder, 5);

and pass the filter to a PIDController or something. Since PIDController has reference overloads, it’ll just work.

Thanks…i was trying to get it to work using pointers to objects like the rest of the robot builder framework does