Hello! My team is having quite a bit of problems with our 2nd joystick. We are using joystick 1 for driving and joystick 2 for our launcher. Our 2nd joystick doesn't seem to work at all. The driver station recognizes it, but we are unable to do anything with it. I hope it's just a simple code mistake. Could anyone help us out? Any help is greatly appreciated! Here is the code:
Code:
/*----------------------------------------------------------------------------*/ /* Copyright (c) FIRST 2008. All Rights Reserved. */ /* Open Source Software - may be modified and shared by FRC teams. The code */ /* must be accompanied by the FIRST BSD license file in the root directory of */ /* the project. */ /*-------------------------------------------------------------------*/ package edu.wpi.first.wpilibj.templates;
import edu.wpi.first.wpilibj.SimpleRobot;
import edu.wpi.first.wpilibj.Joystick;
import edu.wpi.first.wpilibj.RobotDrive;
import edu.wpi.first.wpilibj.Talon;
import edu.wpi.first.wpilibj.Timer;
import edu.wpi.first.wpilibj.Victor;
/** * The VM is configured to automatically run this class, and to call the * functions corresponding to each mode, as described in the SimpleRobot * documentation. If you change the name of this class or the package after * creating this project, you must also update the manifest file in the resource * directory. */
public class Drive extends SimpleRobot {
private RobotDrive myDrive, Shooter;
private Joystick driveStick, driveStick2;
private Talon FrontRight, FrontLeft, BackRight, BackLeft;
private Victor M1, M2;
/** * This function is called once each time the robot enters autonomous mode. */
public void robotInit()
{
FrontRight = new Talon(1);
BackLeft = new Talon(2);
FrontLeft = new Talon(3);
BackRight = new Talon(4);
myDrive = new RobotDrive(FrontLeft, BackLeft, FrontRight, BackRight); myDrive.setInvertedMotor(RobotDrive.MotorType.kFrontRight,true);
M1 = new Victor(5);
M2 = new Victor(6);
Shooter = new RobotDrive(M1, M2);
driveStick = new Joystick(1);
driveStick2 = new Joystick(2);
}
public void autonomous()
{
while(isAutonomous() && isEnabled())
myDrive.drive(-.5, 0.0);
Timer.delay(2.0);
myDrive.drive(0.0,0.0);
}
/** * This function is called once each time the robot enters operator control. */
public void operatorControl()
{
while(isOperatorControl() && isEnabled())
myDrive.arcadeDrive(driveStick);
Timer.delay(0.01);
Shooter.arcadeDrive(driveStick2);
Timer.delay(0.01); }
}