|
Help Setting Up PID System for Tank Drive Train
My team is making 4 motor drive train that has two on each side with a jaguar attached to each motor. I have a basic understanding of the CommandBase structure included in the library, but I'm not sure what I would use for the pid loop when it comes to values, constants, and to do with returnPIDInput(). I'm not entirely sure what sort of input the jaguars can have, and that's the source of my problem. I keep seeing that they have built in encoders? Here's my code so far. I hope that once I figure out how to use PID here I'll be able to use a similar format to control our "arm."
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package edu.wpi.first.wpilibj.templates.subsystems;
import edu.wpi.first.wpilibj.RobotDrive;
import edu.wpi.first.wpilibj.command.PIDSubsystem;
import edu.wpi.first.wpilibj.templates.RobotMap;
/**
*
* @author l0stboy
*/
public class DriveTrain extends PIDSubsystem {
private static final double Kp = 0.0;
private static final double Ki = 0.0;
private static final double Kd = 0.0;
//declare objects
RobotDrive zombieDrive;
// Initialize your subsystem here
public DriveTrain() {
super("DriveTrains", Kp, Ki, Kd);
// Use these to get going:
// setSetpoint() - Sets where the PID controller should move the system
// to
// enable() - Enables the PID controller.
zombieDrive = new RobotDrive(RobotMap.leftBackMotor, RobotMap.leftFrontMotor,
RobotMap.rightBackMotor, RobotMap.rightFrontMotor);
}
public void initDefaultCommand() {
// Set the default command for a subsystem here.
//setDefaultCommand(new MySpecialCommand());d
setDefaultCommnad(JoystickDrive);
}
protected double returnPIDInput() {
// Return your input value for the PID loop
// e.g. a sensor, like a potentiometer:
// yourPot.getAverageVoltage() / kYourMaxVoltage;
return zombieDrive.get;
}
protected void usePIDOutput(double output) {
// Use output to drive your system, like a motor
// e.g. yourMotor.set(output);
}
}
__________________
Pedro
Ocala InZombiacs
Last edited by l0stboy : 27-01-2012 at 16:37.
|