Help ME PLEASE ASAP

Can someone please fix my code or point me in the right direction so i can use a xbox controller to drive. tank drive or arcade drive it doesnt matter

public class Robot extends IterativeRobot {
RobotDrive drive = new RobotDrive(1,2,3,4);
Joystick mXboxController = new Joystick(0);
Joystick controlStick = new Joystick(1);
Talon frontLeft = new Talon(4);
Talon rearLeft = new Talon(3);
Talon frontRight = new Talon(2);
Talon rearRight = new Talon(1);

public void robotInit() {	
drive = new RobotDrive(0,1,2,3); 
mXboxController = new Joystick(0); 
controlStick = new Joystick(1);
frontLeft = new Talon(1);
frontLeft.enableDeadbandElimination(true);
frontLeft.set(+1.0);
rearLeft = new Talon(2);
rearLeft.enableDeadbandElimination(true);
rearLeft.set(-1.0);
frontRight = new Talon(3);
frontRight.enableDeadbandElimination(true);
frontRight.set(+1.0);
rearRight = new Talon(4);
rearRight.enableDeadbandElimination(true);
rearRight.set(-1.0);

}


public void autonomousInit() {  
	drive = new RobotDrive(1,2,3,4);
	frontLeft = new Talon(1);
    frontLeft.enableDeadbandElimination(true);
    frontLeft.set(-1.0);
    rearLeft = new Talon(2);
    rearLeft.enableDeadbandElimination(true);
    rearLeft.set(+1.0); 
    frontRight = new Talon(3);
    frontRight.enableDeadbandElimination(true);
    frontRight.set(-1.0);
    rearRight = new Talon(4);
    rearRight.enableDeadbandElimination(true);
    rearRight.set(+1.0);
    
}


public void autonomousPeriodic() { 
	while (isAutonomous() && isEnabled()) {
		drive.setSafetyEnabled(true);
        drive.drive(-0.5,0.0);
		Timer.delay(5); 
		drive.drive(0.0,0.0); 
	
	}
}
	



public void teleopInit(){ 
  drive = new RobotDrive(1,2,3,4);
  mXboxController = new Joystick(0); 
  controlStick = new Joystick(1);
  frontLeft = new Talon(1);
  frontLeft.enableDeadbandElimination(true);
  frontLeft.set(-1.0);
  rearLeft = new Talon(2);
  rearLeft.enableDeadbandElimination(true);
  rearLeft.set(+1.0); 
  frontRight = new Talon(3);
  frontRight.enableDeadbandElimination(true);
  frontRight.set(-1.0);
  rearRight = new Talon(4);
  rearRight.enableDeadbandElimination(true);
  rearRight.set(+1.0);
   
   }
 



public void teleopPeriodic() {
	while (isOperatorControl() && isEnabled()) {
		drive.setSafetyEnabled(true);
        double speedControl = 1;
		double joystickLeftY = mXboxController.getRawAxis(1)*speedControl;
	    double joystickLeftX = mXboxController.getRawAxis(0)*-1*speedControl;
		drive.arcadeDrive(joystickLeftY, joystickLeftX);

Add one of these to the end }

and the code will work?



RobotDrive drive = new RobotDrive(1,2,3,4); 

Talon frontLeft = new Talon(4); 
Talon rearLeft = new Talon(3);
Talon frontRight = new Talon(2); 
Talon rearRight = new Talon(1);


You are declaring and initializing a RobotDrive and you are also declaring your drivetrain Talons individually.

You need to do one or the other, but not both. Doing this will throw an error saying you are declaring and initializing all your drivetrain Talons twice.

Pick which way you want to program your robot: either using the simpler RobotDrive object, or by manually coding commands to your individual Talons, then delete all the code for the method you are not using.

In the future, it is also a good idea to post a description of the problem you are encountering, including any exceptions or errors messages.

Not necessarily. You can do


Talon = new Talon(0)
Talon2 = new Talon(1)
Talon3 = new Talon(2)
Talon4 = new Talon(3)
drive = new Robotdrive(Talon, Talon2, Talon3, Talon4)

You can do this way, but if you assign the ports to robotdrive then no, you can’t do both.

:cool: