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


Java Gyro類代碼示例

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


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

示例1: robotInit

import edu.wpi.first.wpilibj.Gyro; //導入依賴的package包/類
/**
 * This function is run when the robot is first started up and should be
 * used for any initialization code.
 */
public void robotInit() {
    // instantiate the command used for the autonomous period
    autonomousCommand = new ExampleCommand();
    
    frontLeft = new Victor(1); // Creating Victor motors
    frontRight = new Victor(2);
    rearLeft = new Victor(3);
    rearRight = new Victor(4);
    
    myDrive = new RobotDrive(frontLeft, frontRight);
    // myDrive = new RobotDrive(frontLeft,frontRight,rearLeft,rearRight);
    
    driveStick = new Joystick(1);
    
    gyro = new Gyro(1);

    // Initialize all subsystems
    CommandBase.init();
}
 
開發者ID:Spartronics4915,項目名稱:2014-Aerial-Assist,代碼行數:24,代碼來源:RobotTemplate.java

示例2: MecanumDriveAlgorithm

import edu.wpi.first.wpilibj.Gyro; //導入依賴的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

示例3: Drivetrain

import edu.wpi.first.wpilibj.Gyro; //導入依賴的package包/類
public Drivetrain () {
    leftBackMotor   = new TalonWrapper (RobotMap.Drivetrain.LEFT_BACK_MOTOR_CHANNEL, Constants.Drivetrain.LEFT_BACK_MOTOR_FLIPPED);
    leftMiddleMotor = new TalonWrapper (RobotMap.Drivetrain.LEFT_MIDDLE_MOTOR_CHANNEL, Constants.Drivetrain.LEFT_MIDDLE_MOTOR_FLIPPED);
    leftFrontMotor  = new TalonWrapper (RobotMap.Drivetrain.LEFT_FRONT_MOTOR_CHANNEL, Constants.Drivetrain.LEFT_FRONT_MOTOR_FLIPPED);
    rightBackMotor  = new TalonWrapper (RobotMap.Drivetrain.RIGHT_BACK_MOTOR_CHANNEL, Constants.Drivetrain.RIGHT_BACK_MOTOR_FLIPPED);
    rightMiddleMotor = new TalonWrapper (RobotMap.Drivetrain.RIGHT_MIDDLE_MOTOR_CHANNEL, Constants.Drivetrain.RIGHT_MIDDLE_MOTOR_FLIPPED);
    rightFrontMotor = new TalonWrapper (RobotMap.Drivetrain.RIGHT_FRONT_MOTOR_CHANNEL, Constants.Drivetrain.RIGHT_FRONT_MOTOR_FLIPPED);

    leftEnc  = new EncoderWrapper (RobotMap.Drivetrain.LEFT_ENC_CHANNEL_A, RobotMap.Drivetrain.LEFT_ENC_CHANNEL_B);
    rightEnc = new EncoderWrapper (RobotMap.Drivetrain.RIGHT_ENC_CHANNEL_A, RobotMap.Drivetrain.RIGHT_ENC_CHANNEL_B);

    gyro = new Gyro(RobotMap.Drivetrain.GYRO_CHANNEL);

    shifter = new Solenoid(RobotMap.Drivetrain.SHIFTER_CHANNEL);

    leftTargetSpeed = rightTargetSpeed = leftCurrSpeed = rightCurrSpeed = 0;

    isBusy = false;
    isShifterLocked = false;
}
 
開發者ID:Arcterus,項目名稱:RobotCode-2015,代碼行數:21,代碼來源:Drivetrain.java

示例4: SensorInput

import edu.wpi.first.wpilibj.Gyro; //導入依賴的package包/類
/**
 * Instantiates the Sensor Input module to read all sensors connected to the roboRIO.
 */
private SensorInput() {	
	limit_left = new DigitalInput(ChiliConstants.left_limit);
	limit_right = new DigitalInput(ChiliConstants.right_limit);
	accel = new BuiltInAccelerometer(Accelerometer.Range.k2G);
	gyro = new Gyro(ChiliConstants.gyro_channel);
	pdp = new PowerDistributionPanel();
	left_encoder = new Encoder(ChiliConstants.left_encoder_channelA, ChiliConstants.left_encoder_channelB, false);
	right_encoder = new Encoder(ChiliConstants.right_encoder_channelA, ChiliConstants.right_encoder_channelB, true);
	gyro_i2c = new GyroITG3200(I2C.Port.kOnboard);
	
	gyro_i2c.initialize();
	gyro_i2c.reset();
	gyro.initGyro();
	
	left_encoder.setDistancePerPulse(ChiliConstants.kDistancePerPulse);
	right_encoder.setDistancePerPulse(ChiliConstants.kDistancePerPulse);
}
 
開發者ID:Chilean-Heart,項目名稱:2015-frc-robot,代碼行數:21,代碼來源:SensorInput.java

示例5: ControllerDrive

import edu.wpi.first.wpilibj.Gyro; //導入依賴的package包/類
public ControllerDrive(int limit)
{
    super(limit);
    //TODO
    leftEncoder = new Encoder(3,4);  //competition: 3,4 / practice: 8,7
    rightEncoder = new Encoder(2,1); //competition: 2,1 / practice: 6,5
    gyro = new Gyro(2);
    
    leftEncoderDistance = 0;
    rightEncoderDistance = 0;
    lastLeftEncoderDistance = 0;
    lastRightEncoderDistance = 0;
    
    timer = new Timer();
    timer.start();
    
    lastGyroValue = 0;
    System.out.println("[WiredCats] Drive Controller Initialized.");
}
 
開發者ID:wiredcats,項目名稱:EventBasedWiredCats,代碼行數:20,代碼來源:ControllerDrive.java

示例6: update

import edu.wpi.first.wpilibj.Gyro; //導入依賴的package包/類
public void update() {
    left_drive_speed = ((Double) WsOutputManager.getInstance().getOutput(WsOutputManager.LEFT_DRIVE_SPEED).get((IOutputEnum) null));
    right_drive_speed = ((Double) WsOutputManager.getInstance().getOutput(WsOutputManager.RIGHT_DRIVE_SPEED).get((IOutputEnum) null));
    
    Gyro gyro = ((WsDriveBase) (WsSubsystemContainer.getInstance().getSubsystem(WsSubsystemContainer.WS_DRIVE_BASE))).getGyro();
    double angle = gyro.getAngle();
    //Handle brakes
    if ((left_drive_speed > 0.1) && (right_drive_speed < 0.1)) {
        angle--;
    } else if ((left_drive_speed < 0.1) && (right_drive_speed > 0.1)) {
        angle++;
    }
    gyro.setAngle(angle);
    SmartDashboard.putNumber("Gyro Angle", angle);
}
 
開發者ID:wildstang111,項目名稱:2013_drivebase_proto,代碼行數:16,代碼來源:GyroSimulation.java

示例7: initialize

import edu.wpi.first.wpilibj.Gyro; //導入依賴的package包/類
@Override
public void initialize()
{
	rightFront = new Talon(0);
	rightBack = new Talon(1);
	leftFront = new Talon(3);
	leftBack = new Talon(2);
	drivetrain = new RobotDrive(leftBack, leftFront, rightBack, rightFront);		
	
	gyro = new Gyro(0);
	
	drivetrain.setInvertedMotor(MotorType.kFrontRight, true);
	drivetrain.setInvertedMotor(MotorType.kRearRight, true);
}
 
開發者ID:SCOTS-Bots,項目名稱:FRC-2015-Robot-Java,代碼行數:15,代碼來源:RobotHardwareMecbot.java

示例8: initialize

import edu.wpi.first.wpilibj.Gyro; //導入依賴的package包/類
public void initialize() 
{
	rearLeftMotor = new Jaguar(0);
	frontLeftMotor = new Jaguar(1);
	liftMotor = new Jaguar(2);
	liftMotor2 = new Jaguar(3);
	liftEncoder = new Encoder(6, 7, false, EncodingType.k4X);
	
	drivetrain = new RobotDrive(rearLeftMotor, frontLeftMotor);	
	
	drivetrain.setInvertedMotor(MotorType.kFrontLeft, true);
	drivetrain.setInvertedMotor(MotorType.kFrontRight, true);

	halsensor = new DigitalInput(0);
	
	horizontalCamera = new Servo(8);
	verticalCamera = new Servo(9);
	
	solenoid = new DoubleSolenoid(0,1);
	
	gyro = new Gyro(1);
	accelerometer = new BuiltInAccelerometer();
	
	liftEncoder.reset();
	
	RobotHardwareWoodbot hardware = (RobotHardwareWoodbot)Robot.bot;
	
	LiveWindow.addActuator("Drive Train", "Front Left Motor", (Jaguar)hardware.frontLeftMotor);
	LiveWindow.addActuator("Drive Train", "Back Left Motor", (Jaguar)hardware.rearLeftMotor);
	//LiveWindow.addActuator("Drive Train", "Front Right Motor", (Jaguar)hardware.frontRightMotor);
	//LiveWindow.addActuator("Drive Train", "Back Right Motor", (Jaguar)hardware.rearRightMotor);
}
 
開發者ID:SCOTS-Bots,項目名稱:FRC-2015-Robot-Java,代碼行數:33,代碼來源:RobotHardwareWoodbot.java

示例9: initialize

import edu.wpi.first.wpilibj.Gyro; //導入依賴的package包/類
@Override
public void initialize()

{
	//PWM
	liftMotor = new Victor(0); //2);
	leftMotors = new Victor(1);
	rightMotors = new Victor(2); //0);
	armMotors = new Victor(3);
	transmission = new Servo(7);

	//CAN
	armSolenoid = new DoubleSolenoid(4,5);
	
	//DIO
	liftEncoder = new Encoder(0, 1, false, EncodingType.k4X);
	liftBottomLimit = new DigitalInput(2);
	liftTopLimit = new DigitalInput(3);
	backupLiftBottomLimit = new DigitalInput(5);
	
	switch1 = new DigitalInput(9);
	switch2 = new DigitalInput(8);
	
	//ANALOG
	gyro = new Gyro(0);
	
	//roboRio
	accelerometer = new BuiltInAccelerometer();
	
	//Stuff
	drivetrain = new RobotDrive(leftMotors, rightMotors);

	liftSpeedRatio = 1; //Half power default
	liftGear = 1;
	driverSpeedRatio = 1;
	debounceComp = 0;
	
	drivetrain.setInvertedMotor(MotorType.kRearLeft, true);
	drivetrain.setInvertedMotor(MotorType.kRearRight, true);
}
 
開發者ID:SCOTS-Bots,項目名稱:FRC-2015-Robot-Java,代碼行數:41,代碼來源:RobotHardwareCompbot.java

示例10: initialize

import edu.wpi.first.wpilibj.Gyro; //導入依賴的package包/類
@Override
public void initialize()
{
	//PWM
	liftMotor = new Talon(0); //2);
	leftMotors = new Talon(1);
	rightMotors = new Talon(2); //0);
	armMotors = new Talon(3);
	transmission = new Servo(7);

	//CAN
	armSolenoid = new DoubleSolenoid(4,5);
	
	//DIO
	/*liftEncoder = new Encoder(0, 1, false, EncodingType.k4X);
	liftBottomLimit = new DigitalInput(2);
	liftTopLimit = new DigitalInput(3);
	backupLiftBottomLimit = new DigitalInput(4);
	
	switch1 = new DigitalInput(9);
	switch2 = new DigitalInput(8);*/
	
	//ANALOG
	gyro = new Gyro(0);
	
	//roboRio
	accelerometer = new BuiltInAccelerometer();
	
	//Stuff
	drivetrain = new RobotDrive(leftMotors, rightMotors);

	liftSpeedRatio = 1; //Half power default
	liftGear = 1;
	driverSpeedRatio = 1;
	debounceComp = 0;
	
	drivetrain.setInvertedMotor(MotorType.kRearLeft, true);
	drivetrain.setInvertedMotor(MotorType.kRearRight, true);
}
 
開發者ID:SCOTS-Bots,項目名稱:FRC-2015-Robot-Java,代碼行數:40,代碼來源:RobotHardwarePracticebot.java

示例11: init

