Unknown type name 'class'

Hey Im running into this issue that says unknown type name 'EMA'
I’m trying to create a new EMA for each PID I make, here’s the code.



There error says its occuring in PID.hpp on the same line as EMA ema;

It’s also underlining #include “main.h” as an error. Could there be something wrong in that file?

What does it say when you hover over "main.h"?

na thats an extension theres no problem with that

unknown type name 'EMA'

Could you share what is on line 13 in PID.hpp?


Try removing #include "main.h" from PID.hpp.

PID.hpp doesnt use anything that comes from main, I just had it there to check if it did for some reason. So it didnt change anything

Try adding class EMA; right above class PID {.

class EMA is declared in EMA.hpp already, it cant be declared twice.

It seems like it’s not including properly. I’m not sure how to fix this issue.

Ok thanks for trying to help lol

Adding class EMA; doesn’t redeclare EMA, it only lets the compiler know that EMA will exist later in the code and tells the compiler not to throw any errors in regards to EMA

Probably easier if you paste your code rather than take screen-grabs. Offhand, it looks like there is no space between #include and "7157X/motionAlgs/EMA.hpp" try adding a space there.


Yeah your right, i actually didnt catch there wasnt a space but it didnt seem to change anything still…
Heres all of the code.

// PID.hpp
#pragma once
#include "7157X/motionAlgs/EMA.hpp"

class PID {

    private :
    double kP, kI, kD, alpha, time, prevTime;
    double error, derivative, integral, preverror, result, maxI, minDist;
    EMA ema;

    public :

    PID ( double p, double i, double d, double a );
    PID ( double p, double i, double d );
    PID ( double p );
    PID ();

    // End Constructors

    void setGains( double p, double i, double d );
    void setAGain( double a );
    void setwindUp( double windUp, double dist );

    // End Set Gains

    void initalize();
    double update( double target );


// EMA.hpp

#pragma once

  class EMA  {

    private :

      double alpha;
      double output = 0;
      double prevOutput = 0;
      bool run = false;

    public :

    EMA(double a);

  // End Constructors

    void setGain(double a);
    double start(double input);
    void reset();
    double getOutput();


I actually just figure out the issue, I had the extra #include “main.h” in my header file which really wasnt necessary thanks for all the help

1 Like