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);
}
项目:snobot-2017
文件:Snobot.java
/**
* 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);
}
项目:Stronghold2016-340
文件:Drive.java
/**
* 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);
}
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);
}
public Robot()
{
//make objects for the drive train,gyro,and joystick
myRobot = new RobotDrive(new CANTalon(leftMotorChannel),new CANTalon(
leftRearMotorChannel),new CANTalon(rightRearMotorChannel));
gyro = new AnalogGyro(gyroChannel);
joystick = new Joystick(joystickChannel);
}
项目:FRC-2017
文件:GyroSensor.java
public static void initialize()
{
if (!initialized) {
myGyro = new AnalogGyro(GYRO_CHANNEL);
myGyro.setSensitivity(GYRO_SENSITIVITY);
myGyro.calibrate();
initialized = true;
}
}
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);
}
项目:turtleshell
文件:DriveTrain.java
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);
}
项目:2017TestBench
文件:RobotMap.java
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
}
项目:Stronghold2016-340
文件:Drive.java
public Drive() {
leftDrive = new TalonSRX(RobotMap.DriveLeftMotor);
rightDrive = new TalonSRX(RobotMap.DriveRightMotor);
gyro = new AnalogGyro(RobotMap.DriveGyro);
}
项目: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,"Front Right");
rearLeftPID = new PIDSpeedController(rearLeftEncoder,rearLeftTalon,"Rear Left");
rearRightPID = new PIDSpeedController(rearRightEncoder,rearRightTalon,"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);
}
@Override
public void init(Environment environment) {
gyro = new AnalogGyro(RobotMap.GYRO);
gyro.initGyro();
}
项目:turtleshell
文件:TurtleAnalogGyro.java
public TurtleAnalogGyro(int port) {
g = new AnalogGyro(port);
}
项目:turtleshell
文件:TurtleAnalogGyro.java
public TurtleAnalogGyro(int port) {
gyro = new AnalogGyro(port);
}
/**
* 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;
}
项目:strongback-java
文件:Hardware.java
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。