Go to Post I am definitely not a battery or battery charging expert (far from it) but I do know enough to be dangerous (I stayed in a Holiday Inn Express last night)... - Don Wright [more]
Home
Go Back   Chief Delphi > Technical > Programming > Java
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 06-02-2016, 23:34
Lesafian Lesafian is offline
Registered User
AKA: Jeremy Styma
FRC #6077 (Wiking Kujon)
Team Role: Programmer
 
Join Date: Feb 2016
Rookie Year: 2016
Location: Posen, Michigan
Posts: 21
Lesafian is an unknown quantity at this point
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);
does not specify what joystick axis it's utilizing. I'd like to know how to setup Arcade Drive (which I assume is the optimal for using only one stick) and specify it to use only the left stick.

Thank you in advance
Reply With Quote
  #2   Spotlight this post!  
Unread 07-02-2016, 19:22
minutebot minutebot is offline
Programming Captain
FRC #4536 (The Minutebots)
Team Role: Programmer
 
Join Date: Mar 2014
Rookie Year: 2014
Location: Saint Paul, Minnesota
Posts: 26
minutebot is a glorious beacon of lightminutebot is a glorious beacon of lightminutebot is a glorious beacon of lightminutebot is a glorious beacon of lightminutebot is a glorious beacon of light
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/
Reply With Quote
  #3   Spotlight this post!  
Unread 07-02-2016, 21:31
Dan Waxman Dan Waxman is offline
Registered User
FRC #0263 (Aftershock)
Team Role: Programmer
 
Join Date: Feb 2016
Rookie Year: 2016
Location: Long Island
Posts: 34
Dan Waxman is an unknown quantity at this point
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.
Reply With Quote
  #4   Spotlight this post!  
Unread 08-02-2016, 08:43
MaraiGG MaraiGG is offline
Registered User
FRC #5180
 
Join Date: Mar 2015
Location: South Carolina, United States
Posts: 2
MaraiGG is an unknown quantity at this point
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.
Reply With Quote
  #5   Spotlight this post!  
Unread 09-02-2016, 09:36
geniusadam69 geniusadam69 is offline
Registered User
FRC #5923
 
Join Date: Feb 2016
Location: Houston, TX
Posts: 5
geniusadam69 is an unknown quantity at this point
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.
Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 22:16.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


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