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


Java PIDSource类代码示例

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


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

示例1: SetDistanceToBox

import edu.wpi.first.wpilibj.PIDSource; //导入依赖的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

示例2: DriveStraight

import edu.wpi.first.wpilibj.PIDSource; //导入依赖的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

示例3: sourceFor

import edu.wpi.first.wpilibj.PIDSource; //导入依赖的package包/类
protected static PIDSource sourceFor(SystemModel model, PIDSourceType initialSourceType) {
    return new PIDSource() {
        private PIDSourceType sourceType = initialSourceType;

        @Override
        public PIDSourceType getPIDSourceType() {
            return sourceType;
        }

        @Override
        public void setPIDSourceType(PIDSourceType pidSource) {
            this.sourceType = pidSource;
        }

        @Override
        public double pidGet() {
            return model.getActualValue();
        }
    };
}
 
开发者ID:strongback,项目名称:strongback-java,代码行数:21,代码来源:SoftwarePIDControllerTest.java

示例4: SwervePod

import edu.wpi.first.wpilibj.PIDSource; //导入依赖的package包/类
public SwervePod(SpeedController turningMotor, SpeedController driveMotor, Encoder encoder, double encoderDistancePerTick, AngularSensor directionSensor) {
    // Initialize motors //
    _turningMotor = turningMotor;
    _driveMotor = driveMotor;
    
    // Initialize sensors //
    _encoder = encoder;
    _encoder.setPIDSourceParameter(PIDSource.PIDSourceParameter.kRate);
    _encoder.setDistancePerPulse(encoderDistancePerTick);
    _encoder.start();
    _directionSensor = directionSensor;
    
    // Initialize PID loops //
    // Turning //
    PIDTurning = new PIDController(Kp_turning, Ki_turning, Kd_turning, _directionSensor, _turningMotor);
    PIDTurning.setOutputRange(minSpeed, maxSpeed);
    PIDTurning.setContinuous(true);
    PIDTurning.setAbsoluteTolerance(tolerance_turning);
    PIDTurning.enable();
    
    // Linear driving //
    PIDDriving = new PIDController(Kp_driving, Ki_driving, Kd_driving, _encoder, _driveMotor);
    PIDDriving.setOutputRange(minSpeed, maxSpeed);
    PIDDriving.disable(); //TODO: Enable
}
 
开发者ID:Whillikers,项目名称:SwerveDrive,代码行数:26,代码来源:SwervePod.java

示例5: EasyPID

import edu.wpi.first.wpilibj.PIDSource; //导入依赖的package包/类
/**
 * Constructs an EasyPID object with the given parameters
 * @param p the constant P value
 * @param i the constant I value
 * @param d the constant D value
 * @param f the constant F value
 * @param name the name to be given to the EasyPID object for SmartDashboard
 * @param s the source to be used for input in the PIDController object
 */
public EasyPID(double p, double i, double d, double f, String name, PIDSource s)
{
    this.name = name;
    System.out.println("constucting PIDEasy object");
    source = s;
    output = new SoftPID();
    
    P = p;
    I = i;
    D = d;
    F = f;
    
    controller = new PIDController(P, I, D, F, source, output);
    SmartDashboard.putData(name, controller);
}
 
开发者ID:BadRobots1014,项目名称:BadRobot2013,代码行数:25,代码来源:EasyPID.java

示例6: DriveToPeg

import edu.wpi.first.wpilibj.PIDSource; //导入依赖的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

示例7: NavXGyroWrapper

import edu.wpi.first.wpilibj.PIDSource; //导入依赖的package包/类
public NavXGyroWrapper(PIDSource wrappedSource) throws IllegalSourceException {
	super(wrappedSource);
	if (wrappedSource.getClass() != AHRS.class) {
		throw new IllegalSourceException();
	}
	else {
		m_navxSource = ((AHRS) m_pidSource);
	}
}
 
开发者ID:1757WestwoodRobotics,项目名称:2017-Steamworks,代码行数:10,代码来源:NavXGyroWrapper.java

示例8: NavXAccelWrapper

import edu.wpi.first.wpilibj.PIDSource; //导入依赖的package包/类
public NavXAccelWrapper(PIDSource wrappedSource, Axis axis) throws IllegalSourceException {
	super(wrappedSource);
	if (wrappedSource.getClass() != AHRS.class) {
		throw new IllegalSourceException();
	}
	else {
		m_navxSource = ((AHRS) m_pidSource);
		this.axis = axis;
	}
}
 
开发者ID:1757WestwoodRobotics,项目名称:2017-Steamworks,代码行数:11,代码来源:NavXAccelWrapper.java

示例9: DriveToAngle

