I just tried to implement what you guys have been giving me into my code and when I try to compile I get the following error:
C:/WindRiver/Team2992_2011_Code_1/IterativeDemo.cpp:150: error: PIDSource' is an inaccessible base of
PIDEncoder’
and it highlights in red the line from my code below “elevatorControl = new PIDController(0.1, 0.01, 0.001, elevatorEncoder, elevatorMotor);”
I did tweak jwakeman’s PIDEncoder.h and ".cpp to below because I prefer to do without the slot designation for the cRio.
PIDEncoder.h
#include "Encoder.h"
#include "PIDSource.h"
class PIDEncoder : public Encoder, PIDSource
{
public:
//constructor
PIDEncoder(UINT32 aChannel,UINT32 bChannel,
bool reverseDirection, EncodingType encodingType);
PIDEncoder(UINT32 aSlot, UINT32 aChannel,
UINT32 bSlot, UINT32 bChannel,
bool reverseDirection, EncodingType encodingType);
//destructor
~PIDEncoder();
//virtual from PIDSource
double PIDGet();
private:
};
PIDEncoder.cpp
#include "PIDEncoder.h"
//constructor
PIDEncoder::PIDEncoder(UINT32 aChannel, UINT32 bChannel,
bool reverseDirection, EncodingType encodingType) :
Encoder(aChannel,bChannel,reverseDirection,encodingType)
{
}
PIDEncoder::PIDEncoder(UINT32 aSlot, UINT32 aChannel,
UINT32 bSlot, UINT32 bChannel,
bool reverseDirection, EncodingType encodingType) : Encoder(aSlot,aChannel,bSlot,bChannel,reverseDirection,encodingType)
{
}
//destructor
PIDEncoder::~PIDEncoder()
{
}
//virtual from PIDSource
double PIDEncoder::PIDGet()
{
return this->GetDistance();
}
And here is what I put in my IterativeRobot code:
Under Iterative Robot Class:
PIDEncoder *elevatorEncoder;
PIDController *elevatorControl;
Victor *elevatorMotor;
Inside Constructor:
elevatorEncoder = new PIDEncoder(11,12,true,Encoder::k4X);
elevatorEncoder->SetDistancePerPulse(0.04318); //inches //UPDATE!!
elevatorEncoder->Start();
elevatorMotor = new Victor(5);
elevatorControl = new PIDController(0.1, 0.01, 0.001, elevatorEncoder, elevatorMotor);
Did I do a boneheaded thing when tweaking jwakeman’s code, or did I not understand how to call the stuff correctly in my IterativeRobot code? Can you guys help me debug this issue?