Java 类edu.wpi.first.wpilibj.RobotDrive.MotorType 实例源码

项目:2017-newcomen    文件:Drivetrain.java   
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);
    }
项目:Stronghold    文件:Drivetrain.java   
public void initDefaultCommand() {
    setDefaultCommand(new TankDrive());
    robotDrive.setInvertedMotor(MotorType.kFrontLeft, true);
    robotDrive.setInvertedMotor(MotorType.kRearLeft, true);
    LiveWindow.addActuator("Drive Motors", "fRight", fRight);
    LiveWindow.addActuator("Drive Motors", "fLeft", fLeft);
    LiveWindow.addActuator("Drive Motors", "bRight", bRight);
    LiveWindow.addActuator("Drive Motors", "bLeft", bLeft);
}
项目:liastem    文件:Robot.java   
public Robot() {
    //make objects for drive train, joystick, and gyro
    myRobot = new RobotDrive(new CANTalon(leftMotorChannel), new CANTalon(leftRearMotorChannel),
      new CANTalon(rightMotorChannel), new CANTalon(rightRearMotorChannel));
    myRobot.setInvertedMotor(MotorType.kFrontLeft, true); // invert the left side motors
    myRobot.setInvertedMotor(MotorType.kRearLeft, true); // you may need to change or remove this to match your robot

    joystick = new Joystick(0);
    gyro = new AnalogGyro(gyroChannel);
}
项目:2015RobotCode    文件:DriveTrain.java   
@Override
public void initialize() {
    m_robot = new RobotDrive(RobotMap.FRONT_LEFT_MOTOR, RobotMap.REAR_LEFT_MOTOR,
            RobotMap.FRONT_RIGHT_MOTOR, RobotMap.REAR_RIGHT_MOTOR);
    m_robot.setExpiration(RobotDrive.kDefaultExpirationTime);  // set expiration time for motor movement if error occurs
    m_robot.setSafetyEnabled(true);  // enable safety so motors don't burn out
    m_robot.setInvertedMotor(MotorType.kFrontRight, true);
    //m_robot.setInvertedMotor(MotorType.kFrontLeft, true);
    m_robot.setInvertedMotor(MotorType.kRearRight, true);
    //m_robot.setInvertedMotor(MotorType.kRearLeft, true);

}
项目:FRC-2015-Robot-Java    文件:RobotHardwareMecbot.java   
@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);
}
项目:FRC-2015-Robot-Java    文件:RobotHardwareWoodbot.java   
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);
}
项目:FRC-2015-Robot-Java    文件:RobotHardwareCompbot.java   
@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);
}
项目:FRC-2015-Robot-Java    文件:RobotHardwarePracticebot.java   
@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);
}
项目:mecanumCommand    文件:Chassis.java   
/**  The control mode needs to be set in the constructor for the speed mode to work:
     *  http://www.chiefdelphi.com/forums/showthread.php?t=89721
     * 
     * Setting the "changeControlMode" after the constructor does not seem to work.
     * 
     */
    public Chassis() {
        try {
            System.out.println("Chassis Construtor started");
            rightFront = new CANJaguar(RobotMap.JAG_RIGHT_FRONT_MOTOR, CANJaguar.ControlMode.kSpeed);
            configSpeedControl(rightFront);
            System.out.println("JAG Right Front works, " + RobotMap.JAG_RIGHT_FRONT_MOTOR);
            rightRear = new CANJaguar(RobotMap.JAG_RIGHT_REAR_MOTOR, CANJaguar.ControlMode.kSpeed);
            configSpeedControl(rightRear);
            System.out.println("JAG Right Back works, " + RobotMap.JAG_RIGHT_REAR_MOTOR);
            leftFront = new CANJaguar(RobotMap.JAG_LEFT_FRONT_MOTOR, CANJaguar.ControlMode.kSpeed);
            configSpeedControl(leftFront);
            System.out.println("JAG Left Front works, " + RobotMap.JAG_LEFT_FRONT_MOTOR);
            leftRear = new CANJaguar(RobotMap.JAG_LEFT_REAR_MOTOR, CANJaguar.ControlMode.kSpeed);
            configSpeedControl(leftRear);
            System.out.println("JAG Left Back works, " + RobotMap.JAG_LEFT_REAR_MOTOR);

        } catch (CANTimeoutException ex) {
            System.out.println("Chassis constructor CANTimeoutException: ");
            ex.printStackTrace();
            //System.exit(-1);
        }

        drive = new RobotDrive(leftFront, leftRear, rightFront, rightRear);
        drive.setInvertedMotor(MotorType.kFrontLeft, true);//Left front motor normally opposite
        drive.setMaxOutput(2);//TODO: Fix the magic numbers
//  drive = new RobotDrive(leftRear, leftRear, leftRear, leftRear);
        drive.setSafetyEnabled(false);
    }
