![]() |
Tank Drive Issues
Hello,
This year I have been switching my team over to Java and we have started to work with a Command Based control system. I built my drivetrain in RobotBuilder and then added code for the Tank Drive. Unfortunately, when I try to run the code, the left Joystick controls both sides of the robot instead of just the left side. The Code: DriveTrain subsystem: public void tankDrive(double leftJoystickValue, double rightJoystickValue){ robotDrive.tankDrive(leftJoystickValue, rightJoystickValue); } public double deadZone (double val) { return val > 0.25 || val < -0.25? val: 0; } public double adjustSpeed (double val){ return Robot.oi.leftJoystick.getRawButton(1)? val*.75: (Robot.oi.rightJoystick.getRawButton(1)? val*.75: val); } DriveCommand: protected void execute() { Robot.drivetrain.tankDrive(Robot.drivetrain.adjust Speed(Robot.drivetrain.deadZone(Robot.oi.getleftJo ystick().getY())), Robot.drivetrain.adjustSpeed(Robot.drivetrain.dead Zone(Robot.oi.getrightJoystick().getY()))); } Thanks |
Re: Tank Drive Issues
I don't see anything in the code that you posted that would output the left joystick to both left and right. Are your joystick declarations correct?
|
Re: Tank Drive Issues
I'm not entirely sure what is intended to be going on in the adjustSpeed method (chained ternary operators are pretty bad for that), but you're using it for each side's input into your tank drive and it seems to be depending on a specific combination of inputs.
EDIT: nevermind I get it now, my only remaining suspicions are the same as Joe's. |
Re: Tank Drive Issues
To answer your question, I would take a look at the code in the OI class. getrightJoystick() and getleftJoystick() may not be returning what you're expecting.
One suggestion to make your code a little easier to read/use (this isn't goign to solve your problem)... By changing what the tankDrive method does slightly you can clean up your "DriveCommand" code significantly, without changing how things work. Code:
//DriveTrain subsystem: |
Re: Tank Drive Issues
Agreed that you probably have a problem in your OI. And tell us whether you are using 2 joysticks or a video game controller (ie XBox/PS3 controller).
Also, I am glad to see a team using robot builder. Such an amazing yet underused tool, especially for your first year using Java/C++. |
| All times are GMT -5. The time now is 22:34. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi