View Single Post
  #1   Spotlight this post!  
Unread 03-02-2012, 13:38
kingkurry kingkurry is offline
Registered User
FRC #4067
 
Join Date: Jan 2012
Location: Maryland
Posts: 20
kingkurry is an unknown quantity at this point
Spike Relay code failing

We are using a spike relay to control a spinbrush in the front of the robot to sweep in balls. I created a new spike relay object and used the left trigger to get it to move. However, every time I hit the trigger, the ENTIRE robot jerks forward and then becomes unresponsive until I disable and renable teleop. And when i say jerk froward, I mean that the CIM motos, which are connected to our 4 jaguars, move and the spin brush moves too, albeit for a short period of time. Is there some issue in the code that could cause this to happen?


Code:
package edu.wpi.first.wpilibj.templates;


import edu.wpi.first.wpilibj.IterativeRobot;
import edu.wpi.first.wpilibj.Joystick;
import edu.wpi.first.wpilibj.RobotDrive;
import edu.wpi.first.wpilibj.Relay;

public class Test extends IterativeRobot {
    Joystick leftStick;
    Joystick rightStick;
    RobotDrive robot; 
    Relay spike;
    double leftValue, rightValue;
    
    public void robotInit() {
        leftStick = new Joystick(1);
        rightStick = new Joystick(2);
        
        robot = new RobotDrive(1,2,3,4);
        
        spike = new Relay(5);
       
    }

    public void disabledPeriodic(){
       
    }
    public void autonomousPeriodic() {
      
    }


    public void teleopPeriodic() {
        //robot.setSafetyEnabled(false);
        
        
        robot.tankDrive(leftStick.getY(),rightStick.getY());  

        //robot.tankDrive(leftValue, rightValue);
        
        
        //spike.set(Relay.Value.kForward);
        
        if(leftStick.getRawButton(1)){
            spike.set(Relay.Value.kForward);
        }
    
}
Also, I am plugging in the relay to the relay port of the sidecar. We are just using 5 here because we tried switching between different relay port numbers.
Reply With Quote