项目:2017-newcomen    文件:Drivetrain.java   
public CANTalon getTalon(MotorType mtype) {
    return talons[mtype.value];
}
项目:2017-newcomen    文件:Drivetrain.java   
public double[] mecanumSpeeds_Cartesian(double x, double y, double rotation) {
    double[] wheelSpeeds = new double[4];
    double k1, k2, k3, k4, 
    pr, // primary rotation
    // wheel positions relative to center of mass:
    x1 = -11.25, 
    y1 = 6.75,
    x2 = 11.25, 
    y2 = y1,
    x3 = x1, 
    y3 = -7.25, 
    x4 = x2, 
    y4 = y3,
    rotationRatio, maxRotVel, rr, multiplier = 1;
    // split motion into other axes,
    k1 = (x + y);
    k2 = (-x + y);
    k3 = (-x + y);
    k4 = (x + y);
    rotationRatio = -y1 / y4;
    maxRotVel = (x1 - y1 - x2 - y2 + x3 + y3 + x4 - y4);
    // scaled primary rotation (pr) (pos. is counter clock)
    pr = (k1 * (x1 - y1) + (k2 * (x2 + y2)) + (k3 * (x3 + y3)) + (k4 * (x4 - y4))) / maxRotVel;
    // scaled additional required rotation
    rr = pr + rotation;

    if (Math.abs((x + y + (rotationRatio * rr))) > 1) {
        multiplier /= (x + y + (rotationRatio * rr));
    }
    if (Math.abs((-x + y - rr) * multiplier) > 1) {
        multiplier /= (-x + y - rr);
    }
    if (Math.abs((-x + y + rr) * multiplier) > 1) {
        multiplier /= (-x + y + rr);
    }
    if (Math.abs((x + y - (rotationRatio * rr)) * multiplier) > 1) {
        multiplier /= (x + y - (rotationRatio * rr));
    }

    multiplier = Math.abs(multiplier);

    wheelSpeeds[MotorType.kFrontLeft.value] = (k1 + rr) * multiplier;
    wheelSpeeds[MotorType.kFrontRight.value] = (k2 - rr) * multiplier;
    wheelSpeeds[MotorType.kRearLeft.value] = (k3 + (rotationRatio * rr)) * multiplier;
    wheelSpeeds[MotorType.kRearRight.value] = (k4 - (rotationRatio * rr)) * multiplier;

    return wheelSpeeds;

}
项目:2017-newcomen    文件:Drivetrain.java   
public void setTalons(double[] values) {
    talons[MotorType.kFrontLeft.value].set(values[MotorType.kFrontLeft.value]);
    talons[MotorType.kFrontRight.value].set(values[MotorType.kFrontRight.value]);
    talons[MotorType.kRearLeft.value].set(values[MotorType.kRearLeft.value]);
    talons[MotorType.kRearRight.value].set(values[MotorType.kRearRight.value]);
}
项目:Stronghold    文件:Drivetrain.java   
public void ReverseDrive(){
    robotDrive.setInvertedMotor(MotorType.kFrontLeft, true);
    robotDrive.setInvertedMotor(MotorType.kFrontRight, true);
    robotDrive.setInvertedMotor(MotorType.kRearLeft, true);
    robotDrive.setInvertedMotor(MotorType.kRearRight, true);
}
项目:Stronghold    文件:Drivetrain.java   
public void ForwardDrive(){
    robotDrive.setInvertedMotor(MotorType.kFrontLeft, false);
    robotDrive.setInvertedMotor(MotorType.kFrontRight, false);
    robotDrive.setInvertedMotor(MotorType.kRearRight, false);
    robotDrive.setInvertedMotor(MotorType.kRearLeft, false);
}
项目:frc-2015    文件:Drive.java   
public Drive() {

        // SPEED CONTROLLER PORTS
        frontLeftTalon = new Talon(RobotMap.Pwm.FrontLeftDrive);
        rearLeftTalon = new Talon(RobotMap.Pwm.RearLeftDrive);
        frontRightTalon = new Talon(RobotMap.Pwm.FrontRightDrive);
        rearRightTalon = new Talon(RobotMap.Pwm.RearRightDrive);

        // ULTRASONIC SENSORS
        leftAngleIR = new AnalogInput(RobotMap.Analog.LeftAngleIR);
        rightAngleIR = new AnalogInput(RobotMap.Analog.RightAngleIR);

        leftCenterIR = new AnalogInput(RobotMap.Analog.LeftCenterIR);
        rightCenterIR = new AnalogInput(RobotMap.Analog.RightCenterIR);

        // YAWRATE SENSOR
        gyro = new AnalogGyro(RobotMap.Analog.Gryo);

        // ENCODER PORTS
        frontLeftEncoder = new Encoder(RobotMap.Encoders.FrontLeftDriveA, RobotMap.Encoders.FrontLeftDriveB);
        rearLeftEncoder = new Encoder(RobotMap.Encoders.RearLeftDriveA, RobotMap.Encoders.RearLeftDriveB);
        frontRightEncoder = new Encoder(RobotMap.Encoders.FrontRightDriveA, RobotMap.Encoders.FrontRightDriveB);
        rearRightEncoder = new Encoder(RobotMap.Encoders.RearRightDriveA, RobotMap.Encoders.RearRightDriveB);

        // ENCODER MATH
        frontLeftEncoder.setDistancePerPulse(DistancePerPulse);
        frontLeftEncoder.setPIDSourceType(PIDSourceType.kRate);
        frontRightEncoder.setDistancePerPulse(DistancePerPulse);
        frontRightEncoder.setPIDSourceType(PIDSourceType.kRate);
        rearLeftEncoder.setDistancePerPulse(DistancePerPulse);
        rearLeftEncoder.setPIDSourceType(PIDSourceType.kRate);
        rearRightEncoder.setDistancePerPulse(DistancePerPulse);
        rearRightEncoder.setPIDSourceType(PIDSourceType.kRate);

        // PID SPEED CONTROLLERS
        frontLeftPID = new PIDSpeedController(frontLeftEncoder, frontLeftTalon, "Drive", "Front Left");
        frontRightPID = new PIDSpeedController(frontRightEncoder, frontRightTalon, "Drive", "Front Right");
        rearLeftPID = new PIDSpeedController(rearLeftEncoder, rearLeftTalon, "Drive", "Rear Left");
        rearRightPID = new PIDSpeedController(rearRightEncoder, rearRightTalon, "Drive", "Rear Right");

        // DRIVE DECLARATION
        robotDrive = new RobotDrive(frontLeftPID, rearLeftPID, frontRightPID, rearRightPID);
        robotDrive.setExpiration(0.1);

        // MOTOR INVERSIONS
        robotDrive.setInvertedMotor(MotorType.kFrontRight, true);
        robotDrive.setInvertedMotor(MotorType.kRearRight, true);

        LiveWindow.addActuator("Drive", "Front Left Talon", frontLeftTalon);
        LiveWindow.addActuator("Drive", "Front Right Talon", frontRightTalon);
        LiveWindow.addActuator("Drive", "Rear Left Talon", rearLeftTalon);
        LiveWindow.addActuator("Drive", "Rear Right Talon", rearRightTalon);

        LiveWindow.addSensor("Drive Encoders", "Front Left Encoder", frontLeftEncoder);
        LiveWindow.addSensor("Drive Encoders", "Front Right Encoder", frontRightEncoder);
        LiveWindow.addSensor("Drive Encoders", "Rear Left Encoder", rearLeftEncoder);
        LiveWindow.addSensor("Drive Encoders", "Rear Right Encoder", rearRightEncoder);
    }
项目:Spartonics-Code    文件:Chassis.java   
public Chassis() {
    rightMotor = new Spark(4);
    leftMotor = new Spark(RobotMap.LEFT_MOTOR);
    drive = new RobotDrive(rightMotor, leftMotor);

    this.drive.setInvertedMotor(MotorType.kFrontLeft, true);
    this.drive.setInvertedMotor(MotorType.kFrontRight, true);


}