View Single Post
  #3   Spotlight this post!  
Unread 01-15-2013, 02:00 PM
Bennett Bennett is offline
Registered User
FRC #2977 (Sir Lancer Bots)
Team Role: Mentor
 
Join Date: Jan 2012
Rookie Year: 2012
Location: Minnesota
Posts: 26
Bennett is an unknown quantity at this point
Re: Relay/Spike Problems?

SpikeOn:

Code:
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package edu.wpi.first.wpilibj.templates.commands;

import edu.wpi.first.wpilibj.Relay;
import edu.wpi.first.wpilibj.templates.subsystems.Spike;
import edu.wpi.first.wpilibj.templates.commands.CommandBase;

/**
 *
 * @author Bennett
 */
public class SpikeOn extends CommandBase {
    Spike spike = new Spike();
    public SpikeOn() {
        
        
        // Use requires() here to declare subsystem dependencies
        // eg. requires(chassis);
    }

    // Called just before this Command runs the first time
    protected void initialize() {
    }

    // Called repeatedly when this Command is scheduled to run
    protected void execute() {
        spike.spikeon();
        //setTimeout(10.0);
    }

    // Make this return true when this Command no longer needs to run execute()
    protected boolean isFinished() {
       return false;
        // return isTimedOut();
    }

    // Called once after isFinished returns true
    protected void end() {
    }

    // Called when another command which requires one or more of the same
    // subsystems is scheduled to run
    protected void interrupted() {
    }
}
SpikeOff:

Code:
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package edu.wpi.first.wpilibj.templates.commands;

import edu.wpi.first.wpilibj.templates.subsystems.Spike;
import edu.wpi.first.wpilibj.templates.commands.SpikeOff;

/**
 *
 * @author Bennett
 */
public class SpikeOff extends CommandBase {
    Spike spike = new Spike();
    
    
    public SpikeOff() {
        // Use requires() here to declare subsystem dependencies
        // eg. requires(chassis);
    }

    // Called just before this Command runs the first time
    protected void initialize() {
    }

    // Called repeatedly when this Command is scheduled to run
    protected void execute() {
        spike.spikestop();
    }

    // Make this return true when this Command no longer needs to run execute()
    protected boolean isFinished() {
        return false;
    }

    // Called once after isFinished returns true
    protected void end() {
    }

    // Called when another command which requires one or more of the same
    // subsystems is scheduled to run
    protected void interrupted() {
    }
}
Here is my spike class:

Code:
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package edu.wpi.first.wpilibj.templates.subsystems;

import edu.wpi.first.wpilibj.command.Subsystem;
import edu.wpi.first.wpilibj.Relay;
/**
 *
 * @author Bennett
 */
public class Spike extends Subsystem {
    Relay spike = new Relay(8);
    
  public void spikeon(){
    spike.set(Relay.Value.kForward);
  }
  
  public void spikestop(){
      spike.set(Relay.Value.kOff);
  }
    // Put methods for controlling this subsystem
    // here. Call these from Commands.

    public void initDefaultCommand() {
        // Set the default command for a subsystem here.
        //setDefaultCommand(new MySpecialCommand());
    }
}
Reply With Quote