Go to Post Don't let them fail at the end. - DonRotolo [more]
Home
Go Back   Chief Delphi > Technical > Programming > C/C++
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
Thread Tools Rating: Thread Rating: 6 votes, 5.00 average. Display Modes
  #1   Spotlight this post!  
Unread 05-02-2015, 19:54
thatprogrammer's Avatar
thatprogrammer thatprogrammer is offline
Registered User
AKA: Ahad Bawany
no team (None)
Team Role: Programmer
 
Join Date: Apr 2014
Rookie Year: 2014
Location: Florida
Posts: 610
thatprogrammer has a reputation beyond reputethatprogrammer has a reputation beyond reputethatprogrammer has a reputation beyond reputethatprogrammer has a reputation beyond reputethatprogrammer has a reputation beyond reputethatprogrammer has a reputation beyond reputethatprogrammer has a reputation beyond reputethatprogrammer has a reputation beyond reputethatprogrammer has a reputation beyond reputethatprogrammer has a reputation beyond reputethatprogrammer has a reputation beyond repute
Need help with testing PID for an elevator

We run this code:
Code:
{
private:
	//Initializing livewindow
	LiveWindow *lw;
	//Initializing stick
	Joystick *stick;
	//Initializing the Chassis parts
	Talon *kFrontLeftMotor;
	Talon *kFrontRightMotor;
	Talon *Elevator;
	RobotDrive *robot;
	Relay *Fan;
	DoubleSolenoid *shifter;
	Encoder *ChassisEnc;
	Encoder *OtherEnc;
	Encoder *ElevatorEnc;
	//Initializing the values for Cheesy Drive
	float Rotation;
	float Acceleration;
	float rightMultiplier;
	float leftMultiplier;
    double automode;
    Gyro *gyro;
    bool robottime;
    double Angle;
    DoubleSolenoid *ElevSol;
    bool robotdrive;
   double Kp = 0.03;
   DigitalInput *Limit;
   PIDController *ElevatorPID;
	void RobotInit()
	{

		SmartDashboard::init();
		lw = LiveWindow::GetInstance();
		stick = new Joystick(0);
		kFrontLeftMotor = new Talon(0);
		kFrontRightMotor = new Talon(1);
		Elevator = new Talon (2);
		robot = new RobotDrive(kFrontRightMotor, kFrontLeftMotor);
		Fan = new Relay (3);


		/* Setting the shifter as a DoubleSolenoid
		 * Because we're using both pistons off of
		 * one Double Solenoid
		 */
		shifter = new DoubleSolenoid (0,1);

		ChassisEnc = new Encoder (0,1, false, Encoder::EncodingType::k4X);
		OtherEnc= new Encoder (8,9, false, Encoder::EncodingType::k4X);

		//Setting it so the fan is off by default
		Fan->Set(Relay::kOff);


		//Setting the Rotation and Accel values
		Rotation = stick->GetRawAxis(1);
		Acceleration = stick->GetRawAxis(3);

	    /*Setting the multipliers
	     * so that they don't allow
	     * a robot to go full forward
	     * while going full turn
	     */

		rightMultiplier = Rotation + Acceleration;
		leftMultiplier = Rotation - Acceleration;

		//Setting the shifter to Low Gear
		shifter->Set(DoubleSolenoid::kReverse);
		robot->SetInvertedMotor(RobotDrive::kFrontLeftMotor, true);
		robot->SetInvertedMotor(RobotDrive::kFrontRightMotor, true);

		ChassisEnc->SetDistancePerPulse(.084);
		OtherEnc->SetDistancePerPulse(.084);
        ElevatorEnc->SetDistancePerPulse(.5);
	gyro = new Gyro (1);
	Angle = gyro->GetAngle();

	if (stick->GetRawButton(1))

		{
			automode = 1;
		}
		if (stick->GetRawButton(2))
		{
			automode = 2;
		} else {
			automode = 0;
		}
	SmartDashboard::PutNumber("Auto:", automode);
gyro->InitGyro();
ElevSol = new DoubleSolenoid (2,3);
gyro->InitGyro();
Limit = new DigitalInput(2);
ElevatorPID = new PIDController(0.5, 0.0, 0.0, &ElevatorEnc, &Elevator);
	}
We get this error: no matching function for call to 'PIDController:IDController(double, double, double, Encoder**, Talon**, double)'
We're confused on how to get the function for the PID working. Thanks!
Reply With Quote
  #2   Spotlight this post!  
Unread 05-02-2015, 20:25
Ben Wolsieffer Ben Wolsieffer is offline
Dartmouth 2020
AKA: lopsided98
FRC #2084 (Robots by the C)
Team Role: Alumni
 
Join Date: Jan 2011
Rookie Year: 2011
Location: Manchester, MA (Hanover, NH)
Posts: 520
Ben Wolsieffer has much to be proud ofBen Wolsieffer has much to be proud ofBen Wolsieffer has much to be proud ofBen Wolsieffer has much to be proud ofBen Wolsieffer has much to be proud ofBen Wolsieffer has much to be proud ofBen Wolsieffer has much to be proud ofBen Wolsieffer has much to be proud of
Re: Need help with testing PID for an elevator

Try changing the second to last line to:
Code:
ElevatorPID = new PIDController(0.5, 0.0, 0.0, ElevatorEnc, Elevator);
Your problem is that you are passing the address of a pointer to the PIDController instead of just a pointer (because ElevatorInc and Elevator are already pointers).
__________________



2016 North Shore District - Semifinalists and Excellence in Engineering Award
2015 Northeastern University District - Semifinalists and Creativity Award
2014 Granite State District - Semifinalists and Innovation in Control Award
2012 Boston Regional - Finalists
Reply With Quote
  #3   Spotlight this post!  
Unread 05-02-2015, 22:18
thatprogrammer's Avatar
thatprogrammer thatprogrammer is offline
Registered User
AKA: Ahad Bawany
no team (None)
Team Role: Programmer
 
Join Date: Apr 2014
Rookie Year: 2014
Location: Florida
Posts: 610
thatprogrammer has a reputation beyond reputethatprogrammer has a reputation beyond reputethatprogrammer has a reputation beyond reputethatprogrammer has a reputation beyond reputethatprogrammer has a reputation beyond reputethatprogrammer has a reputation beyond reputethatprogrammer has a reputation beyond reputethatprogrammer has a reputation beyond reputethatprogrammer has a reputation beyond reputethatprogrammer has a reputation beyond reputethatprogrammer has a reputation beyond repute
Re: Need help with testing PID for an elevator

Quote:
Originally Posted by lopsided98 View Post
Try changing the second to last line to:
Code:
ElevatorPID = new PIDController(0.5, 0.0, 0.0, ElevatorEnc, Elevator);
Your problem is that you are passing the address of a pointer to the PIDController instead of just a pointer (because ElevatorInc and Elevator are already pointers).
That did it, thanks!
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 14:04.

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


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi