當前位置: 首頁>>代碼示例>>Java>>正文


Java Victor.set方法代碼示例

本文整理匯總了Java中edu.wpi.first.wpilibj.Victor.set方法的典型用法代碼示例。如果您正苦於以下問題:Java Victor.set方法的具體用法?Java Victor.set怎麽用?Java Victor.set使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在edu.wpi.first.wpilibj.Victor的用法示例。


在下文中一共展示了Victor.set方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: ControlToggleRunMotor

import edu.wpi.first.wpilibj.Victor; //導入方法依賴的package包/類
public void ControlToggleRunMotor(Victor vMotor, int speed) {
	if (!toggleMotor) {
		vMotor.set(speed);
		toggleMotor = true;
	}else if (toggleMotor) {
		vMotor.set(0.0);
		toggleMotor = false;
	}
}
 
開發者ID:Team4777,項目名稱:FRC-2015,代碼行數:10,代碼來源:MotorClass.java

示例2: ControlHoldRunMotor

import edu.wpi.first.wpilibj.Victor; //導入方法依賴的package包/類
public void ControlHoldRunMotor(Victor vMotor, int speed, boolean holdingButton) {
	if (holdingButton) {
		vMotor.set(speed);
	}else{
		vMotor.set(0.0);
	}
}
 
開發者ID:Team4777,項目名稱:FRC-2015,代碼行數:8,代碼來源:MotorClass.java

示例3: VictorPair

import edu.wpi.first.wpilibj.Victor; //導入方法依賴的package包/類
public VictorPair(int a, double adjA, int b, double adjB) {
	va = new Victor(a);
	va.set(0);
	adjustA = adjA;

	vb = new Victor(b);
	vb.set(0);
	adjustB = adjB;
}
 
開發者ID:dkess,項目名稱:ReboundRumbleJava,代碼行數:10,代碼來源:VictorPair.java

示例4: EncoderShooter

import edu.wpi.first.wpilibj.Victor; //導入方法依賴的package包/類
public EncoderShooter() {
    backMotor = new Victor(RobotMap.BACK_SHOOTER_MOTOR);
    frontMotor = new Victor(RobotMap.FRONT_SHOOTER_MOTOR);
    counter = new Counter(RobotMap.SHOOTER_ENCODER);
    counter.setUpDownCounterMode();
    counter.start();
    setpoint = RobotMap.DEFAULT_SETPOINT;
    backMotor.set(RobotMap.BACK_SHOOTING_SPEED);


}
 
開發者ID:frc1675,項目名稱:frc1675-2013,代碼行數:12,代碼來源:EncoderShooter.java

示例5: testServoMechanism

import edu.wpi.first.wpilibj.Victor; //導入方法依賴的package包/類
@Test
public void testServoMechanism() {
	// Make the motor and encoder.
	Victor motor = new Victor(1);
	Encoder encoder = new Encoder(1, 2);
	final double cpr = 360.0;
	final double encoder_angular_distance_per_pulse = 2.0*Math.PI / cpr;
	final double pulley_radius = 0.0143256;  // .564 in (18T 5mm pitch)
	// arc length = 2*pi*r*central_angle/360
	final double encoder_linear_distance_per_pulse = pulley_radius * 2.0 * Math.PI / cpr;
	
	// Make a servo mechanism.
	DCMotor transmission = DCMotor.makeTransmission(DCMotor.makeRS775(), 2, 10.5, 0.8);
	// Load is nominally 1kg*m^2
	ServoMechanism mechanism = new ServoMechanism(new PWMObserver(1), new EncoderSetter(1, 2), 0,
			encoder_angular_distance_per_pulse, transmission, .007, new ServoMechanism.Limits(0.0, 1.8));

	// Check against limits.
	assert(mechanism.withinLowerLimits());
	assert(mechanism.withinUpperLimits());
	
	// Drive the load down.
	motor.set(-1.0);
	mechanism.step(12.0, 0.0, 0.01);
	mechanism.step(12.0, 0.0, 0.01);
	mechanism.step(12.0, 0.0, 0.01);
	
	assertFalse(mechanism.withinLowerLimits());
	assert(mechanism.withinUpperLimits());
	
	// Check encoder went in reverse.
	assert(encoder.getRaw() < 0);
	
	// Reset the mechanism.
	mechanism.reset(0.0);
	assertEquals(encoder.getRaw(), 0);
	assert(mechanism.withinLowerLimits());
	
	// Simple 100Hz PID controller.
	final double period = 0.01;
	final double setpoint = 1.5;  // Do a 1.5m lift
	final double proportional_gain = 10.0;
	final double integral_gain = 100.0;
	final double derivative_gain = 0.2;
	double last_error = setpoint;
	double error_sum = 0;
	int last_encoder = 0;
	for (int i = 0; i < 200; ++i) {
		double error = setpoint - encoder.getRaw() * encoder_linear_distance_per_pulse;
		double derivative = (error - last_error) / period;
		last_error = error;
		if (proportional_gain * error < 1.0) {
			error_sum += error * period;
		}
		motor.set(proportional_gain * error + integral_gain * error_sum + derivative_gain * derivative);
		last_encoder = encoder.getRaw();
		mechanism.step(12.0, -9.8/pulley_radius, period);  // Gravity reacting against the lift
		double velocity = (encoder.getRaw() - last_encoder) * encoder_linear_distance_per_pulse / period;
		if (i % 10 == 0) {
			System.out.println("Time: " + i * period + ", Error: " + error + ", Command: " + motor.get() + ", Velocity: " + velocity);
		}
	}
	assertEquals(encoder.getRaw() * encoder_linear_distance_per_pulse, setpoint, 1E-3);
}
 
開發者ID:Team254,項目名稱:Sim-FRC-2015,代碼行數:65,代碼來源:TestServoMechanism.java

示例6: Intake

import edu.wpi.first.wpilibj.Victor; //導入方法依賴的package包/類
public Intake() {        
    intakeRoller = new Victor(Ports.LOADER_INTAKE_ROLLER);
    intakeRoller.set(0);
    extender = new DoubleSolenoid(Ports.LOADER_EXTENDER_1, Ports.LOADER_EXTENDER_2);
}
 
開發者ID:Mercury1089,項目名稱:2014-robot-code,代碼行數:6,代碼來源:Intake.java

示例7: RampedSpeedController

import edu.wpi.first.wpilibj.Victor; //導入方法依賴的package包/類
/**
 * Constructor that creates a Victor to use as the speed controller with the channel number
 * for the Victor to use
 * @param channel the number of the channel to create the speed controller with
 */
public RampedSpeedController(int channel) {
	controller = new Victor(channel);
	controller.set(0);
}
 
開發者ID:Impact2585,項目名稱:Lib2585,代碼行數:10,代碼來源:RampedSpeedController.java


注:本文中的edu.wpi.first.wpilibj.Victor.set方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。