![]() |
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); |
Re: Help ME PLEASE ASAP
Add one of these to the end }
|
Re: Help ME PLEASE ASAP
and the code will work?
|
Re: Help ME PLEASE ASAP
Code:
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. |
Re: Help ME PLEASE ASAP
Quote:
Code:
Talon = new Talon(0) |
Thanks Guys
:cool:
|
| All times are GMT -5. The time now is 08:03 AM. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi