|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
|||
|
|||
|
RobotDrive with left joystick only? (XboxController)
Hey everyone.
I'm rather confused on how RobotDrive works. I'm planning on using the right joystick to move our sliding mechanism on top of our chassis. The code.. Code:
RobotDrive drive; Joystick xboxController; drive.arcadeDrive(xboxController); Thank you in advance ![]() |
|
#2
|
|||
|
|||
|
Re: RobotDrive with left joystick only? (XboxController)
I'm not familiar with RobotDrive. We always set up our drive from scratch by making a DriveTrain subsystem (command base) or class (iterative).
It uses however many motor controllers your team uses which in our case is 4. Here's some sample code: public void arcadeDrive(double forwardThrottle, double turnThrottle) { double leftVictorSPThrottle = forwardThrottle + turnThrottle; double rightVictorSPThrottle = -forwardThrottle + turnThrottle; leftBackVictorSP.set(leftVictorSPThrottle); leftFrontVictorSP.set(leftVictorSPThrottle); rightBackVictorSP.set(rightVictorSPThrottle); rightFrontVictorSP.set(rightVictorSPThrottle); } You set motor values from the drive train methods. To receive input you use an XBox controller or joystick like you did and you can use the Joystick.getY() method to use the y axis for forward throttle and Joystick.get() method to use the x axis for turning throttle. Here's a link to the 2016 WPILIB API which has all the classes like joystick and the thing they can do (methods). http://first.wpi.edu/FRC/roborio/release/docs/java/ |
|
#3
|
|||
|
|||
|
Re: RobotDrive with left joystick only? (XboxController)
This is my first year, but I found it much easier to write my own drive class with a few other programmers. A ton easier to adjust to driver feedback and hotfix as needed.
|
|
#4
|
|||
|
|||
|
Re: RobotDrive with left joystick only? (XboxController)
I am going to assume you are using a XboxController class. If so here is the code my team used last year.
Teleop { double rotateValue = Xbox.getLeftX(); double moveValue = Xbox.getLeftY(); mainDrive.arcadeDrive(rotateValue, moveValue); } Make sure if you are using a XboxController class that the axis ports are labeled starting with 0 like so. LEFT_X_AXIS = 0, LEFT_Y_AXIS = 1, L_TRIGGER = 2, R_TRIGGER = 3, RIGHT_X_AXIS = 4, RIGHT_Y_AXIS = 5, DPAD_LR = 6; I hope this helped. |
|
#5
|
|||
|
|||
|
Re: RobotDrive with left joystick only? (XboxController)
The arcade drive method has a lot of different parameters sets, including (double move, double rotate) and (GenericHID stick).
The arcadeDrive(GenericHID stick) method requires a GenericHID item, which Joystick is. Since your xboxController is a Joystick and Joystick extends GenericHID, then this is the method you're calling. What we found is that using an Xbox Controller and declaring it as Joystick will result in only the left joystick being recognized directly. The right joystick is available, but it's buried deeper. So, your current method will work just fine for arcade drive. The better way to use an Xbox Controller is to write your own class called XboxController and provide methods to access all of the features of the controller. Typically you will provide a double back for the joystick positions like MaraiGG used. Then you can expose both joysticks in a clean way. You'll then use the other parameter set: arcadeDrive(double move, double rotate) Last edited by geniusadam69 : 09-02-2016 at 09:49. Reason: read the original question more and thought to provide a more clear answer. |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|