微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

edu.wpi.first.wpilibj.TalonSRX的实例源码

项目:FlashLib    文件ExampleMecanumDrive.java   
protected void robotinit() {
//We need to create the speed controllers for our drive system.
//In this example,we have a mecanum drive,so we create 4 speed 
//controller objects from WPILib. We will use the TalonSRX speed controllers.

TalonSRX frontRight = new TalonSRX(0);
TalonSRX rearRight = new TalonSRX(1);
TalonSRX frontLeft = new TalonSRX(2);
TalonSRX rearLeft = new TalonSRX(3);

//Since FlashLib wasn't specifically built for FRC,//MecanumDrive cannot receive WPILib speed controller objects.
//We need to create a FlashSpeedController object to wrap the speed 
//controllers. We will use FRCSpeedControllers. This class can receive
//several speed controller objects. 
//We will create 4 wrappers: one for each controller

FRCSpeedControllers frontRightWrapper = new FRCSpeedControllers(frontRight);
FRCSpeedControllers rearRightWrapper = new FRCSpeedControllers(rearRight);
FRCSpeedControllers frontLeftWrapper = new FRCSpeedControllers(frontLeft);
FRCSpeedControllers rearLeftWrapper = new FRCSpeedControllers(rearLeft);

//Now we can create the MecanumDrive object and pass it or speed controller
//wrappers.
driveTrain = new MecanumDrive(frontRightWrapper,rearRightWrapper,frontLeftWrapper,rearLeftWrapper);

//Creating our controller for channel 0 of the DriverStation.
controller = new XBoxController(0);
  }
项目:FlashLib    文件ExampleOmniDrive.java   
protected void robotinit() {
//We need to create the speed controllers for our drive system.
//In this example,we have an omni drive with 4 motors:
//one on the right side and one on the left side (moving the robot along the Y axis)
//one on the front of the robot and one on the rear of the robot (moving the robot along the X axis)
//so we create 4 speed controller objects from WPILib. We will use the TalonSRX speed controllers.

TalonSRX front = new TalonSRX(0);
TalonSRX rear = new TalonSRX(1);
TalonSRX left = new TalonSRX(2);
TalonSRX right = new TalonSRX(3);

//Since FlashLib wasn't specifically built for FRC,//FlashDrive cannot receive WPILib speed controller objects.
//We need to create a FlashSpeedController object to wrap the speed 
//controllers. We will use FRCSpeedControllers. 
//We will create 4 wrappers: one for each side

FRCSpeedControllers frontWrapper = new FRCSpeedControllers(front);
FRCSpeedControllers rearWrapper = new FRCSpeedControllers(rear);
FRCSpeedControllers rightWrapper = new FRCSpeedControllers(right);
FRCSpeedControllers leftWrapper = new FRCSpeedControllers(left);

//Now we can create the FlashDrive object and pass it or speed controller
//wrappers.
driveTrain = new FlashDrive(rightWrapper,leftWrapper,frontWrapper,rearWrapper);

//Creating our controller for channel 0 of the DriverStation.
controller = new XBoxController(0);
  }
项目:FlashLib    文件ExampleTankDrive.java   
protected void robotinit() {
//We need to create the speed controllers for our drive system.
//In this example,we have a 4x4 tank drive,//FlashDrive cannot receive WPILib speed controller objects.
//We need to create a FlashSpeedController object to wrap the speed 
//controllers. We will use FRCSpeedControllers. This class can receive
//several speed controller objects. 
//We will create 2 wrappers: one for the left side,another for the right side

FRCSpeedControllers rightControllers = new FRCSpeedControllers(frontRight,rearRight);
FRCSpeedControllers leftControllers = new FRCSpeedControllers(frontLeft,rearLeft);

//Now we can create the FlashDrive object and pass it or speed controller
//wrappers.
driveTrain = new FlashDrive(rightControllers,leftControllers);

//Creating our controller for channel 0 of the DriverStation.
controller = new XBoxController(0);
  }
