当前位置: 首页>>代码示例>>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;未经允许,请勿转载。