本文整理汇总了Java中edu.wpi.first.wpilibj.RobotDrive.MotorType类的典型用法代码示例。如果您正苦于以下问题:Java MotorType类的具体用法?Java MotorType怎么用?Java MotorType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MotorType类属于edu.wpi.first.wpilibj.RobotDrive包,在下文中一共展示了MotorType类的16个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: initTalonConfig
import edu.wpi.first.wpilibj.RobotDrive.MotorType; //导入依赖的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
示例2: initDefaultCommand
import edu.wpi.first.wpilibj.RobotDrive.MotorType; //导入依赖的package包/类
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);
}
开发者ID:frc3946,项目名称:Stronghold,代码行数:10,代码来源:Drivetrain.java
示例3: Robot
import edu.wpi.first.wpilibj.RobotDrive.MotorType; //导入依赖的package包/类
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);
}
开发者ID:wjaneal,项目名称:liastem,代码行数:11,代码来源:Robot.java
示例4: initialize
import edu.wpi.first.wpilibj.RobotDrive.MotorType; //导入依赖的package包/类
@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);
}
开发者ID:TechnoWolves5518,项目名称:2015RobotCode,代码行数:13,代码来源:DriveTrain.java
示例5: initialize
import edu.wpi.first.wpilibj.RobotDrive.MotorType; //导入依赖的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
示例6: initialize
import edu.wpi.first.wpilibj.RobotDrive.MotorType; //导入依赖的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
示例7: initialize
import edu.wpi.first.wpilibj.RobotDrive.MotorType; //导入依赖的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
示例8: initialize
import edu.wpi.first.wpilibj.RobotDrive.MotorType; //导入依赖的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
示例9: Chassis
import edu.wpi.first.wpilibj.RobotDrive.MotorType; //导入依赖的package包/类
/** 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);
}
开发者ID:Team-4153,项目名称:mecanumCommand,代码行数:35,代码来源:Chassis.java
示例10: getTalon
import edu.wpi.first.wpilibj.RobotDrive.MotorType; //导入依赖的package包/类
public CANTalon getTalon(MotorType mtype) {
return talons[mtype.value];
}
开发者ID:frc2879,项目名称:2017-newcomen,代码行数:4,代码来源:Drivetrain.java
示例11: mecanumSpeeds_Cartesian
import edu.wpi.first.wpilibj.RobotDrive.MotorType; //导入依赖的package包/类
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;
}
开发者ID:frc2879,项目名称:2017-newcomen,代码行数:50,代码来源:Drivetrain.java
示例12: setTalons
import edu.wpi.first.wpilibj.RobotDrive.MotorType; //导入依赖的package包/类
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]);
}
开发者ID:frc2879,项目名称:2017-newcomen,代码行数:7,代码来源:Drivetrain.java
示例13: ReverseDrive
import edu.wpi.first.wpilibj.RobotDrive.MotorType; //导入依赖的package包/类
public void ReverseDrive(){
robotDrive.setInvertedMotor(MotorType.kFrontLeft, true);
robotDrive.setInvertedMotor(MotorType.kFrontRight, true);
robotDrive.setInvertedMotor(MotorType.kRearLeft, true);
robotDrive.setInvertedMotor(MotorType.kRearRight, true);
}
开发者ID:frc3946,项目名称:Stronghold,代码行数:7,代码来源:Drivetrain.java
示例14: ForwardDrive
import edu.wpi.first.wpilibj.RobotDrive.MotorType; //导入依赖的package包/类
public void ForwardDrive(){
robotDrive.setInvertedMotor(MotorType.kFrontLeft, false);
robotDrive.setInvertedMotor(MotorType.kFrontRight, false);
robotDrive.setInvertedMotor(MotorType.kRearRight, false);
robotDrive.setInvertedMotor(MotorType.kRearLeft, false);
}
开发者ID:frc3946,项目名称:Stronghold,代码行数:7,代码来源:Drivetrain.java
示例15: Drive
import edu.wpi.first.wpilibj.RobotDrive.MotorType; //导入依赖的package包/类
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);
}
开发者ID:chopshop-166,项目名称:frc-2015,代码行数:59,代码来源:Drive.java
示例16: Chassis
import edu.wpi.first.wpilibj.RobotDrive.MotorType; //导入依赖的package包/类
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);
}
开发者ID:2141-Spartonics,项目名称:Spartonics-Code,代码行数:11,代码来源:Chassis.java
注:本文中的edu.wpi.first.wpilibj.RobotDrive.MotorType类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论