|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
| Thread Tools | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
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?
|
|
#2
|
||||
|
||||
|
Re: Use both joysticks to drive robot on Xbox controller?
Code:
robotDrive.tankDrive(xboxController.getRawAxis(1), xboxController.getRawAxis(3)) |
|
#3
|
||||
|
||||
|
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)); |
|
#4
|
|||
|
|||
|
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. |
|
#5
|
||||
|
||||
|
Re: Use both joysticks to drive robot on Xbox controller?
Quote:
Quote:
Can you post your code please? |
|
#6
|
||||
|
||||
|
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);
}
}
Last edited by AustinShalit : 15-01-2017 at 23:52. |
|
#7
|
|||
|
|||
|
Re: Use both joysticks to drive robot on Xbox controller?
Okay, thank you all for your help!
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|