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


Java RobotDrive類代碼示例

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


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

示例1: init

import edu.wpi.first.wpilibj.RobotDrive; //導入依賴的package包/類
public static void init() {
	driveTrainCIMRearLeft = new CANTalon(2); // rear left motor
	driveTrainCIMFrontLeft = new CANTalon(12); // 
	driveTrainCIMRearRight = new CANTalon(1);
	driveTrainCIMFrontRight = new CANTalon(11);
	driveTrainRobotDrive41 = new RobotDrive(driveTrainCIMRearLeft, driveTrainCIMFrontLeft, 
			driveTrainCIMRearRight, driveTrainCIMFrontRight);
	climberClimber = new CANTalon(3);
    c1 = new Talon(5);
    pDPPowerDistributionPanel1 = new PowerDistributionPanel(0);
    gyro = new ADXRS450_Gyro(Port.kOnboardCS0);
    c2 = new Talon(6);
    ultra = new AnalogInput(0);
    
    LiveWindow.addSensor("PDP", "PowerDistributionPanel 1", pDPPowerDistributionPanel1);
    LiveWindow.addSensor("Ultra", "Ultra", ultra);
   //  LiveWindow.addActuator("Intake", "Intake", intakeIntake);
    LiveWindow.addActuator("Climber", "Climber", climberClimber);
    LiveWindow.addActuator("RearLeft (2)", "Drivetrain", driveTrainCIMRearLeft);
    LiveWindow.addActuator("FrontLeft (12)", "Drivetrain", driveTrainCIMFrontLeft);
    LiveWindow.addActuator("RearRight (1)", "Drivetrain", driveTrainCIMRearRight);
    LiveWindow.addActuator("FrontRight (11)", "Drivetrain", driveTrainCIMFrontRight);
    LiveWindow.addActuator("Drive Train", "Gyro", gyro);
    // LiveWindow.addActuator("Shooter", "Shooter", shooter1);
}
 
開發者ID:Team4914,項目名稱:2017-emmet,代碼行數:26,代碼來源:RobotMap.java

示例2: Robot

import edu.wpi.first.wpilibj.RobotDrive; //導入依賴的package包/類
public Robot() {
	stick = new Joystick(0);
	driveLeftFront = new Victor(LEFT_FRONT_DRIVE);
	driveLeftRear = new Victor(LEFT_REAR_DRIVE);
	driveRightFront = new Victor(RIGHT_FRONT_DRIVE);
	driveRightRear = new Victor(RIGHT_REAR_DRIVE);
	enhancedDriveLeft = new Victor(ENHANCED_LEFT_DRIVE);
	enhancedDriveRight = new Victor(ENHANCED_RIGHT_DRIVE);
	gearBox = new DoubleSolenoid(GEAR_BOX_PART1, GEAR_BOX_PART2);
	climber1 = new Victor(CLIMBER_PART1);
	climber2 = new Victor(CLIMBER_PART2);
	vexSensorBackLeft = new Ultrasonic(0, 1);
	vexSensorBackRight = new Ultrasonic(2, 3);
	vexSensorFrontLeft = new Ultrasonic(4, 5);
	vexSensorFrontRight = new Ultrasonic(6, 7);

	Skylar = new RobotDrive(driveLeftFront, driveLeftRear, driveRightFront, driveRightRear);
	OptimusPrime = new RobotDrive(enhancedDriveLeft, enhancedDriveRight);
}
 
開發者ID:TeamAutomatons,項目名稱:Steamwork_2017,代碼行數:20,代碼來源:Robot.java

示例3: initTalonConfig

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

	    talons = new CANTalon[] {
	    		new CANTalon(TALONS_FRONT_LEFT), new CANTalon(TALONS_FRONT_RIGHT),
	            new CANTalon(TALONS_REAR_LEFT), new CANTalon(TALONS_REAR_RIGHT)};
	    
	    talons[MotorType.kFrontLeft.value].setInverted(true);
	    talons[MotorType.kFrontRight.value].setInverted(false);
	    talons[MotorType.kRearLeft.value].setInverted(true);
	    talons[MotorType.kRearRight.value].setInverted(false);
	    
	    for (CANTalon t: talons) {
            t.changeControlMode(CANTalon.TalonControlMode.PercentVbus);
            t.enableBrakeMode(false);
            t.setFeedbackDevice(FeedbackDevice.QuadEncoder);
            t.configEncoderCodesPerRev(ENC_CODES_PER_REV);
            t.setEncPosition(0);
            t.set(0);
        }
	    robotDrive = new RobotDrive(talons[MotorType.kFrontLeft.value], talons[MotorType.kRearLeft.value], 
	    							talons[MotorType.kFrontRight.value], talons[MotorType.kRearRight.value]);
	    robotDrive.setSafetyEnabled(false);
	}
 
開發者ID:frc2879,項目名稱:2017-newcomen,代碼行數:24,代碼來源:Drivetrain.java

示例4: robotInit

import edu.wpi.first.wpilibj.RobotDrive; //導入依賴的package包/類
/**
 * This function is run when the robot is first started up and should be
 * used for any initialization code.
 */
@Override
public void robotInit() {

       driveLeftA = new CANTalon(2);
       driveLeftB = new CANTalon(1);
       driveRightA = new CANTalon(3);
       driveRightB = new CANTalon(4);

       climberMotorA = new Talon(1);
       climberMotorB = new Talon(2);

       drive = new RobotDrive(driveLeftA, driveLeftB, driveRightA, driveRightB);

       joystick = new Joystick(0);

       SmartDashboard.putNumber("SlowClimber", .5);
       SmartDashboard.putNumber("FastClimber", 1);
}
 
開發者ID:ArcticWarriors,項目名稱:snobot-2017,代碼行數:23,代碼來源:Robot.java

示例5: DriveSubsystem

import edu.wpi.first.wpilibj.RobotDrive; //導入依賴的package包/類
public DriveSubsystem() {
  super("DriveSubsystem");

  leftFrontTalon = new CANTalon(RobotMap.TALON_DRIVEBASE_LEFT_FRONT);
  leftRearTalon = new CANTalon(RobotMap.TALON_DRIVEBASE_LEFT_REAR);
  rightFrontTalon = new CANTalon(RobotMap.TALON_DRIVEBASE_RIGHT_FRONT);
  rightRearTalon = new CANTalon(RobotMap.TALON_DRIVEBASE_RIGHT_REAR);

  leftFrontTalon.setVoltageRampRate(RAMP_RATE);
  rightFrontTalon.setVoltageRampRate(RAMP_RATE);
  leftRearTalon.setVoltageRampRate(RAMP_RATE);
  rightRearTalon.setVoltageRampRate(RAMP_RATE);

  leftFrontTalon.setFeedbackDevice(CANTalon.FeedbackDevice.CtreMagEncoder_Relative);
  rightRearTalon.setFeedbackDevice(CANTalon.FeedbackDevice.CtreMagEncoder_Relative);
  rightRearTalon.reverseSensor(true);

  robotDrive = new RobotDrive(leftFrontTalon, leftRearTalon, rightFrontTalon, rightRearTalon);
  robotDrive.setSafetyEnabled(false);
}
 
開發者ID:FRC-1294,項目名稱:frc2017,代碼行數:21,代碼來源:DriveSubsystem.java

示例6: initialize

import edu.wpi.first.wpilibj.RobotDrive; //導入依賴的package包/類
public static void initialize()
{
	if (!initialized) {
        mFrontLeft = new CANTalon(LEFT_FRONT_TALON_ID);
        mBackLeft = new CANTalon(LEFT_REAR_TALON_ID);
        mFrontRight = new CANTalon(RIGHT_FRONT_TALON_ID);
        mBackRight = new CANTalon(RIGHT_REAR_TALON_ID);
        	        
        drive = new RobotDrive(mFrontLeft, mBackLeft, mFrontRight, mBackRight);
        	        
        drive.setInvertedMotor(RobotDrive.MotorType.kFrontLeft, false);
        drive.setInvertedMotor(RobotDrive.MotorType.kFrontRight, false);
        drive.setInvertedMotor(RobotDrive.MotorType.kRearLeft, false);
        drive.setInvertedMotor(RobotDrive.MotorType.kRearRight, false);   
        
        leftStick = new Joystick(LEFT_JOYSTICK_ID);
        rightStick = new Joystick(RIGHT_JOYSTICK_ID);
        
        initialized = true;
	}
}
 
