当前位置: 首页>>代码示例>>Java>>正文


Java PIDOutput类代码示例

本文整理汇总了Java中edu.wpi.first.wpilibj.PIDOutput的典型用法代码示例。如果您正苦于以下问题:Java PIDOutput类的具体用法?Java PIDOutput怎么用?Java PIDOutput使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


PIDOutput类属于edu.wpi.first.wpilibj包,在下文中一共展示了PIDOutput类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: DriveTrain

import edu.wpi.first.wpilibj.PIDOutput; //导入依赖的package包/类
public DriveTrain() {
    // TODO: would be nice to migrate stuff from RobotMap here.

    // m_turnPID is used to improve accuracy during auto-turn operations.
    m_imu = new IMUPIDSource();
    m_turnPID = new PIDController(turnKp, turnKi, turnKd, turnKf,
                                  m_imu,
                                  new PIDOutput() {
                public void pidWrite(double output) {
                    // output is [-1, 1]... we need to
                    // convert this to a speed...
                    Robot.driveTrain.turn(output * MAXIMUM_TURN_SPEED);
                    // robotDrive.tankDrive(-output, output);
                }
            });
    m_turnPID.setOutputRange(-1, 1);
    m_turnPID.setInputRange(-180, 180);
    m_turnPID.setPercentTolerance(2);
    // m_turnPID.setContuous?
}
 
开发者ID:Spartronics4915,项目名称:2016-Stronghold,代码行数:21,代码来源:DriveTrain.java

示例2: SetDistanceToBox

import edu.wpi.first.wpilibj.PIDOutput; //导入依赖的package包/类
public SetDistanceToBox(double distance) {
	requires(Robot.drivetrain);
	pid = new PIDController(-2, 0, 0, new PIDSource() {
		PIDSourceType m_sourceType = PIDSourceType.kDisplacement;

		public double pidGet() {
			return Robot.drivetrain.getDistanceToObstacle();
		}

		@Override
		public void setPIDSourceType(PIDSourceType pidSource) {
			m_sourceType = pidSource;
		}

		@Override
		public PIDSourceType getPIDSourceType() {
			return m_sourceType;
		}
	}, new PIDOutput() {
		public void pidWrite(double d) {
			Robot.drivetrain.drive(d, d);
		}
	});
	pid.setAbsoluteTolerance(0.01);
	pid.setSetpoint(distance);
}
 
开发者ID:FRC1458,项目名称:turtleshell,代码行数:27,代码来源:SetDistanceToBox.java

示例3: DriveStraight

import edu.wpi.first.wpilibj.PIDOutput; //导入依赖的package包/类
public DriveStraight(double distance) {
    requires(Robot.drivetrain);
    pid = new PIDController(4, 0, 0,
            new PIDSource() {
                PIDSourceType m_sourceType = PIDSourceType.kDisplacement;

                public double pidGet() {
                    return Robot.drivetrain.getDistance();
                }

                @Override
                public void setPIDSourceType(PIDSourceType pidSource) {
                  m_sourceType = pidSource;
                }

                @Override
                public PIDSourceType getPIDSourceType() {
                    return m_sourceType;
                }
            },
            new PIDOutput() { public void pidWrite(double d) {
                Robot.drivetrain.drive(d, d);
            }});
    pid.setAbsoluteTolerance(0.01);
    pid.setSetpoint(distance);
}
 
开发者ID:FRC1458,项目名称:turtleshell,代码行数:27,代码来源:DriveStraight.java

示例4: MecanumDriveAlgorithm

import edu.wpi.first.wpilibj.PIDOutput; //导入依赖的package包/类
/**
 * Creates a new {@link MecanumDriveAlgorithm} that controls the specified
 * {@link FourWheelDriveController}.
 *
 * @param controller the {@link FourWheelDriveController} to control
 * @param gyro the {@link Gyro} to use for orientation correction and
 * field-oriented driving
 */
public MecanumDriveAlgorithm(FourWheelDriveController controller, Gyro gyro) {
    super(controller);
    // Necessary because we hide the controller field inherited from
    // DriveAlgorithm (if this was >=Java 5 I would use generics).
    this.controller = controller;
    this.gyro = gyro;
    rotationPIDController = new PIDController(
            ROTATION_P,
            ROTATION_I,
            ROTATION_D,
            ROTATION_F,
            gyro,
            new PIDOutput() {
                public void pidWrite(double output) {
                    rotationSpeedPID = output;
                }
            }
    );
    SmartDashboard.putData("Rotation PID Controller", rotationPIDController);
}
 
开发者ID:RobotsByTheC,项目名称:CMonster2014,代码行数:29,代码来源:MecanumDriveAlgorithm.java

示例5: DriveToPeg

