View Single Post
  #12   Spotlight this post!  
Unread 25-01-2011, 10:22
sircedric4's Avatar
sircedric4 sircedric4 is offline
Registered User
AKA: Darren
no team (The SS Prometheus)
Team Role: Mentor
 
Join Date: Jan 2008
Rookie Year: 2006
Location: Lousiana
Posts: 245
sircedric4 has a reputation beyond reputesircedric4 has a reputation beyond reputesircedric4 has a reputation beyond reputesircedric4 has a reputation beyond reputesircedric4 has a reputation beyond reputesircedric4 has a reputation beyond reputesircedric4 has a reputation beyond reputesircedric4 has a reputation beyond reputesircedric4 has a reputation beyond reputesircedric4 has a reputation beyond reputesircedric4 has a reputation beyond repute
Angry Re: Encoder as PIDSource

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
Code:
#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
Code:
#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:

Code:
PIDEncoder *elevatorEncoder;
PIDController *elevatorControl;
Victor *elevatorMotor;
Inside Constructor:

Code:
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?
Reply With Quote