開發者ID:MTHSRoboticsClub,項目名稱:FRC-2017,代碼行數:22,代碼來源:CANDriveAssembly.java

示例7: DriveTrainSubsystem

import edu.wpi.first.wpilibj.RobotDrive; //導入依賴的package包/類
public DriveTrainSubsystem()
{
    lastLeft = 0.0D;
    lastRight = 0.0D;

    leftTalon0 = new CANTalon(RobotMap.Motor.LEFT_TALON_0);
    leftTalon1 = new CANTalon(RobotMap.Motor.LEFT_TALON_1);
    rightTalon0 = new CANTalon(RobotMap.Motor.RIGHT_TALON_0);
    rightTalon1 = new CANTalon(RobotMap.Motor.RIGHT_TALON_1);

    drive = new RobotDrive(leftTalon0, leftTalon1, rightTalon0, rightTalon1);
    drive.setExpiration(0.1D);

    setTalonSettings(leftTalon0);
    setTalonSettings(leftTalon1);
    setTalonSettings(rightTalon0);
    setTalonSettings(rightTalon1);
}
 
開發者ID:Team-2502,項目名稱:RobotCode2017,代碼行數:19,代碼來源:DriveTrainSubsystem.java

示例8: DrivetrainSubsystem

import edu.wpi.first.wpilibj.RobotDrive; //導入依賴的package包/類
public DrivetrainSubsystem(){
	leftMotor = RobotMap.leftDriveMotor.getController();
	rightMotor = RobotMap.rightDriveMotor.getController();
	drive = new RobotDrive(leftMotor, rightMotor);
	
	accelerometer = new IntegratedBuiltinAccelerometer(Range.k2G);
	
	leftEncoder = new Encoder(RobotMap.leftEncoder[0], RobotMap.leftEncoder[1]);
	rightEncoder = new Encoder(RobotMap.rightEncoder[0], RobotMap.rightEncoder[1]);
	leftEncoder.setReverseDirection(true);
	rightEncoder.setReverseDirection(true);
	
	driveGyro = new AnalogGyro(RobotMap.driveGyroPort);
	driveGyro.reset();
	driveGyro.setSensitivity(0.007);
	
	
}
 
開發者ID:Millerbots,項目名稱:FRC2549-2016,代碼行數:19,代碼來源:DrivetrainSubsystem.java

示例9: DrivetrainPID

import edu.wpi.first.wpilibj.RobotDrive; //導入依賴的package包/類
public DrivetrainPID() {
  	super(RobotMap.DRIVE_TURN_P, RobotMap.DRIVE_TURN_I, RobotMap.DRIVE_TURN_D);
  	frontLeft = new CANTalon(RobotMap.FRONT_LEFT_MOTOR);
frontRight = new CANTalon(RobotMap.FRONT_RIGHT_MOTOR);
rearLeft = new CANTalon(RobotMap.REAR_LEFT_MOTOR);
rearRight = new CANTalon(RobotMap.REAR_RIGHT_MOTOR);

frontLeft.enableControl();
frontRight.enableControl();
rearLeft.enableControl();
rearRight.enableControl();

oneDrive = new RobotDrive(frontLeft, rearLeft, frontRight, rearRight);
SmartDashboard.putNumber("Front right", 0);
SmartDashboard.putNumber("Front left", 0);
  }
 
開發者ID:SouthEugeneRoboticsTeam,項目名稱:Stronghold-2016,代碼行數:17,代碼來源:DrivetrainPID.java

示例10: Robot

