本文整理汇总了Java中edu.wpi.first.wpilibj.AnalogGyro类的典型用法代码示例。如果您正苦于以下问题:Java AnalogGyro类的具体用法?Java AnalogGyro怎么用?Java AnalogGyro使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
AnalogGyro类属于edu.wpi.first.wpilibj包,在下文中一共展示了AnalogGyro类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: DrivetrainSubsystem
import edu.wpi.first.wpilibj.AnalogGyro; //导入依赖的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);
}
示例2: robotInit
import edu.wpi.first.wpilibj.AnalogGyro; //导入依赖的package包/类
/**
* 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);
}
示例3: Drive
import edu.wpi.first.wpilibj.AnalogGyro; //导入依赖的package包/类
/**
* Code for driving robot
*/
public Drive() {
leftDrive = new Talon(RobotMap.LEFT_DRIVE_TALON);
rightDrive = new Talon(RobotMap.RIGHT_DRIVE_TALON);
PTOMotor = new Servo(RobotMap.DRIVE_PTO);
gyro = new AnalogGyro(0);
}
示例4: Robot
import edu.wpi.first.wpilibj.AnalogGyro; //导入依赖的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);
}
示例5: Robot
import edu.wpi.first.wpilibj.AnalogGyro; //导入依赖的package包/类
public Robot()
{
//make objects for the drive train, gyro, and joystick
myRobot = new RobotDrive(new CANTalon(leftMotorChannel), new CANTalon(
leftRearMotorChannel), new CANTalon(rightMotorChannel),
new CANTalon(rightRearMotorChannel));
gyro = new AnalogGyro(gyroChannel);
joystick = new Joystick(joystickChannel);
}
示例6: initialize
import edu.wpi.first.wpilibj.AnalogGyro; //导入依赖的package包/类
public static void initialize()
{
if (!initialized) {
myGyro = new AnalogGyro(GYRO_CHANNEL);
myGyro.setSensitivity(GYRO_SENSITIVITY);
myGyro.calibrate();
initialized = true;
}
}
示例7: ShooterSubsystem
import edu.wpi.first.wpilibj.AnalogGyro; //导入依赖的package包/类
public ShooterSubsystem(){
liftController=RobotMap.liftMotor.getController();
wheelController=RobotMap.wheelMotor.getController();
liftGyro = new AnalogGyro(RobotMap.liftGyroPort);
liftGyro.reset();
liftGyro.setSensitivity(0.007);
limitSwitch = new DigitalInput(RobotMap.limitSwitch);
}
示例8: DriveTrain
import edu.wpi.first.wpilibj.AnalogGyro; //导入依赖的package包/类
public DriveTrain() {
super();
front_left_motor = new Talon(1);
back_left_motor = new Talon(2);
front_right_motor = new Talon(3);
back_right_motor = new Talon(4);
drive = new RobotDrive(front_left_motor, back_left_motor,
front_right_motor, back_right_motor);
left_encoder = new Encoder(1, 2);
right_encoder = new Encoder(3, 4);
// Encoders may measure differently in the real world and in
// simulation. In this example the robot moves 0.042 barleycorns
// per tick in the real world, but the simulated encoders
// simulate 360 tick encoders. This if statement allows for the
// real robot to handle this difference in devices.
if (Robot.isReal()) {
left_encoder.setDistancePerPulse(0.042);
right_encoder.setDistancePerPulse(0.042);
} else {
// Circumference in ft = 4in/12(in/ft)*PI
left_encoder.setDistancePerPulse((4.0/12.0*Math.PI) / 360.0);
right_encoder.setDistancePerPulse((4.0/12.0*Math.PI) / 360.0);
}
rangefinder = new AnalogInput(6);
gyro = new AnalogGyro(1);
// Let's show everything on the LiveWindow
LiveWindow.addActuator("Drive Train", "Front_Left Motor", (Talon) front_left_motor);
LiveWindow.addActuator("Drive Train", "Back Left Motor", (Talon) back_left_motor);
LiveWindow.addActuator("Drive Train", "Front Right Motor", (Talon) front_right_motor);
LiveWindow.addActuator("Drive Train", "Back Right Motor", (Talon) back_right_motor);
LiveWindow.addSensor("Drive Train", "Left Encoder", left_encoder);
LiveWindow.addSensor("Drive Train", "Right Encoder", right_encoder);
LiveWindow.addSensor("Drive Train", "Rangefinder", rangefinder);
LiveWindow.addSensor("Drive Train", "Gyro", gyro);
}
示例9: init
import edu.wpi.first.wpilibj.AnalogGyro; //导入依赖的package包/类
public static void init() {
// BEGIN AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=CONSTRUCTORS
motorsVictor0 = new VictorSP(0);
LiveWindow.addActuator("Motors", "Victor0", (VictorSP) motorsVictor0);
motorsVictor1 = new VictorSP(1);
LiveWindow.addActuator("Motors", "Victor1", (VictorSP) motorsVictor1);
LiveWindow.addActuator("Motors", "TalonSRX", (CANTalon) motorsCANTalon);
electricalPowerDistributionPanel1 = new PowerDistributionPanel(0);
LiveWindow.addSensor("Electrical", "PowerDistributionPanel 1", electricalPowerDistributionPanel1);
sensorsAnalogGyro1 = new AnalogGyro(0);
LiveWindow.addSensor("Sensors", "AnalogGyro 1", sensorsAnalogGyro1);
sensorsAnalogGyro1.setSensitivity(0.007);
// END AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=CONSTRUCTORS
}
示例10: Drive
import edu.wpi.first.wpilibj.AnalogGyro; //导入依赖的package包/类
public Drive() {
leftDrive = new TalonSRX(RobotMap.DriveLeftMotor);
rightDrive = new TalonSRX(RobotMap.DriveRightMotor);
gyro = new AnalogGyro(RobotMap.DriveGyro);
}
示例11: Drive
import edu.wpi.first.wpilibj.AnalogGyro; //导入依赖的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);
}
示例12: init
import edu.wpi.first.wpilibj.AnalogGyro; //导入依赖的package包/类
@Override
public void init(Environment environment) {
gyro = new AnalogGyro(RobotMap.GYRO);
gyro.initGyro();
}
示例13: TurtleAnalogGyro
import edu.wpi.first.wpilibj.AnalogGyro; //导入依赖的package包/类
public TurtleAnalogGyro(int port) {
g = new AnalogGyro(port);
}
示例14: TurtleAnalogGyro
import edu.wpi.first.wpilibj.AnalogGyro; //导入依赖的package包/类
public TurtleAnalogGyro(int port) {
gyro = new AnalogGyro(port);
}
示例15: GyroscopeModule
import edu.wpi.first.wpilibj.AnalogGyro; //导入依赖的package包/类
/**
* Constructs the module with the gyro object underneath this class to call
* methods from.
*
* @throws NullPointerException when gyro is null
* @param gyro the composing instance which will return values
*/
protected GyroscopeModule(AnalogGyro gyro) {
if (gyro == null) {
throw new NullPointerException("Null gyro given");
}
this.gyro = gyro;
}