OCCRA
Go to Post We're all such geeks...not that's that a bad thing. - IMDWalrus [more]
Home
Go Back   Chief Delphi > Technical > Programming > C/C++
CD-Media  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 03-28-2018, 01:07 PM
nollchr's Avatar
nollchr nollchr is offline
Registered User
AKA: Chris Noll
FRC #2170 (Titanium Tomahawks)
Team Role: Mentor
 
Join Date: Feb 2014
Rookie Year: 2014
Location: Glastonbury, CT
Posts: 36
nollchr is an unknown quantity at this point
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.

Thanks

Chris.
__________________
Christopher Noll
FRC 2170 Mentor
Reply With Quote
  #2   Spotlight this post!  
Unread 03-28-2018, 08:20 PM
calcmogul's Avatar
calcmogul calcmogul is offline
WPILib Developer
AKA: Tyler Veness
FRC #3512 (Spartatroniks)
Team Role: Mentor
 
Join Date: Nov 2011
Rookie Year: 2012
Location: Hawthorne, CA
Posts: 109
calcmogul has much to be proud ofcalcmogul has much to be proud ofcalcmogul has much to be proud ofcalcmogul has much to be proud ofcalcmogul has much to be proud ofcalcmogul has much to be proud ofcalcmogul has much to be proud ofcalcmogul has much to be proud ofcalcmogul has much to be proud ofcalcmogul has much to be proud of
Re: LinearDigitalFilter factory function help

Use the factory methods like so:
Code:
#include <Encoder.h>
#include <Filters/LinearDigitalFilter.h>
#include <TimedRobot.h>

class Robot : public frc::TimedRobot {
 public:
  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.
Reply With Quote
  #3   Spotlight this post!  
Unread 03-29-2018, 09:05 AM
nollchr's Avatar
nollchr nollchr is offline
Registered User
AKA: Chris Noll
FRC #2170 (Titanium Tomahawks)
Team Role: Mentor
 
Join Date: Feb 2014
Rookie Year: 2014
Location: Glastonbury, CT
Posts: 36
nollchr is an unknown quantity at this point
Re: LinearDigitalFilter factory function help

Quote:
Originally Posted by calcmogul View Post
Use the factory methods like so:
Code:
#include <Encoder.h>
#include <Filters/LinearDigitalFilter.h>
#include <TimedRobot.h>

class Robot : public frc::TimedRobot {
 public:
  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
__________________
Christopher Noll
FRC 2170 Mentor
Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 03:59 PM.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin®
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi