Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Driver Joystick Scaling #16

Open
schreiaj opened this issue Jan 29, 2014 · 0 comments
Open

Driver Joystick Scaling #16

schreiaj opened this issue Jan 29, 2014 · 0 comments

Comments

@schreiaj
Copy link
Contributor

Implement scaling on the Driver Joysticks for cheesydrive. Reference scaling function from 79 below, steal if you want. These values will have to be tweaked based on driver prefs.

public static double mapJoystickToPowerOutput(double input)
    {
        if(Math.abs(input) < 0.05)
        {
                // Stop if joystick is near zero
                return 0.0;
        }
        else
        {
            double mapping;

            if(Math.abs(input) <= 0.75)
            {
                    mapping = 0.95 * ((0.5 * MathUtils.pow(Math.abs(input), 2.0)) + 0.2);
                    mapping = (input >= 0) ? mapping : -mapping; // Change to negative if the input was negative
                    return mapping;
            }
            else
            {
                    mapping = 2.16 * Math.abs(input) - 1.16;
                    mapping = (input >= 0) ? mapping : -mapping; // Change to negative if the input was negative
                    return mapping;
            }
        }
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant