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)); }
/** * Constructor for RobotDrive with 4 motors specified with channel numbers. * Set up parameters for a four wheel drive system where all four motor pwm * channels are specified in the call. This call assumes Jaguars for * controlling the motors. * * @param frontLeftMotor Front left motor channel number on the default * digital module * @param rearLeftMotor Rear Left motor channel number on the default * digital module * @param frontRightMotor Front right motor channel number on the default * digital module * @param rearRightMotor Rear Right motor channel number on the default * digital module * @param middleLeftMotor third left motor PWM channel number * @param middleRightMotor third right motor PWM channel number */ public RobotDrive6(final int frontLeftMotor, final int rearLeftMotor, final int frontRightMotor, final int rearRightMotor, final int middleLeftMotor, final int middleRightMotor) { m_sensitivity = kDefaultSensitivity; m_maxOutput = kDefaultMaxOutput; m_rearLeftMotor = new Jaguar(rearLeftMotor); m_rearRightMotor = new Jaguar(rearRightMotor); m_frontLeftMotor = new Jaguar(frontLeftMotor); m_frontRightMotor = new Jaguar(frontRightMotor); m_middleLeftMotor = new Jaguar(middleLeftMotor); m_middleRightMotor = new Jaguar(middleRightMotor); for (int i = 0; i < kMaxNumberOfMotors; i++) { m_invertedMotors[i] = 1; } m_allocatedSpeedControllers = true; setupMotorSafety(); drive(0, 0); }
public DrivePart(BotRunner runner){ super(runner); bot = runner; shotRange = 90; highRange = 60; lowRange = 30; autoTime = new Timer(); frontRight = new Jaguar(1); frontLeft = new Jaguar(2); backRight = new Jaguar(3); backLeft = new Jaguar(4); roboDrive = new RobotDrive(frontLeft, backLeft, frontRight, backRight); roboDrive.setInvertedMotor(RobotDrive.MotorType.kRearRight, true); roboDrive.setInvertedMotor(RobotDrive.MotorType.kFrontLeft, true); }
/** * Constructor for RobotDrive with 4 motors specified with channel numbers. * Set up parameters for a four wheel drive system where all four motor pwm * channels are specified in the call. This call assumes Jaguars for * controlling the motors. * * @param frontLeftMotor Front left motor channel number on the default * digital module * @param rearLeftMotor Rear Left motor channel number on the default * digital module * @param frontRightMotor Front right motor channel number on the default * digital module * @param rearRightMotor Rear Right motor channel number on the default * digital module */ public RobotDriveSteering(final int frontLeftMotor, final int rearLeftMotor, final int frontRightMotor, final int rearRightMotor) { m_sensitivity = kDefaultSensitivity; m_maxOutput = kDefaultMaxOutput; m_rearLeftMotor = new Jaguar(rearLeftMotor); m_rearRightMotor = new Jaguar(rearRightMotor); m_frontLeftMotor = new Jaguar(frontLeftMotor); m_frontRightMotor = new Jaguar(frontRightMotor); for (int i = 0; i < kMaxNumberOfMotors; i++) { m_invertedMotors[i] = 1; } m_allocatedSpeedControllers = true; setupMotorSafety(); drive(0, 0); }
/** * Instantiates a new robot output. */ private RobotOutput() { this.forces = ChiliFunctions.fillArrayWithZeros(this.forces); front_left = new Talon(ChiliConstants.front_left_motor); rear_left = new Talon(ChiliConstants.rear_left_motor); front_right = new Talon(ChiliConstants.front_right_motor); rear_right = new Talon(ChiliConstants.rear_right_motor); left_lifter = new Jaguar(ChiliConstants.left_lifter_motor); right_lifter = new Jaguar(ChiliConstants.right_lifter_motor); //Sensor object for some cheating. //Objecto de sensor. "Trampa" para obtener ciertos valores. sensor = SensorInput.getInstance(); /*front_left.setSafetyEnabled(true); rear_left.setSafetyEnabled(true); front_right.setSafetyEnabled(true); rear_right.setSafetyEnabled(true); left_lifter.setSafetyEnabled(true); right_lifter.setSafetyEnabled(true);*/ }
public BTMotor(int port, boolean isCan) { isCANBus = isCan; if (isCANBus) { //int maxTries = 0; //while(CANMotor == null && maxTries < 10) //{ try{ CANMotor = new CANJaguar(port); } catch(Exception CANTimeoutException){ Log.log("Error initialising CANJaguar"); } //} //if (maxTries >= 10) //Log.log("CANJaguar(" + port + ") failed to initialize."); } else { PWMMotor = new Jaguar(port); } }
public void instanciate(int port, boolean isCan, boolean isVoltage) { isCANBus = isCan; portNum = port; voltage = isVoltage; if (isCANBus) { try{ CANMotor = new CANJaguar(port); if (isVoltage) { setVoltageControlMode(); } successJag = true; } catch(Exception CANTimeoutException){ System.out.println("Error initialising CANJaguar at port: " +port); } } else { PWMMotor = new Jaguar(port); } }
/** * This function is run when the robot is first started up and should be * used for any initialization code. */ public void robotInit() { // PWM's mTestMotor1 = new Talon(0); mTestMotor2 = new Jaguar(1); mServo = new Servo(2); // Digital IO mDigitalOutput = new DigitalOutput(0); mRightEncoder = new Encoder(4, 5); mLeftEncoder = new Encoder(1, 2); mUltrasonic = new Ultrasonic(7, 6); // Analog IO mAnalogGryo = new AnalogGyro(0); mPotentiometer = new AnalogPotentiometer(1); // Solenoid mSolenoid = new Solenoid(0); // Relay mRelay = new Relay(0); // Joysticks mJoystick1 = new Joystick(0); mJoystick2 = new XboxController(1); // SPI mSpiGryo = new ADXRS450_Gyro(); // Utilities mTimer = new Timer(); mPDP = new PowerDistributionPanel(); Preferences.getInstance().putDouble("Motor One Speed", .5); }
public SpeedController getController(){ if (allocated) return null; this.allocated = true; switch (this.speedControllerType){ case kJaguar: return new Jaguar(this.PWMChannel); case kTalon: return new Talon(this.PWMChannel); default: return null; } }
Manipulator() { LiftMotor = new Jaguar(ELEVATOR_MOTOR_PORT) { public void set(double speed) { super.set(-speed); } }; encoder = new Encoder(ENCODER_CHANNEL_A, ENCODER_CHANNEL_B); }
public Robot() { stick = new Joystick(0); try { /* Construct Digital I/O Objects */ pwm_out_9 = new Victor( getChannelFromPin( PinType.PWM, 9 )); pwm_out_8 = new Jaguar( getChannelFromPin( PinType.PWM, 8 )); dig_in_7 = new DigitalInput( getChannelFromPin( PinType.DigitalIO, 7 )); dig_in_6 = new DigitalInput( getChannelFromPin( PinType.DigitalIO, 6 )); dig_out_5 = new DigitalOutput( getChannelFromPin( PinType.DigitalIO, 5 )); dig_out_4 = new DigitalOutput( getChannelFromPin( PinType.DigitalIO, 4 )); enc_3and2 = new Encoder( getChannelFromPin( PinType.DigitalIO, 3 ), getChannelFromPin( PinType.DigitalIO, 2 )); enc_1and0 = new Encoder( getChannelFromPin( PinType.DigitalIO, 1 ), getChannelFromPin( PinType.DigitalIO, 0 )); /* Construct Analog I/O Objects */ /* NOTE: Due to a board layout issue on the navX MXP board revision */ /* 3.3, there is noticeable crosstalk between AN IN pins 3, 2 and 1. */ /* For that reason, use of pin 3 and pin 2 is NOT RECOMMENDED. */ an_in_1 = new AnalogInput( getChannelFromPin( PinType.AnalogIn, 1 )); an_trig_0 = new AnalogTrigger( getChannelFromPin( PinType.AnalogIn, 0 )); an_trig_0_counter = new Counter( an_trig_0 ); an_out_1 = new AnalogOutput( getChannelFromPin( PinType.AnalogOut, 1 )); an_out_0 = new AnalogOutput( getChannelFromPin( PinType.AnalogOut, 0 )); /* Configure I/O Objects */ pwm_out_9.setSafetyEnabled(false); /* Disable Motor Safety for Demo */ pwm_out_8.setSafetyEnabled(false); /* Disable Motor Safety for Demo */ /* Configure Analog Trigger */ an_trig_0.setAveraged(true); an_trig_0.setLimitsVoltage(MIN_AN_TRIGGER_VOLTAGE, MAX_AN_TRIGGER_VOLTAGE); } catch (RuntimeException ex ) { DriverStation.reportError( "Error instantiating MXP pin on navX MXP: " + ex.getMessage(), true); } }
public Robot() { myRobot = new RobotDrive(RobotMap.FRONT_LEFT_MOTOR, RobotMap.REAR_LEFT_MOTOR, RobotMap.FRONT_RIGHT_MOTOR, RobotMap.REAR_RIGHT_MOTOR); myRobot.setExpiration(0.1); stick = new Joystick(RobotMap.JOYSTICK_PORT1); compressor = new Compressor(); solenoid = new DoubleSolenoid(RobotMap.SOLENOID_PCM_PORT1, RobotMap.SOLENOID_PCM_PORT2); jaguar = new Jaguar(RobotMap.LIFT_MOTOR); }
public void init(Environment env) { inputMethod = env.getInput(); speedController = new MultiMotor(new SpeedController[]{new Jaguar(RobotMap.SHOOTER_MOTOR_1),new Jaguar(RobotMap.SHOOTER_MOTOR_2)}); speedController.set(0); solenoid = new Solenoid(RobotMap.SHOOTER_SOLENOID); }
public void init(Environment environment) { shooter = environment.getShooterSystem(); motorController = new Jaguar(RobotMap.INTAKE_MOTOR_CONTROLLER); intakeLift = new Relay(RobotMap.INTAKE_LIFT_1); intakeLift2 = new Relay(RobotMap.INTAKE_LIFT_2); close(); inputMethod = environment.getInput(); }
public Drive() { super(); jFL = new Jaguar(RobotMap.MECANUM_FRONT_LEFT); jBL = new Jaguar(RobotMap.MECANUM_BACK_LEFT); jFR = new Jaguar(RobotMap.MECANUM_FRONT_RIGHT); jBR = new Jaguar(RobotMap.MECANUM_BACK_RIGHT); drive = new RobotDrive(jFL, jBL, jFR, jBR); }
/** * Constructor for RobotDrive with 2 motors specified with channel numbers. * Set up parameters for a two wheel drive system where the left and right * motor pwm channels are specified in the call. This call assumes Jaguars * for controlling the motors. * * @param leftMotorChannel The PWM channel number on the default digital * module that drives the left motor. * @param rightMotorChannel The PWM channel number on the default digital * module that drives the right motor. */ public RobotDriveSteering(final int leftMotorChannel, final int rightMotorChannel) { m_sensitivity = kDefaultSensitivity; m_maxOutput = kDefaultMaxOutput; m_frontLeftMotor = null; m_rearLeftMotor = new Jaguar(leftMotorChannel); m_frontRightMotor = null; m_rearRightMotor = new Jaguar(rightMotorChannel); for (int i = 0; i < kMaxNumberOfMotors; i++) { m_invertedMotors[i] = 1; } m_allocatedSpeedControllers = true; setupMotorSafety(); drive(0, 0); }
public BTJaguar(int port, BTDebugger debug) { jag = new Jaguar(port); val = 0; motorG = new BTStatGroup("MotorGroup "+port); debugSpeed = motorG.newNumStat("DEBUG: BTJaguar: Port: "+port+" ", 0, Constants.DEBUGMODE); }
public TitanSpeedController create(int pChannel, Class<?> pClass, Switch pForwardLimitSwitch, Switch pReverseLimitSwitch, boolean pInvertDirection) { TitanSpeedController controller; if (pClass.equals(Talon.class)) { controller = new TitanSpeedController(new Talon(pChannel), pForwardLimitSwitch, pReverseLimitSwitch, pInvertDirection); } else if (pClass.equals(Victor.class)) { controller = new TitanSpeedController(new Victor(pChannel), pForwardLimitSwitch, pReverseLimitSwitch, pInvertDirection); } else { controller = new TitanSpeedController(new Jaguar(pChannel), pForwardLimitSwitch, pReverseLimitSwitch, pInvertDirection); } return controller; }
public TitanSpeedController create(int pChannel, Class pClass, Switch pForwardLimitSwitch, Switch pReverseLimitSwitch, boolean pInvertDirection) { TitanSpeedController controller; if (pClass.equals(Talon.class)) { controller = new TitanSpeedController(new Talon(pChannel), pForwardLimitSwitch, pReverseLimitSwitch, pInvertDirection); } else if (pClass.equals(Victor.class)) { controller = new TitanSpeedController(new Victor(pChannel), pForwardLimitSwitch, pReverseLimitSwitch, pInvertDirection); } else { controller = new TitanSpeedController(new Jaguar(pChannel), pForwardLimitSwitch, pReverseLimitSwitch, pInvertDirection); } return controller; }
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); }
public DriveTrain() { // Set up the motors ... this.leftMotor = new Jaguar(Robot.KickMotors.LEFT_PORT); this.rightMotor = new Jaguar(Robot.KickMotors.RIGHT_PORT); // And the drive controller ... drive = new RobotDrive(leftMotor, rightMotor); drive.setInvertedMotor(Robot.KickMotors.LEFT_POSITION, Robot.KickMotors.LEFT_REVERSED); drive.setInvertedMotor(Robot.KickMotors.RIGHT_POSITION, Robot.KickMotors.RIGHT_REVERSED); drive.setSafetyEnabled(false); setMaxDriveSpeed(Robot.KickMotors.INITIAL_MAX_KICK_SPEED); }
public Drive () { jaguar_lf = new Jaguar(JAGUAR_LF); jaguar_rf = new Jaguar(JAGUAR_RF); jaguar_lr = new Jaguar(JAGUAR_LR); jaguar_rr = new Jaguar(JAGUAR_RR); joystick = new Joystick (JOYSTICK_ID); }
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."); }
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."); }
private Climber() { climberController = new Jaguar(BadRobotMap.climberArticulator); encoder = new Encoder(BadRobotMap.climberEncoderIn, BadRobotMap.climberEncoderOut, true); encoder.start(); //controller = new EasyPID(.01, 0.0, 0.0, 0.0, "Climber Controller", encoder); //controller.controller.enable(); //controller.setAbsoluteTolerance(8); //controller.enable(); }
private SpeedController createMultiplexedJaguar(int id, int idMini){ Jaguar[] jaguars = new Jaguar[2]; jaguars[0] = new Jaguar(id); jaguars[1] = new Jaguar(idMini); SpeedControllerMultiplexer scMultiplexer = new SpeedControllerMultiplexer(jaguars); return scMultiplexer; }
public Elevator() { super("Elevator", Kp, Ki, Kd); motor = new Jaguar(RobotMap.elevatorMotor); pot = new AnalogChannel(RobotMap.elevatorPot); // Set default position and start PID setSetpoint(STOW); enable(); }
void init() { A = new Victor(RobotMap.Apin); B = new Victor(RobotMap.Bpin); C = new Victor(RobotMap.Cpin); climb = new Victor(RobotMap.climbpin); climbasst = new Jaguar(RobotMap.climbasstpin); shootwheel = new Jaguar(RobotMap.wheelpin); shoottilt = new Jaguar(RobotMap.tiltpin); push = new Relay(RobotMap.pushpin); push.setDirection(Relay.Direction.kBoth); }
public Drive(UltimateAscentRobot robot){ super(robot); leftMotor = new Jaguar(1); //PWM 1 rightMotor = new Jaguar(2); //PWM 2 drive = new RobotDrive(leftMotor,rightMotor); //compressor = new Relay(1); //compressor.setDirection(Relay.Direction.kForward); }
public MecanumDrive(){ motor1 = new Jaguar(RobotMap.DSC_SLOT, RobotMap.DRIVE_MOTOR_1); motor2 = new Jaguar(RobotMap.DSC_SLOT, RobotMap.DRIVE_MOTOR_2); motor3 = new Jaguar(RobotMap.DSC_SLOT, RobotMap.DRIVE_MOTOR_3); motor4 = new Jaguar(RobotMap.DSC_SLOT, RobotMap.DRIVE_MOTOR_4); }
public Canon(ReserveBallon reserve) { mReserve = reserve; mjControl = JoystickDevice.GetCoPilot(); mjAngleDeTir = new Jaguar(PwmDevice.mCanonAngleDeTir); mfAngleDeTir = new FiltrePasseBas(25); mjOrientationDeTir = new Jaguar(PwmDevice.mCanonOrientationDeTir); mfOrientationDeTir = new FiltrePasseBas(25); msTir = new Solenoid(SolenoidDevice.mCanonTir); msTirRev = new Solenoid(SolenoidDevice.mCanonTirRev); mdLimiteRotationGauche = new DigitalInput(DigitalDevice.mCanonLimiteRotationGauche); mdLimiteRotationDroite = new DigitalInput(DigitalDevice.mCanonLimiteRotationDroite); mjCanonHaut = new Jaguar(PwmDevice.mCanonMoteurHaut); mfCanonHaut = new FiltrePasseBas(25); macCanonHaut = new AnalogChannel(AnalogDevice.mCanonMoteurHaut); mpidCanonHaut = new PIDController(Kp,Ki, Kd, macCanonHaut, mjCanonHaut); mpidCanonHaut.setInputRange(0.0, 4095.0); mpidCanonHaut.setOutputRange(-1.0, 1.0); mjCanonBas = new Jaguar(PwmDevice.mCanonMoteurBas); mfCanonBas = new FiltrePasseBas(25); macCanonBas = new AnalogChannel(AnalogDevice.mCanonMoteurBas); mpidCanonBas = new PIDController(Kp,Ki, Kd, macCanonBas, mjCanonBas); mpidCanonBas.setInputRange(0.0, 4095.0); mpidCanonBas.setOutputRange(-1.0, 1.0); mRangeFinder = new RangeFinder(5); maAngle = new ADXL345_I2C(1, ADXL345_I2C.DataFormat_Range.k8G); maRef = new ADXL345_I2C(1, ADXL345_I2C.DataFormat_Range.k8G); msTir.set(false); msTirRev.set(true); }
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; } }
public Grabber() { super(); jGrab = new Jaguar(RobotMap.SPINNING_BALL_GRABBER_PORT); jGrab.set(0.0); }
protected Jaguar leftMotor() { return (Jaguar)leftMotor; }
protected Jaguar rightMotor() { return (Jaguar)rightMotor; }
public Shooting() { arm = new Relay(1); flyWheel = new Jaguar(10); tripWire = new DigitalInput(2); }
public void init() { controller = new XboxController(1); motor1 = new Jaguar(6); }
public static void init() { //initialize encoders frontWheelEncoder = new Encoder(1, 1, 1, 2, false, CounterBase.EncodingType.k2X); frontWheelEncoder.setDistancePerPulse(WHEEL_ENCODER_DISTANCE_PER_TICK); frontWheelEncoder.setPIDSourceParameter(PIDSource.PIDSourceParameter.kRate); // have encoder measure rate, not distance frontWheelEncoder.start(); LiveWindow.addSensor("Drivetrain", "frontWheelEncoder", frontWheelEncoder); leftWheelEncoder = new Encoder(1, 3, 1, 4, false, CounterBase.EncodingType.k2X); leftWheelEncoder.setDistancePerPulse(WHEEL_ENCODER_DISTANCE_PER_TICK); leftWheelEncoder.setPIDSourceParameter(PIDSource.PIDSourceParameter.kRate); // have encoder measure rate, not distance leftWheelEncoder.start(); LiveWindow.addSensor("Drivetrain", "leftWheelEncoder", leftWheelEncoder); backWheelEncoder = new Encoder(1, 5, 1, 6, false, CounterBase.EncodingType.k2X); backWheelEncoder.setDistancePerPulse(WHEEL_ENCODER_DISTANCE_PER_TICK); backWheelEncoder.setPIDSourceParameter(PIDSource.PIDSourceParameter.kRate); // have encoder measure rate, not distance backWheelEncoder.start(); LiveWindow.addSensor("Drivetrain", "backWheelEncoder", backWheelEncoder); rightWheelEncoder = new Encoder(1, 7, 1, 8, false, CounterBase.EncodingType.k2X); rightWheelEncoder.setDistancePerPulse(WHEEL_ENCODER_DISTANCE_PER_TICK); rightWheelEncoder.setPIDSourceParameter(PIDSource.PIDSourceParameter.kRate); // have encoder measure rate, not distance rightWheelEncoder.start(); LiveWindow.addSensor("Drivetrain", "rightWheelEncoder", rightWheelEncoder); frontModuleEncoder = new Encoder(2, 1, 2, 2, false, CounterBase.EncodingType.k2X); frontModuleEncoder.setDistancePerPulse(MODULE_ENCODER_DISTANCE_PER_TICK); frontModuleEncoder.setPIDSourceParameter(PIDSource.PIDSourceParameter.kDistance); // have encoder measure rate, not distance frontModuleEncoder.start(); LiveWindow.addSensor("Drivetrain", "frontModuleEncoder", frontModuleEncoder); leftModuleEncoder = new Encoder(2, 7, 2, 8, false, CounterBase.EncodingType.k2X); leftModuleEncoder.setDistancePerPulse(MODULE_ENCODER_DISTANCE_PER_TICK); leftModuleEncoder.setPIDSourceParameter(PIDSource.PIDSourceParameter.kDistance); // have encoder measure rate, not distance leftModuleEncoder.start(); LiveWindow.addSensor("Drivetrain", "leftModuleEncoder", leftModuleEncoder); backModuleEncoder = new Encoder(2, 5, 2, 6, false, CounterBase.EncodingType.k2X); backModuleEncoder.setDistancePerPulse(MODULE_ENCODER_DISTANCE_PER_TICK); backModuleEncoder.setPIDSourceParameter(PIDSource.PIDSourceParameter.kDistance); // have encoder measure rate, not distance backModuleEncoder.start(); LiveWindow.addSensor("Drivetrain", "backModuleEncoder", backModuleEncoder); rightModuleEncoder = new Encoder(2, 3, 2, 4, false, CounterBase.EncodingType.k2X); rightModuleEncoder.setDistancePerPulse(MODULE_ENCODER_DISTANCE_PER_TICK); rightModuleEncoder.setPIDSourceParameter(PIDSource.PIDSourceParameter.kDistance); // have encoder measure rate, not distance rightModuleEncoder.start(); LiveWindow.addSensor("Drivetrain", "rightModuleEncoder", rightModuleEncoder); //initialize motors frontWheelMotor = new Victor246(1,1); LiveWindow.addActuator("Drivetrain", "frontWheelMotor", (Victor) frontWheelMotor); leftWheelMotor = new Victor246(1,2); LiveWindow.addActuator("Drivetrain", "leftWheelMotor", (Victor) leftWheelMotor); backWheelMotor = new Victor246(1,3); LiveWindow.addActuator("Drivetrain", "backWheelMotor", (Victor) backWheelMotor); rightWheelMotor = new Victor246(1,4); LiveWindow.addActuator("Drivetrain", "rightWheelMotor", (Victor) rightWheelMotor); frontModuleMotor = new Jaguar246(2,1); LiveWindow.addActuator("Drivetrain", "frontModuleMotor", (Jaguar) frontModuleMotor); leftModuleMotor = new Jaguar246(2,2); LiveWindow.addActuator("Drivetrain", "leftModuleMotor", (Jaguar) leftModuleMotor); backModuleMotor = new Jaguar246(2,3); LiveWindow.addActuator("Drivetrain", "backModuleMotor", (Jaguar) backModuleMotor); rightModuleMotor = new Jaguar246(2,4); LiveWindow.addActuator("Drivetrain", "rightModuleMotor", (Jaguar) rightModuleMotor); //initialize limit switch angleZeroingButton = new DigitalInput(1,9); LiveWindow.addSensor("Drivetrain", "encoderZeroingSwitch", angleZeroingButton); }
/** * This function is run when the robot is first started up and should be * used for any initialization code. */ public void robotInit() { joystick = new TPAJoystick(RobotMap.JOYSTICK_ONE_PORT); jaguar = new Jaguar(RobotMap.MOTOR_PORT); }