View Single Post
  #1   Spotlight this post!  
Unread 09-02-2014, 17:22
MichaelB MichaelB is offline
Registered User
FRC #3573 (The Ohms)
Team Role: Programmer
 
Join Date: Feb 2014
Rookie Year: 2011
Location: Conyers
Posts: 8
MichaelB is an unknown quantity at this point
Negative Joystick Values Don't Control Mecanum Wheels

In my team's mecanum drive system, negative joystick values don't control the wheels, while positive ones do. Can anyone help with this? I've tried looking in the WPILib code, but can't find anything that would do it.

Relevant code:
DriveWithJoystick
Code:
protected void execute() {
        double x = oi.getRightStick().getX();
        double y = oi.getRightStick().getY();
        double twist = ((oi.getLeftStick().getX())-0.5)*2; //This is because all the way to the left is being interpreted as 0, while all the way to the right is 1.
        driveTrain.driveWithJoystick(x, y, twist);
        lcd.println(DriverStationLCD.Line.kUser2, 1, "Y: " + ((int)(y*10))/10.0);
        lcd.println(DriverStationLCD.Line.kUser3, 1, "Y: " + ((int)(y*10))/10.0);
        lcd.println(DriverStationLCD.Line.kUser4, 1, "Twist: " + ((int)(twist*10))/10.0);
        lcd.updateLCD();
    }
DriveTrain
Code:
    public void driveWithJoystick(double x, double y, double twist) {
        //x = -((x - Robot3573.initialX) / (1 - Robot3573.initialX));
        //y = (y - Robot3573.initialY) / (1 - Robot3573.initialY);
        //twist = (twist - Robot3573.initialTwist) / (1 - Robot3573.initialTwist);
        x = x > RobotMap.joystickTolerance ? x : 0;
        y = y > RobotMap.joystickTolerance ? y : 0;
        twist = twist > RobotMap.joystickTolerance ? twist : 0;
        driveTrain.mecanumDrive_Cartesian(x,y,twist, 0);
        System.out.println("X: " + x + "Y: " + y + "Twist: " + twist);
        //driveTrain.mecanumDrive_Polar(x,y,twist);
    }
Reply With Quote