import edu.wpi.first.wpilibj.PIDOutput; //导入依赖的package包/类
public DriveToPeg(){		
	double distance = .2;
	
	requires(Robot.driveBase);
	double kP = -.4;
	double kI = 1;
	double kD = 5;
	
	pid = new PIDController(kP, kI, kD, new PIDSource() {
		PIDSourceType m_sourceType = PIDSourceType.kDisplacement;

		@Override
		public double pidGet() {
			return Robot.driveBase.getDistanceAhead();
		}

		@Override
		public void setPIDSourceType(PIDSourceType pidSource) {
			m_sourceType = pidSource;
		}

		@Override
		public PIDSourceType getPIDSourceType() {
			return m_sourceType;
		}
	}, new PIDOutput() {
		@Override
		public void pidWrite(double d) {
			Robot.driveBase.driveForward(d);
			System.out.println(d);
		}
	});
	pid.setAbsoluteTolerance(0.01);
	pid.setSetpoint(distance);
	pid.setOutputRange(0, .35);
	
	SmartDashboard.putData("driveToPeg", pid);
}
 
开发者ID:FRC-6413,项目名称:steamworks-java,代码行数:39,代码来源:DriveToPeg.java

示例6: BangBangController

import edu.wpi.first.wpilibj.PIDOutput; //导入依赖的package包/类
public BangBangController (PIDOutput pidOutput, PIDSource pidSource, double period){
    _pidSource = pidSource;
    _pidOutput = pidOutput;
    _period = period;
    _setPoint = 0;
    _timer.schedule(new _bgTask(), 0, (long) (1000*_period));
}
 
开发者ID:2729StormRobotics,项目名称:Storm2014,代码行数:8,代码来源:BangBangController.java

示例7: TakeBackHalfPlusPlus

import edu.wpi.first.wpilibj.PIDOutput; //导入依赖的package包/类
public TakeBackHalfPlusPlus(PIDOutput pidoutput, PIDSource pidsource, double period, double max, double min){
    
    _pidSource = pidsource;
    _pidOutput = pidoutput;
    _setPoint = 0;
    _period = period;
    _max = max;
    _min = min;
    _timer.schedule(new _bgTask(), 0, (long) (1000 * _period));
}
 
开发者ID:2729StormRobotics,项目名称:Storm2014,代码行数:11,代码来源:TakeBackHalfPlusPlus.java

示例8: PIDController649

import edu.wpi.first.wpilibj.PIDOutput; //导入依赖的package包/类
/**
 * Allocate a PID object with the given constants for P, I, D, and F
 *
 * @param Kp the proportional coefficient
 * @param Ki the integral coefficient
 * @param Kd the derivative coefficient
 * @param Kf the feed forward term
 * @param source The PIDSource object that is used to get values
 * @param output The PIDOutput object that is set to the output percentage
 * @param period the loop time for doing calculations. This particularly
 * effects calculations of the integral and differential terms. The default
 * is 50ms.
 */
public PIDController649(double Kp, double Ki, double Kd, double Kf,
        PIDSource source, PIDOutput output,
        double period) {

    if (source == null) {
        throw new NullPointerException("Null PIDSource was given");
    }
    if (output == null) {
        throw new NullPointerException("Null PIDOutput was given");
    }

    m_controlLoop = new java.util.Timer();

    m_P = Kp;
    m_I = Ki;
    m_D = Kd;
    m_F = Kf;

    m_pidInput = source;
    m_pidOutput = output;
    m_period = period;

    m_controlLoop.schedule(new PIDTask(this), 0L, (long) (m_period * 1000));

    instances++;
    UsageReporting.report(UsageReporting.kResourceType_PIDController, instances);
    m_tolerance = new NullTolerance();
    m_outputDirection = true;
}
 
开发者ID:SaratogaMSET,项目名称:649code2014,代码行数:43,代码来源:PIDController649.java

示例9: Tilter

import edu.wpi.first.wpilibj.PIDOutput; //导入依赖的package包/类
private Tilter() {
    leadscrew = new BoundedTalon(Constants.TILTER_CHANNEL, Constants.TILTER_UPPER_LIMIT_SWITCH_CHANNEL, Constants.TILTER_LOWER_LIMIT_SWITCH_CHANNEL);
    accel = new ADXL345_I2C(Constants.ACCELEROMETER_CHANNEL, ADXL345_I2C.DataFormat_Range.k2G);
    accelMeasurements = new Vector();
    updateAccel();        
    pendulum = new AnalogChannel(Constants.PENDULUM_CHANNEL);
    enc = new Encoder(Constants.LEADSCREW_ENCODER_A_CHANNEL, Constants.LEADSCREW_ENCODER_B_CHANNEL);
    enc.setDistancePerPulse(Constants.TILTER_DISTANCE_PER_PULSE);
    enc.start();
    Thread t = new Thread(new Runnable() {
        public void run() {
            Tilter.net = new NetworkIO();
        }
    });
    t.start();
    controller = new PIDController(Constants.PVAL_T, Constants.IVAL_T, Constants.DVAL_T, enc, new PIDOutput() {
        public void pidWrite(double output) {
            setLeadscrewMotor(output);
        }
    }); 
    controller.setPercentTolerance(0.01);
    controller.disable();
    updatePID();
    initialReadingTimer = new Timer();
    initialReadingTimer.schedule(new TimerTask() {

        public void run() {
            initialLeadLength = calcLeadscrewLength(getAveragedAccelBasedAngle());
        }
    }, INITIAL_ANGLE_MEASUREMENT_DELAY);
}
 
