|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
| Thread Tools | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Xbox Controller with mecanum drive
Hello, I'm a first year FRC programmer and was curious on how to use the Xbox 360 controller as both joysticks for the
Code:
myDrive.mecanumDrive_Polar(moveStick.getY(),moveStick.getX() , rotateStick.getTwist()); Code:
myDrive = new RobotDrive(0,1,2,3);
moveStick = new Joystick(1);
rotateStick = new Joystick(2);
|
|
#2
|
||||
|
||||
|
Re: Xbox Controller with mecanum drive
getY() and getX() are intended for flightstick not xbox controllers
i think the code you want is Code:
robotDrive.mecanumDrive_Cartesian(joystick.getRawAxis(whateverYourXAxisIs), joystick.getRawAxis(whateverYourYAxisIs), joystick.getRawAxis(whateverYourRotateAxisIs), whateverYourGyroValueIs) |
|
#3
|
||||
|
||||
|
Re: Xbox Controller with mecanum drive
The buttons on the controller follow this mapping
1: A 2: B 3: X 4: Y 5: Left Bumper 6: Right Bumper 7: Back 8: Start 9: Left Joystick 10: Right Joystick The axis on the controller follow this mapping (all output is between -1 and 1) 1: Left Stick X Axis -Left:Negative ; Right: Positive 2: Left Stick Y Axis -Up: Negative ; Down: Positive 3: Triggers -Left: Positive ; Right: Negative 4: Right Stick X Axis -Left: Negative ; Right: Positive 5: Right Stick Y Axis -Up: Negative ; Down: Positive 6: Directional Pad (Not recommended, buggy) taken from http://www.chiefdelphi.com/forums/sh...45&postcount=8 |
|
#4
|
|||
|
|||
|
Re: Xbox Controller with mecanum drive
so would something like this work as expected?
Code:
*/ RobotDrive myDrive;
Joystick moveStick;
Gyro gyro;
public void robotInit() {
Talon TalLF = new Talon(0);
Talon TalLR = new Talon(1);
Talon TalRF = new Talon(2);
Talon TalRR = new Talon(3);
myDrive = new RobotDrive(TalLF,TalLR,TalRF,TalRR);
moveStick = new Joystick(1);
}
/**
* This function is called periodically during autonomous
*/
public void autonomousPeriodic() {
}
/**
* This function is called periodically during operator control
*/
public void teleopPeriodic() {
//while(!isAutonomous() && isEnabled())
//{
//myDrive.mecanumDrive_Polar(moveStick.getRawAxis(1),moveStick.getRawAxis(2) , moveStick.getRawAxis(4));
myDrive.mecanumDrive_Cartesian(moveStick.getRawAxis(1), moveStick.getRawAxis(2), moveStick.getRawAxis(5), gyro.getAngle());
Timer.delay(0.01);
//}
}
|
|
#5
|
||||
|
||||
|
Re: Xbox Controller with mecanum drive
Quote:
Also, are you meaning to do field-oriented drive (pushing up on the left joystick makes the robot move away from you, no matter which way it's pointing)? |
|
#6
|
|||
|
|||
|
Re: Xbox Controller with mecanum drive
honestly at this point no. I just want the drive to work correctly, Do we have the gyro assigned correctly?
Code:
RobotDrive myDrive, catcherDrive; Joystick moveStick; Gyro gyro; myDrive.mecanumDrive_Cartesian(moveStick.getRawAxis(1), moveStick.getRawAxis(1), moveStick.getRawAxis(1), gyro.getAngle()); |
|
#7
|
|||
|
|||
|
Re: Xbox Controller with mecanum drive
that was me.... on a different account
|
|
#8
|
||||
|
||||
|
Re: Xbox Controller with mecanum drive
Quote:
Last edited by TimTheGreat : 01-28-2016 at 05:16 PM. |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|