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