import edu.wpi.first.wpilibj.Gyro; //導入依賴的package包/類
public static void init()
{

driveTrainRightVictor = new Victor(1, 1);
driveTrainLeftVictor = new Victor(1, 3);
loaderVictor = new Victor(1, 2);
CatapultVictor = new Victor(1, 4);  

FireSolenoidSpike = new Relay(2);
PrimeSolenoidSpike = new Relay(3);
lightSpike = new Relay(7);
compressorSpike = new Relay(8);
       
gyro = new Gyro(1);
ultrasonic = new AnalogChannel(3);

limitSwitch = new DigitalInput(3);
pressureSwitch = new DigitalInput(2);
        
LiveWindow.addActuator("Drive Train", "Right Victor", (Victor) driveTrainRightVictor);
LiveWindow.addActuator("Drive Train", "Left Victor", (Victor) driveTrainLeftVictor);

robotDriveTrain = new RobotDrive(driveTrainLeftVictor, driveTrainRightVictor);

robotDriveTrain.setSafetyEnabled(true);
robotDriveTrain.setExpiration(0.1);
robotDriveTrain.setSensitivity(0.5);
robotDriveTrain.setMaxOutput(1.0);
}
 
開發者ID:lucaswalter,項目名稱:Staley-Robotics-2014,代碼行數:30,代碼來源:RobotMap.java

示例12: update

import edu.wpi.first.wpilibj.Gyro; //導入依賴的package包/類
@Override
public void update() {
    left_drive_speed = ((Double) OutputManager.getInstance().getOutput(OutputManager.LEFT_DRIVE_SPEED_INDEX).get((IOutputEnum) null));
    right_drive_speed = ((Double) OutputManager.getInstance().getOutput(OutputManager.RIGHT_DRIVE_SPEED_INDEX).get((IOutputEnum) null));
    Gyro gyro = ((DriveBase) (SubsystemContainer.getInstance().getSubsystem(SubsystemContainer.DRIVE_BASE_INDEX))).getGyro();
    double angle = gyro.getAngle();
    //Handle brakes
    if ((left_drive_speed > 0.1) && (right_drive_speed < 0.1)) {
        angle--;
    } else if ((left_drive_speed < 0.1) && (right_drive_speed > 0.1)) {
        angle++;
    }
    gyro.setAngle(angle);
    SmartDashboard.putNumber("Gyro Angle", angle);
}
 
開發者ID:wildstang111,項目名稱:2014_software,代碼行數:16,代碼來源:GyroSimulation.java

示例13: Climber

import edu.wpi.first.wpilibj.Gyro; //導入依賴的package包/類
public Climber(int leftM, int rightM, int leftSecondaryM, int rightSecondaryM, int leftS, int rightS, int gyro)
{
    this.leftM = new Jaguar(leftM);
    this.rightM = new Jaguar(rightM);
    this.leftSecondaryM = new Victor(leftSecondaryM);
    this.rightSecondaryM = new Victor(rightSecondaryM);
    this.leftS = new Servo(leftS);
    this.rightS = new Servo(rightS);
    this.gyro = new Gyro(gyro);
    this.gyro.setSensitivity(.007);
    System.out.println("Sensitivity set");
    this.gyro.reset();

    Log.v(TAG, "Climber subsystem instantiated.");
}
 
開發者ID:eshsrobotics,項目名稱:ultimate-ascent,代碼行數:16,代碼來源:Climber.java

示例14: DriveTrain

import edu.wpi.first.wpilibj.Gyro; //導入依賴的package包/類
public DriveTrain(int left, int right, int gyro)
{
    this.left = new Jaguar(left);
    this.right = new Jaguar(right);
    this.gyro = new Gyro(gyro);

    Log.v(TAG, "Drive train subsystem instantiated.");
}
 
開發者ID:eshsrobotics,項目名稱:ultimate-ascent,代碼行數:9,代碼來源:DriveTrain.java

示例15: VerticalTurretAxis

import edu.wpi.first.wpilibj.Gyro; //導入依賴的package包/類
/** The VerticalTurretAxis constructor is called by the ScraperBike constructor.
 *
 */
public VerticalTurretAxis(){
    super("VerticalTurretAxis");
    verTurretTalon = new Talon(RobotMap.VerTurretMotor);
    
    gyro = new Gyro(RobotMap.gyroAnalogInput);
}
 
開發者ID:jdrusso,項目名稱:ScraperBike2013,代碼行數:10,代碼來源:VerticalTurretAxis.java


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