|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
| Thread Tools | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
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();
}
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);
}
|
|
#2
|
||||
|
||||
|
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; |
|
#3
|
|||
|
|||
|
Re: Negative Joystick Values Don't Control Mecanum Wheels
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!
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|