import edu.wpi.first.wpilibj.PIDSource; //导入依赖的package包/类
public DriveToAngle(double angle, PIDSource source) {
	requires(Robot.driveTrain);
	setPoint = angle;

	Robot.driveTrain.ahrs.reset();

	controller = new PIDController(0.75, 0, 0.9, 0, source, this);
	controller.setInputRange(-180, 180);
	controller.setOutputRange(-.26, .26);
	controller.setAbsoluteTolerance(1.0);
	controller.setContinuous(true);

	LiveWindow.addActuator("DriveToAngle", "RotationController", controller);
}
 
开发者ID:Team997Coders,项目名称:2017SteamBot2,代码行数:15,代码来源:DriveToAngle.java

示例10: DriveToDistance

import edu.wpi.first.wpilibj.PIDSource; //导入依赖的package包/类
public DriveToDistance(double distance, PIDSource source) {
    // Use requires() here to declare subsystem dependencies
    // eg. requires(chassis);
	requires(Robot.driveTrain);
	setPoint = distance;

	controller = new PIDController(0.3, 0, 1, source, this);
	controller.setOutputRange(-.28, .28);
	controller.setAbsoluteTolerance(.5);
}
 
开发者ID:Team997Coders,项目名称:2017SteamBot2,代码行数:11,代码来源:DriveToDistance.java

示例11: LinearDigitalFilter

import edu.wpi.first.wpilibj.PIDSource; //导入依赖的package包/类
/**
 * Create a linear FIR or IIR filter.
 *
 * @param source  The PIDSource object that is used to get values
 * @param ffGains The "feed forward" or FIR gains
 * @param fbGains The "feed back" or IIR gains
 */
public LinearDigitalFilter(PIDSource source, double[] ffGains,
                           double[] fbGains) {
  super(source);
  m_inputs = new CircularBuffer(ffGains.length);
  m_outputs = new CircularBuffer(fbGains.length);
  m_inputGains = ffGains;
  m_outputGains = fbGains;
}
 
开发者ID:ArcticWarriors,项目名称:snobot-2017,代码行数:16,代码来源:LinearDigitalFilter.java

示例12: movingAverage

import edu.wpi.first.wpilibj.PIDSource; //导入依赖的package包/类
/**
 * Creates a K-tap FIR moving average filter of the form: y[n] = 1/k * (x[k] + x[k-1] + ... +
 * x[0]).
 *
 * <p>This filter is always stable.
 *
 * @param source The PIDSource object that is used to get values
 * @param taps   The number of samples to average over. Higher = smoother but slower
 * @throws IllegalArgumentException if number of taps is less than 1
 */
public static LinearDigitalFilter movingAverage(PIDSource source, int taps) {
  if (taps <= 0) {
    throw new IllegalArgumentException("Number of taps was not at least 1");
  }

  double[] ffGains = new double[taps];
  for (int i = 0; i < ffGains.length; i++) {
    ffGains[i] = 1.0 / taps;
  }

  double[] fbGains = new double[0];

  return new LinearDigitalFilter(source, ffGains, fbGains);
}
 
开发者ID:ArcticWarriors,项目名称:snobot-2017,代码行数:25,代码来源:LinearDigitalFilter.java

示例13: setPIDSource

import edu.wpi.first.wpilibj.PIDSource; //导入依赖的package包/类
public void setPIDSource(PIDSource source)
{
    turnController = new PIDController(kP, kI, kD, kF, source, this);
    turnController.setInputRange(-15.0, 15.0);
    turnController.setOutputRange(-1.0, 1.0);
    turnController.setAbsoluteTolerance(kToleranceDegrees);
    turnController.setContinuous(false);
}
 
开发者ID:Team-2502,项目名称:RobotCode2017,代码行数:9,代码来源:DriveStraightCommand.java

示例14: getSource

import edu.wpi.first.wpilibj.PIDSource; //导入依赖的package包/类
public PIDSource getSource(final int index) {
    return new PIDSource() {
        public double pidGet() {
            return vals[index];
        }
    };
}
 
开发者ID:OASTEM,项目名称:2014CataBot,代码行数:8,代码来源:TargetSource.java

示例15: ChassisSubsystem

import edu.wpi.first.wpilibj.PIDSource; //导入依赖的package包/类
public ChassisSubsystem() {
    encLeft.setPIDSourceParameter(PIDSource.PIDSourceParameter.kRate);
    encRight.setPIDSourceParameter(PIDSource.PIDSourceParameter.kRate);

    encLeft.start();
    encRight.start();

    pidLeft.setInputRange(-Constants.MAX_ENCODER_COUNTS, Constants.MAX_ENCODER_COUNTS);
    pidRight.setInputRange(-Constants.MAX_ENCODER_COUNTS, Constants.MAX_ENCODER_COUNTS);

    pidLeft.setOutputRange(-1.0, 1.0);
    pidRight.setOutputRange(-1.0, 1.0);
}
 
开发者ID:runnymederobotics,项目名称:robot2014,代码行数:14,代码来源:ChassisSubsystem.java


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