Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Java (http://www.chiefdelphi.com/forums/forumdisplay.php?f=184)
-   -   Negative Joystick Values Don't Control Mecanum Wheels (http://www.chiefdelphi.com/forums/showthread.php?t=126135)

MichaelB 09-02-2014 17:22

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);
    }


Ether 09-02-2014 17:43

Re: Negative Joystick Values Don't Control Mecanum Wheels
 


What does this code do?
Code:

x = x > RobotMap.joystickTolerance ? x : 0;
y = y > RobotMap.joystickTolerance ? y : 0;
twist = twist > RobotMap.joystickTolerance ? twist : 0;



MichaelB 09-02-2014 17:49

Re: Negative Joystick Values Don't Control Mecanum Wheels
 
Quote:

Originally Posted by Ether (Post 1340218)


What does this code do?
Code:

x = x > RobotMap.joystickTolerance ? x : 0;
y = y > RobotMap.joystickTolerance ? y : 0;
twist = twist > RobotMap.joystickTolerance ? twist : 0;



That was me trying to set up a dead zone in the middle of the joysticks. Of course, now that you pointed it up I see the problem with my code. That bit makes the value 0 if the joystick is less that the tolerance (0.2), instead of the absolute value of the joystick less than the tolerance. Thanks!


All times are GMT -5. The time now is 09:32.

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