|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
|||
|
|||
|
Re: Coasting Problems
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?
|
|
#2
|
|||
|
|||
|
Re: Coasting Problems
Can you elaborate more by what you mean by this:
Quote:
|
|
#3
|
|||
|
|||
|
Re: Coasting Problems
Quote:
It might be an issue with zeroing the motor controllers, although, it works fine with Labview. Heres the code: public class DriveControl { double leftJoystickValue = 0; double rightJoystickValue = 0; /** * Controls the Joystick Read-in. * Reads the joystick values and directs values to the motors. */ public void driveRobot() { if(Math.abs(Hardware.leftJoystick.getY()) > .25){ leftJoystickValue = Hardware.leftJoystick.getY(); } if(Math.abs(Hardware.rightJoystick.getY()) > .25){ rightJoystickValue = Hardware.rightJoystick.getY(); } SmartDashboard.putNumber("leftJoystickValue", leftJoystickValue); SmartDashboard.putNumber("righttJoystickValue", rightJoystickValue); //decrease values by 3/4 for each trigger pressed if (Hardware.leftJoystick.getRawButton(1)) { leftJoystickValue = leftJoystickValue * (.75); rightJoystickValue = leftJoystickValue * (.75); } SmartDashboard.putBoolean("leftJoystickTrigger Pressed", Hardware.leftJoystick.getRawButton(1)); //reduces values even more if (Hardware.rightJoystick.getRawButton(1)) { leftJoystickValue = leftJoystickValue * (.75); rightJoystickValue = leftJoystickValue * (.75); } SmartDashboard.putBoolean("rigbhtJoystickTrigger Pressed", Hardware.rightJoystick.getRawButton(1)); //sends signal to bot with the adjusted drive values Hardware.chassis.tankDrive(leftJoystickValue, rightJoystickValue); } |
|
#4
|
||||||
|
||||||
|
Re: Coasting Problems
Quote:
Imagine the following scenario Code:
joystick output 1 1 0.75 0.75 0.5 0.5 0.3 0.3 0.26 0.26 0.25 0.25 0.1 0.25 0.0 0.25 Last edited by Joe Ross : 17-09-2013 at 16:14. |
|
#5
|
|||
|
|||
|
Re: Coasting Problems
Thank you for your help! I added to the code so the values are zeroed. I'm amazed that I missed that earlier.
|
|
#6
|
||||
|
||||
|
Re: Coasting Problems
Just for future reference, my favourite deadzone code looks something like this:
Code:
float deadZ (float val) {
return val > 0.6 || val < -0.6? val: 0;
}
To me this is the most aesthetically pleasing. But to each his own :P 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 :P Take it with a grain of salt |
|
#7
|
|||
|
|||
|
Re: Coasting Problems
Thanks, I will definitely give those a try.
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|