开发者ID:Team694,项目名称:desiree,代码行数:32,代码来源:Tilter.java

示例10: RateLimitedPIDOutput

import edu.wpi.first.wpilibj.PIDOutput; //导入依赖的package包/类
public RateLimitedPIDOutput(double rate, PIDOutput output) {
  this.maxRate = rate;
  this.output = output;
}
 
开发者ID:TeamMeanMachine,项目名称:meanlib,代码行数:5,代码来源:RateLimitedPIDOutput.java

示例11: DeltaPID

import edu.wpi.first.wpilibj.PIDOutput; //导入依赖的package包/类
public DeltaPID(IMUAdvanced source, PIDOutput output) 
{
	super(velP,velI,velD, 0, source, output);
	prevYaw=RobotMap.imu.getYaw();
}
 
开发者ID:FRC2832,项目名称:Robot_2016,代码行数:6,代码来源:DeltaPID.java

示例12: PIDSpeedController

import edu.wpi.first.wpilibj.PIDOutput; //导入依赖的package包/类
public PIDSpeedController(PIDSource source, PIDOutput output, String subsystem, String controllerName) {
	controller = new PIDController(0, 0, 0, 0, source, output);

	LiveWindow.addActuator(subsystem, controllerName, controller);
}
 
开发者ID:chopshop-166,项目名称:frc-2016,代码行数:6,代码来源:PIDSpeedController.java

示例13: calculate

import edu.wpi.first.wpilibj.PIDOutput; //导入依赖的package包/类
/**
 * Read the input, calculate the output accordingly, and write to the
 * output. This should only be called by the PIDTask and is created during
 * initialization.
 */
private void calculate() {
    boolean enabled;
    PIDSource pidInput;

    synchronized (this) {
        if (m_pidInput == null) {
            return;
        }
        if (m_pidOutput == null) {
            return;
        }
        enabled = m_enabled; // take snapshot of these values...
        pidInput = m_pidInput;
    }

    if (enabled) {
        double input;
        input = pidInput.pidGet();

        double result;
        PIDOutput pidOutput = null;

        synchronized (this) {
            m_error = m_setpoint - input;
            if (m_continuous) {
                if (Math.abs(m_error)
                        > (m_maximumInput - m_minimumInput) / 2) {
                    if (m_error > 0) {
                        m_error = m_error - m_maximumInput + m_minimumInput;
                    } else {
                        m_error = m_error
                                + m_maximumInput - m_minimumInput;
                    }
                }
            }

            if (m_I != 0) {
                double potentialIGain = (m_totalError + m_error) * m_I;
                if (potentialIGain < m_maximumOutput) {
                    if (potentialIGain > m_minimumOutput) {
                        m_totalError += m_error;
                    } else {
                        m_totalError = m_minimumOutput / m_I;
                    }
                } else {
                    m_totalError = m_maximumOutput / m_I;
                }
            }
            //******************************************************************************************************************
            if (m_error > 0 && m_prevError < 0 || m_error < 0 && m_prevError > 0) {
                m_totalError = 0;
            }
            //******************************************************************************************************************
            m_result = m_P * m_error + m_I * m_totalError + m_D * (m_error - m_prevError) + m_setpoint * m_F;
            m_errorDiff = m_prevError - m_error;
            m_prevError = m_error;

            if (m_result > m_maximumOutput) {
                m_result = m_maximumOutput;
            } else if (m_result < m_minimumOutput) {
                m_result = m_minimumOutput;
            }
            pidOutput = m_pidOutput;
            result = m_result * (m_outputDirection ? 1 : -1);
        }
        pidOutput.pidWrite(result);
    }
}
 
开发者ID:SaratogaMSET,项目名称:649code2014,代码行数:74,代码来源:PIDController649.java

示例14: createPIDControllerFromConstants

import edu.wpi.first.wpilibj.PIDOutput; //导入依赖的package包/类
/**
 * Creates a {@link PIDController} from a {@link PIDConstants} object and
 * the specified source and output.
 * 
 * @param constants the PID constants
 * @param source the PID source
 * @param output the PID output
 * @return a shiny new PID controller
 */
public static PIDController createPIDControllerFromConstants(PIDConstants constants,
        PIDSource source, PIDOutput output) {
    return new PIDController(constants.p, constants.i, constants.d, constants.f, source, output);
}
 
开发者ID:RobotsByTheC,项目名称:CMonster2015,代码行数:14,代码来源:DriveUtils.java


注:本文中的edu.wpi.first.wpilibj.PIDOutput类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。