Coding

/*----------------------------------------------------------------------------*/
/* Copyright (c) FIRST 2008. All Rights Reserved.                             */
/* Open Source Software - may be modified and shared by FRC teams. The code   */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project.                                                               */
/*----------------------------------------------------------------------------*/

package edu.wpi.first.wpilibj.templates;


import edu.wpi.first.wpilibj.*;
import edu.wpi.first.wpilibj.Joystick; 
import edu.wpi.first.wpilibj.RobotDrive; 
import edu.wpi.first.wpilibj.SimpleRobot; 
import edu.wpi.first.wpilibj.Timer; 



/**
 * The VM is configured to automatically run this class, and to call the
 * functions corresponding to each mode, as described in the SimpleRobot
 * documentation. If you change the name of this class or the package after
 * creating this project, you must also update the manifest file in the resource
 * directory.
 */
public class Team1605 extends SimpleRobot {
    
    
    Joystick stickDriverLeft = new Joystick(1);
    Joystick stickDriverRight = new Joystick(2);
    
    //remeber to switch jag port values for original robot
    Jaguar leftMotor = new Jaguar(2);
    Jaguar rightMotor = new Jaguar(1);
    Jaguar shooter = new Jaguar(3);
    //Victor gatherer = new Victor(4); 
    //Victor bridgeHandMotor = new Victor(6);
    
    RobotDrive robotDrive = new RobotDrive(leftMotor,rightMotor);
    
   
    
    /**
     * This function is called once each time the robot enters autonomous mode.
     */
    public void autonomous() {
        robotDrive.setSafetyEnabled(false);
        robotDrive.drive(-0.35,0.0);//drive at 35% speed 0% turn
        Timer.delay(1.0);//wait 1 second
        robotDrive.drive(0.0, 0.0);//stop
        Timer.delay(1.0);//wait 1 second
        shooter.set(1.0);//full spped shoots
        Timer.delay(1.0);//wait one second
        shooter.set(0.0);//stop shooter
        Timer.delay(7.0);// wait 7 seconds

        //robotDrive.drive(0.5,0.0);//drive at 50% speed 0% turn
        //Timer.delay(5.0);//wait 5 seconds
        //robotDrive.drive(0.0,0.0);//stop
        //Timer.delay(10.0);// wait 10 seconds
        
        //leftMotor.set(-1);
        //yrightMotor.set(1);
        //Timer.delay(15);
        //leftMotor.set(0);
        //rightMotor.set(0);
        //Timer.delay(3);
        
        
        
    }

    /**
     * This function is called once each time the robot enters operator control.
     */
    public void operatorControl() {
      while(isOperatorControl() && isEnabled())
    {
        
    
     robotDrive.tankDrive(stickDriverLeft.getAxis(Joystick.AxisType.kY), stickDriverRight.getAxis(Joystick.AxisType.kY));
    
        
       
        if(stickDriverRight.getButton(Joystick.ButtonType.kTrigger)) {
           shooter.set(1);
        }
        else {
            shooter.set(0);
        }
        
        
        if(stickDriverLeft.getButton(Joystick.ButtonType.kTrigger)) {
            shooter.set(-0.5);
            
        }
        else {
            shooter.set(0);
            
        }
       
       // bridgeHandMotor.set(stickDriverLeft.getAxis(Joystick.AxisType.kY)); 
               
        
        Timer.delay(.01);
    }

    }
}

can someone check if my programming for the shooter is correct…

What are you expecting the shooter to do?

From what I’m reading the robot will:
Drive forward at 35% speed for 1 second.
Wait one second.
Turn on the shooter motor at full speed for one second.
Wait 7 seconds.

Without knowing what your shooter is I can’t really tell you if it is correct or not.

Your teleop shooter is wrong, it should be like this

if(condition1)
shooter.set(speed)
else if(condition2)
shooter.set(otherspeed)
else
shooter.set(0)
endif

the way you have it up is

if(condition1)
shooter.set(speed)
else
shooter.set(0)
endif

if(condition2)
shooter.set(other)
else
shooter.set(0)
endif

If conditon1 is met, it will still be 0 because the second time around, its setting it to 0

Without knowing what your shooter is I can’t really tell you if it is correct or not.

the shooter is pretty much a kicker which is driven by a motor. for now i am trying to make it move.

i tried it but the shooter still doesn’t work…

What are the lights on the motor controller doing when you press the button?

I want to make sure that you understand what Arhowk is trying to say, and make sure you made the change correctly. Your if-else statements are sending conflicting signals to the motor controllers. The Java Virtual Machine (JVM) will evaluate the two if statements separately the way you have them written. The first one will be evaluated, and send either a full-speed signal or stop motion signal. Then the second one will be evaluated, sending either a half-speed signal or a stop signal. This results in several possible combinations such as full-speed and zero, half-speed and zero, or full-speed and half-speed. The usual result of the first two is a jumpy motion where the movement stops and then starts again, especially if the button is held down.

Combining the code to have an else-if statement should prevent that paticular kind of jumpy motion. An else-if statement is evaluated as one statement, and will therefore only set your motor to one speed, rather than trying to set it to two speeds at once.

The code for an else-if statement would look like this:

 if(stickDriverRight.getButton(Joystick.ButtonType.kTrigger)) {
           shooter.set(1);
        }
        else if(stickDriverLeft.getButton(Joystick.ButtonType.kTrigger)) {
            shooter.set(-0.5);
        }
        else {
            shooter.set(0);
        }

It should replace, quite precisely, this block of code:

 if(stickDriverRight.getButton(Joystick.ButtonType.kTrigger)) {
           shooter.set(1);
        }
        else {
            shooter.set(0);
        }
        
        
        if(stickDriverLeft.getButton(Joystick.ButtonType.kTrigger)) {
            shooter.set(-0.5);
            
        }
        else {
            shooter.set(0);
            
        }

That’s the only thing visibly wrong with your teleop code-I’ve seen this problem exactly with a claw we were working on during build, and experienced the jumpy motion I described earlier. The only other things that I could think of to check are trying different parameters for the .getButton method, in case the one you’re using doesn’t work (it might be perfectly valid but I’ve never used it before), and running through wiring debugs.

Also, the more details you give us on what you’re looking to do and the problems you’re having, the more we can help:)