Thread: Twitchy Motors
View Single Post
  #55   Spotlight this post!  
Unread 14-02-2016, 17:48
hwu24110 hwu24110 is offline
Registered User
FRC #0988
 
Join Date: Feb 2014
Location: Las Vegas
Posts: 44
hwu24110 is an unknown quantity at this point
Re: Twitchy Motors

I've implemented a deadband, but it still twitches.

Code:
	public void operatorControl() {
    	LF.setSafetyEnabled(true);
    	LR.setSafetyEnabled(true);
    	RF.setSafetyEnabled(true);
    	RR.setSafetyEnabled(true);
    	while (isOperatorControl() && isEnabled()) {
        	LF.set(-deadband(stickL.getRawAxis(1)));
        	LR.set(-deadband(stickL.getRawAxis(1)));
        	RF.set(deadband(stickR.getRawAxis(1)));
        	RR.set(deadband(stickR.getRawAxis(1)));
        	C.setClosedLoopControl(true);
        	if(controller.getRawButton(5)){
       		 D.set(DoubleSolenoid.Value.kForward);
        	}
        	else if(controller.getRawButton(6)){
       		 D.set(DoubleSolenoid.Value.kReverse);
        	}
        	Timer.delay(0.005);   	 // wait for a motor update times
    	}
	}

	public double deadband(double JoystickValue) {
   	 double deadbandreturn = 0;
   	 if(Math.abs(JoystickValue)<.2){
   		 return 0;
   	 }
   	 else {
   		 deadbandreturn = JoystickValue;
   	 }
   	 return deadbandreturn;