View Single Post
  #4   Spotlight this post!  
Unread 14-11-2013, 13:48
otherguy's Avatar
otherguy otherguy is offline
sparkE
AKA: James
FRC #2168 (The Aluminum Falcons)
Team Role: Mentor
 
Join Date: Feb 2010
Rookie Year: 2009
Location: CT
Posts: 431
otherguy is a splendid one to beholdotherguy is a splendid one to beholdotherguy is a splendid one to beholdotherguy is a splendid one to beholdotherguy is a splendid one to beholdotherguy is a splendid one to beholdotherguy is a splendid one to behold
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:

public void tankDrive(double leftJoystickValue, double rightJoystickValue){
    robotDrive.tankDrive(
        Robot.drivetrain.adjustSpeed(Robot.drivetrain.deadZone(leftJoystickValue)),
        Robot.drivetrain.adjustSpeed(Robot.drivetrain.deadZone(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.oi.getleftJoystick().getY(),
        Robot.oi.getrightJoystick().getY());
}
Maybe it's just my preference, but I prefer logic to be performed by the subsystem. That way if multiple commands call the exposed methods, they always perform in a consistent manner, and it reduces code duplication at the Command level.
__________________
http://team2168.org
Reply With Quote