项目:swerve-code    文件Robot.java   
public void robotinit() {
    this.mod1Spin = new TalonSRX(Constants.MOD1SPIN);
    this.mod1Drive = new TalonSRX(Constants.MOD1DRIVE);
    this.spinEncoder1 = new Encoder(0,0); //Needs real values
    this.driveEncoder1 = new Encoder(0,0); //Needs real values

    this.mod2Spin = new TalonSRX(Constants.MOD2SPIN);
    this.mod2Drive = new TalonSRX(Constants.MOD2DRIVE);
    this.spinEncoder2 = new Encoder(0,0); //Needs real values
    this.driveEncoder2 = new Encoder(0,0); //Needs real values

    this.mod3Spin = new TalonSRX(Constants.MOD3SPIN);
    this.mod3Drive = new TalonSRX(Constants.MOD3DRIVE);
    this.spinEncoder3 = new Encoder(0,0); //Needs real values
    this.driveEncoder3 = new Encoder(0,0); //Needs real values

    this.mod4Spin = new TalonSRX(Constants.MOD4SPIN);
    this.mod4Drive = new TalonSRX(Constants.MOD4DRIVE);
    this.spinEncoder4 = new Encoder(0,0); //Needs real values
    this.driveEncoder4 = new Encoder(0,0); //Needs real values

    this.xBoxDrive = new Joystick(Constants.XBoxDRIVEPORT);

    this.frontLeft = new SwerveModule("frontLeft",mod1Drive,mod1Spin,spinEncoder1,driveEncoder1); // needs completion0
    this.backLeft = new SwerveModule("backLeft",mod2Drive,mod2Spin,spinEncoder2,driveEncoder2);
    this.frontRight = new SwerveModule("frontRight",mod3Drive,mod3Spin,spinEncoder3,driveEncoder3);
    this.backRight = new SwerveModule("backRight",mod4Drive,mod4Spin,spinEncoder4,driveEncoder4);

    this.swerveDrive = new SwerveDrive(this.frontLeft,this.backLeft,this.frontRight,this.backRight,25,25);

    crab = new CrabDrive(swerveDrive,xBoxDrive,"crabDrive",1);
    spin = new SpinDrive(swerveDrive,"spinDrive",2);
    unicorn = new UnicornDrive(swerveDrive,"unicornDrive",3);
    drive = new DriveBase(crab,spin,unicorn,"driveBase",0);
    drive.init();
}
项目:Stronghold2016-340    文件ClawArm.java   
public ClawArm() {
    System.out.println("Claw arm constructor method called");
    armMotor = new TalonSRX(RobotMap.ClawArmMotor);

    clawPiston = new Solenoid(RobotMap.ClawPiston);

    armAngleSensor = new AnalogPotentiometer(RobotMap.ClawArmAngleSensor,270);
    bottomSwitch = new DigitalInput(RobotMap.ClawBottomSwitch);
    topSwitch = new DigitalInput(RobotMap.ClawTopSwitch);
    System.out.println("Claw arm constructor method complete.");
}
项目:RobotControl    文件Robot.java   
/**
 * This is the initialization for all robot code
 */
public void robotinit()
{
    robotDrive = new RobotDrive(0,1);
    driveStick = new Joystick(0);

    liftServo = new TalonSRX(3);
    liftStick = new Joystick(3);

    server = CameraServer.getInstance();
       server.setQuality(50);
       server.startAutomaticCapture("cam0");
}
项目:FRC-Robotics-2016-Team-2262    文件DriveMotor.java   
public DriveMotor(int frontChannel,int backChannel) {
    front = new TalonSRX(frontChannel);
    back = new TalonSRX(backChannel);

}
项目:Stronghold2016-340    文件Drive.java   
public Drive() {
    leftDrive = new TalonSRX(RobotMap.DriveLeftMotor);
    rightDrive = new TalonSRX(RobotMap.DriveRightMotor);

    gyro = new AnalogGyro(RobotMap.DriveGyro);
}
项目:Stronghold2016-340    文件RightDrive.java   
public RightDrive() {
    rightDrive = new TalonSRX(1);
}
项目:Stronghold2016-340    文件LeftDrive.java   
public LeftDrive() {
    leftDrive = new TalonSRX(0);
}
项目:r2016    文件SpeedControllerSubsystem.java   
public SpeedControllerSubsystem(SpeedControllerSubsystemType type,final int channel) {
    switch(type) {
    case CAN_JAGUAR:
        this._controller = new CANJaguar(channel);
        break;

    case CAN_TALON:
        this._controller = new CANTalon(channel);
        break;

    case JAGUAR:
        this._controller = new Jaguar(channel);
        break;

    case SD540:
        this._controller = new SD540(channel);
        break;

    case SPARK:
        this._controller = new Spark(channel);
        break;

    case TALON:
        this._controller = new Talon(channel);
        break;

    case TALON_SRX:
        this._controller = new TalonSRX(channel);
        break;

    case VICTOR:
        this._controller = new Victor(channel);
        break;

    case VICTOR_SP:
        this._controller = new VictorSP(channel);
        break;

    default:
        break;
    }
}
项目:RecycledrushDriveTrain    文件RobotMap.java   
public static void init() {
    // BEGIN AUTOGENERATED CODE,SOURCE=ROBOTBUILDER ID=CONSTRUCTORS
    driveTrainleftFrontTalon0 = new TalonSRX(0);
    LiveWindow.addActuator("DriveTrain","leftFrontTalon0",(TalonSRX) driveTrainleftFrontTalon0);

    driveTrainleftBackTalon1 = new TalonSRX(1);
    LiveWindow.addActuator("DriveTrain","leftBackTalon1",(TalonSRX) driveTrainleftBackTalon1);

    driveTrainrightFrontTalon2 = new TalonSRX(2);
    LiveWindow.addActuator("DriveTrain","rightFrontTalon2",(TalonSRX) driveTrainrightFrontTalon2);

    driveTrainrightBackTalon3 = new TalonSRX(3);
    LiveWindow.addActuator("DriveTrain","rightBackTalon3",(TalonSRX) driveTrainrightBackTalon3);

    driveTrainRobotDrive = new RobotDrive(driveTrainleftFrontTalon0,driveTrainleftBackTalon1,driveTrainrightFrontTalon2,driveTrainrightBackTalon3);

    driveTrainRobotDrive.setSafetyEnabled(true);
    driveTrainRobotDrive.setExpiration(0.1);
    driveTrainRobotDrive.setSensitivity(0.5);
    driveTrainRobotDrive.setMaxOutput(1.0);

    driveTraingyro = new Gyro(0);
    LiveWindow.addSensor("DriveTrain","gyro",driveTraingyro);
    driveTraingyro.setSensitivity(0.007);
    driveTrainleftFrontEncoder = new Encoder(17,18,false,EncodingType.k4X);
    LiveWindow.addSensor("DriveTrain","leftFrontEncoder",driveTrainleftFrontEncoder);
    driveTrainleftFrontEncoder.setdistancePerpulse(1.0);
    driveTrainleftFrontEncoder.setPIDSourceParameter(PIDSourceParameter.kRate);
    driveTrainleftBackEncoder = new Encoder(19,20,"leftBackEncoder",driveTrainleftBackEncoder);
    driveTrainleftBackEncoder.setdistancePerpulse(1.0);
    driveTrainleftBackEncoder.setPIDSourceParameter(PIDSourceParameter.kRate);
    driveTrainrightFrontEncoder = new Encoder(21,22,"rightFrontEncoder",driveTrainrightFrontEncoder);
    driveTrainrightFrontEncoder.setdistancePerpulse(1.0);
    driveTrainrightFrontEncoder.setPIDSourceParameter(PIDSourceParameter.kRate);
    driveTrainrightBackEncoder = new Encoder(23,24,"rightBackEncoder",driveTrainrightBackEncoder);
    driveTrainrightBackEncoder.setdistancePerpulse(1.0);
    driveTrainrightBackEncoder.setPIDSourceParameter(PIDSourceParameter.kRate);

// END AUTOGENERATED CODE,SOURCE=ROBOTBUILDER ID=CONSTRUCTORS
}
项目:turtleshell    文件TurtleTalonSRXPWM.java   
public TurtleTalonSRXPWM(int port,boolean isReversed) {
    v = new TalonSRX(port);
    this.isReversed = isReversed;
}
项目:2015-beaker-Competition    文件RobotMap.java   
public static void init() {

        driveTrainPWM0 = new TalonSRX(0);
        LiveWindow.addActuator("DriveTrain","PWM0",(TalonSRX) driveTrainPWM0);

        driveTrainPWM9 = new TalonSRX(9);
        LiveWindow.addActuator("DriveTrain","PWM9",(TalonSRX) driveTrainPWM9);

        driveTrainRobotDrive = new RobotDrive(driveTrainPWM0,driveTrainPWM9);

        driveTrainRobotDrive.setSafetyEnabled(true);
        driveTrainRobotDrive.setExpiration(0.1);
        driveTrainRobotDrive.setSensitivity(0.5);
        driveTrainRobotDrive.setMaxOutput(1.0);

        intakePWM4 = new TalonSRX(4);
        LiveWindow.addActuator("Intake","PWM4",(TalonSRX) intakePWM4);

        intakePWM5 = new TalonSRX(5);
        LiveWindow.addActuator("Intake","PWM5",(TalonSRX) intakePWM5);

        elevatorPWM3 = new TalonSRX(3);
        LiveWindow.addActuator("Elevator","PWM3",(TalonSRX) elevatorPWM3);

        elevatorPWM6 = new TalonSRX(6);
        LiveWindow.addActuator("Elevator","PWM6",(TalonSRX) elevatorPWM6);

        armPWM2 = new TalonSRX(2);
        LiveWindow.addActuator("Arm","PWM2",(TalonSRX) armPWM2);

    }

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。