import edu.wpi.first.wpilibj.RobotDrive; //導入依賴的package包/類
public Robot() {
     myRobot = new RobotDrive(0, 1);
     myRobot.setExpiration(0.1);
     stick = new Joystick(0);
     try {
/***********************************************************************
 * navX-MXP:
 * - Communication via RoboRIO MXP (SPI, I2C, TTL UART) and USB.            
 * - See http://navx-mxp.kauailabs.com/guidance/selecting-an-interface.
 * 
 * navX-Micro:
 * - Communication via I2C (RoboRIO MXP or Onboard) and USB.
 * - See http://navx-micro.kauailabs.com/guidance/selecting-an-interface.
 * 
 * Multiple navX-model devices on a single robot are supported.
 ************************************************************************/
         ahrs = new AHRS(SPI.Port.kMXP); 
     } catch (RuntimeException ex ) {
         DriverStation.reportError("Error instantiating navX MXP:  " + ex.getMessage(), true);
     }
 }
 
開發者ID:FRC1458,項目名稱:turtleshell,代碼行數:22,代碼來源:Robot.java

示例11: Robot

import edu.wpi.first.wpilibj.RobotDrive; //導入依賴的package包/類
public Robot() {
     myRobot = new RobotDrive(frontLeftChannel, rearLeftChannel,
     		frontRightChannel, rearRightChannel);
     myRobot.setExpiration(0.1);
     stick = new Joystick(0);
     try {
/***********************************************************************
 * navX-MXP:
 * - Communication via RoboRIO MXP (SPI, I2C, TTL UART) and USB.            
 * - See http://navx-mxp.kauailabs.com/guidance/selecting-an-interface.
 * 
 * navX-Micro:
 * - Communication via I2C (RoboRIO MXP or Onboard) and USB.
 * - See http://navx-micro.kauailabs.com/guidance/selecting-an-interface.
 * 
 * Multiple navX-model devices on a single robot are supported.
 ************************************************************************/
         ahrs = new AHRS(SPI.Port.kMXP); 
     } catch (RuntimeException ex ) {
         DriverStation.reportError("Error instantiating navX MXP:  " + ex.getMessage(), true);
     }
 }
 
開發者ID:FRC1458,項目名稱:turtleshell,代碼行數:23,代碼來源:Robot.java

示例12: Robot

import edu.wpi.first.wpilibj.RobotDrive; //導入依賴的package包/類
public Robot() {
    myRobot = new RobotDrive(frontLeftChannel, rearLeftChannel,
    		frontRightChannel, rearRightChannel);
    myRobot.setExpiration(0.1);
    stick = new Joystick(0);
    try {
/***********************************************************************
 * navX-MXP:
 * - Communication via RoboRIO MXP (SPI, I2C, TTL UART) and USB.            
 * - See http://navx-mxp.kauailabs.com/guidance/selecting-an-interface.
 * 
 * navX-Micro:
 * - Communication via I2C (RoboRIO MXP or Onboard) and USB.
 * - See http://navx-micro.kauailabs.com/guidance/selecting-an-interface.
 * 
 * Multiple navX-model devices on a single robot are supported.
 ************************************************************************/
  	  ahrs = new AHRS(SPI.Port.kMXP); 
    } catch (RuntimeException ex ) {
        DriverStation.reportError("Error instantiating navX MXP:  " + ex.getMessage(), true);
    }
}
 
開發者ID:FRC1458,項目名稱:turtleshell,代碼行數:23,代碼來源:Robot.java

示例13: Robot

import edu.wpi.first.wpilibj.RobotDrive; //導入依賴的package包/類
public Robot() {
    myRobot = new RobotDrive(frontLeftChannel, rearLeftChannel, 
		 frontRightChannel, rearRightChannel);
    myRobot.setExpiration(0.1);
    stick = new Joystick(0);
    try {
/***********************************************************************
 * navX-MXP:
 * - Communication via RoboRIO MXP (SPI, I2C, TTL UART) and USB.            
 * - See http://navx-mxp.kauailabs.com/guidance/selecting-an-interface.
 * 
 * navX-Micro:
 * - Communication via I2C (RoboRIO MXP or Onboard) and USB.
 * - See http://navx-micro.kauailabs.com/guidance/selecting-an-interface.
 * 
 * Multiple navX-model devices on a single robot are supported.
 ************************************************************************/
        ahrs = new AHRS(SPI.Port.kMXP); 
    } catch (RuntimeException ex ) {
        DriverStation.reportError("Error instantiating navX MXP:  " + ex.getMessage(), true);
    }
}
 
開發者ID:FRC1458,項目名稱:turtleshell,代碼行數:23,代碼來源:Robot.java

示例14: hdrive

import edu.wpi.first.wpilibj.RobotDrive; //導入依賴的package包/類
public static void hdrive(RobotDrive drive, int pwm_hmotor, Joystick js, boolean squared) {
//		hdrive_L = js.getY() * (js.getY()) + js.getZ();
//		hdrive_R = js.getY() - js.getZ();
//		hdrive_H = js.getX();
//		hdrive_hmotor = new Jaguar(pwm_hmotor);
//		drive.setLeftRightMotorOutputs((hdrive_L > 1) ? 1 : ((hdrive_L < -1) ? -1 : hdrive_L),
//				(hdrive_R > 1) ? 1 : ((hdrive_R < -1) ? -1 : hdrive_R));
//		hdrive_hmotor.set((hdrive_H > 1) ? 1 : ((hdrive_H < -1) ? -1 : hdrive_H));
		hdrive_X = js.getX();
		hdrive_X *= (squared ? hdrive_X : 1);
		hdrive_Y = js.getX();
		hdrive_Y *= (squared ? hdrive_Y : 1);
		hdrive_Z = js.getX();
		hdrive_Z *= (squared ? hdrive_Z : 1);
		hdrive_hmotor = new Jaguar(pwm_hmotor);
		drive.setLeftRightMotorOutputs(
				(hdrive_Y + hdrive_Z > 1) ? 1 : ((hdrive_Y + hdrive_Z < -1) ? -1 : hdrive_Y + hdrive_Z),
				(hdrive_Y - hdrive_Z > 1) ? 1 : ((hdrive_Y - hdrive_Z < -1) ? -1 : hdrive_Y - hdrive_Z));
		hdrive_hmotor.set((hdrive_X > 1) ? 1 : ((hdrive_X < -1) ? -1 : hdrive_X));
		
	}
 
開發者ID:homosapien97,項目名稱:UberbotsJava,代碼行數:22,代碼來源:UBMethods.java

示例15: Robot

import edu.wpi.first.wpilibj.RobotDrive; //導入依賴的package包/類
public Robot() {	// initialize variables in constructor
	stick = new Joystick(RobotMap.JOYSTICK_PORT); // set the stick to refer to joystick #0
	button = new JoystickButton(stick, RobotMap.BTN_TRIGGER);
	
    myRobot = new RobotDrive(RobotMap.FRONT_LEFT_MOTOR, RobotMap.REAR_LEFT_MOTOR,
    		RobotMap.FRONT_RIGHT_MOTOR, RobotMap.REAR_RIGHT_MOTOR);
    myRobot.setExpiration(RobotDrive.kDefaultExpirationTime);  // set expiration time for motor movement if error occurs
    
    pdp = new PowerDistributionPanel();  // instantiate class to get PDP values
    
    compressor = new Compressor(); // Compressor is controlled automatically by PCM
    
    solenoid = new DoubleSolenoid(RobotMap.SOLENOID_PCM_PORT1, RobotMap.SOLENOID_PCM_PORT2); // solenoid on PCM port #0 & #1
    
    /*camera = CameraServer.getInstance();
    camera.setQuality(50);
    camera.setSize(200);*/
    frame = NIVision.imaqCreateImage(NIVision.ImageType.IMAGE_RGB, 0);  // create the image frame for cam
    session = NIVision.IMAQdxOpenCamera("cam0",
            NIVision.IMAQdxCameraControlMode.CameraControlModeController);  // get reference to camera
    NIVision.IMAQdxConfigureGrab(session);  // grab current streaming session
}
 
開發者ID:TechnoWolves5518,項目名稱:2015RobotCode,代碼行數:23,代碼來源:Robot.java


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