This summer, I switched my team’s robot over from LabView to Java and have successfully moved everything over except for steering. When I attempt to drive with and then release the joysticks, the robot will began crawling in the direction it was previously moving.
From what I can tell, it’s an issue reading in joystick values, for which I’ve set up some wiggle room with a pair of if statements. Unfortunately, the end values of the joysticks keep changing making it near impossible for me to set up a threshold.
You could post your code so others could help you troubleshoot, but first I suggest:
Use the console or dashboard to display the value of the stick, and “let go” a few times. Take note of the range of values it can be and make that your deadzone (the range in which the input shouldn’t cause the motors to move).
Make sure that when you are in the deadzone, that you are sending a command of 0.0 (“stop”), not just “do nothing”. Sending no command would cause the motor to move at the last known value (this one sounds like your issue).
The following assume you are using the RobotDrive VIs in LabVIEW and the robotDrive object in Java.
LabVIEW, by default, squares the inputs joystick inputs. This makes a small input value even smaller and might account for what you are seeing. The Java library also squares the joystick inputs by default, but makes it easier to change to not squaring. Which are you using?
In the Java library, robot drive objects declare jaguars unless speed controller objects are passed to it. If you are using a different type of speed controller (eg Victor or Talon), you may see weird behavior like neutral offsets. In LabVIEW, it’s more obvious how to change to the appropriate speed controller type.
I’m using the Java Library. My inputs are from the .getY() values of the joysticks. The motors are being controlled through: tankDrive(leftJoystickValue, rightJoystickValue). I have the values from the Joystick.getY() being fed to the dashboard to view them. They always seem to read between *.1<->.*3 when the joystick is released. Should I be using the route of the .getY() value to drive the robot?
My team also had this problem but it ended up just being the fact that our talons weren’t zeroed, I know they should be fine on shipment, but for some reason that fixed our problems! The information for zeroing talons was in the 2013 control system pdf if i remember correctly
Just for future reference, my favourite deadzone code looks something like this:
float deadZ (float val) {
return val > 0.6 || val < -0.6? val: 0;
}
Then you would simply say something like ‘tankDrive(deadZ(leftStick), deadZ(rightStick));’
To me this is the most aesthetically pleasing. But to each his own One thing I noticed that would also make it look better (my apologies, I’m really picky about these things) would be to assign ‘Hardware.leftJoystick.getRawButton(1)’ to a boolean somewhere in the beginning of your code so that you don’t have to type that mess every time you need to check it. You could also make a similar method to the one above that takes your boolean as an input as well as a joystick value and clean up the code even more (there’s currently a lot of code involved in just getting it to drive). Just my $0.02 Take it with a grain of salt