Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   C/C++ (http://www.chiefdelphi.com/forums/forumdisplay.php?f=183)
-   -   Need help with testing PID for an elevator (http://www.chiefdelphi.com/forums/showthread.php?t=134050)

thatprogrammer 05-02-2015 19:54

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::PIDController(double, double, double, Encoder**, Talon**, double)'
We're confused on how to get the function for the PID working. Thanks!

Ben Wolsieffer 05-02-2015 20:25

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).

thatprogrammer 05-02-2015 22:18

Re: Need help with testing PID for an elevator
 
Quote:

Originally Posted by lopsided98 (Post 1439005)
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!


All times are GMT -5. The time now is 12:07.

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