Go to Post Can you describe how you utilized your human head device on your intake? - Kevin Ainsworth [more]
Home
Go Back   Chief Delphi > Technical > Programming > Java
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
Thread Tools Rate Thread Display Modes
  #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
  #2   Spotlight this post!  
Unread 09-02-2014, 17:43
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,042
Ether has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond repute
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;

Reply With Quote
  #3   Spotlight this post!  
Unread 09-02-2014, 17:49
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
Re: Negative Joystick Values Don't Control Mecanum Wheels

Quote:
Originally Posted by Ether View Post


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!
Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


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

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


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