Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Java (http://www.chiefdelphi.com/forums/forumdisplay.php?f=184)
-   -   Use both joysticks to drive robot on Xbox controller? (http://www.chiefdelphi.com/forums/showthread.php?t=153696)

Eric_Dao 15-01-2017 00:16

Use both joysticks to drive robot on Xbox controller?
 
How can I use both thumb sticks on an Xbox controller to move the robot's left and right motors?

euhlmann 15-01-2017 02:01

Re: Use both joysticks to drive robot on Xbox controller?
 
Code:

robotDrive.tankDrive(xboxController.getRawAxis(1), xboxController.getRawAxis(3))

AustinShalit 15-01-2017 11:48

Re: Use both joysticks to drive robot on Xbox controller?
 
You can also try this:

Code:

robotDrive.tankDrive(xboxController.getY(Hand.kLeft), xboxController.getY(Hand.kRight));

18gillespiery 15-01-2017 16:00

Re: Use both joysticks to drive robot on Xbox controller?
 
What we did was define two variables as joysticks on the same port

From there use the Joystick.setChannel() method to change it to the y axis on the other stick. It should be channel 5.

after that it should work.

euhlmann 15-01-2017 23:40

Re: Use both joysticks to drive robot on Xbox controller?
 
Quote:

Originally Posted by 18gillespiery (Post 1631540)
What we did was define two variables as joysticks on the same port

From there use the Joystick.setChannel() method to change it to the y axis on the other stick. It should be channel 5.

after that it should work.

Sorry, I'm a bit confused about what you're doing.
Quote:

Originally Posted by 18gillespiery (Post 1631540)
What we did was define two variables as joysticks on the same port

Bad idea. Why do you need to do this?
Can you post your code please?

AustinShalit 15-01-2017 23:48

Re: Use both joysticks to drive robot on Xbox controller?
 
What 18gillespiery recommends is below. I do not recommend teams do this. Instead use either of the examples above.

Once again, this code is not recommended!
Code:

public class Robot extends IterativeRobot {
       
        private RobotDrive drive;
       
        private Joystick joystick1;
        private Joystick joystick2;
       
        @Override
        public void robotInit() {
                drive = new RobotDrive(0, 1);
               
                joystick1 = new Joystick(0);
                joystick2 = new Joystick(0);
               
                joystick2.setAxisChannel(AxisType.kY, 5);
        }
       
        @Override
        public void teleopPeriodic() {
                drive.tankDrive(joystick1, joystick2);
        }

}


Eric_Dao 16-01-2017 08:17

Re: Use both joysticks to drive robot on Xbox controller?
 
Okay, thank you all for your help!


All times are GMT -5. The time now is 12:34.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi