Go to Post I had so much to say but I dont know how to get it accross -- but to all of you that we were involved with this weekend, thankyou for everything -- we're changing lives, and we truly are moving mountains, in more ways than one. - Jacqui Sutton [more]
Home
Go Back   Chief Delphi > FIRST > General Forum
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Spotlight this post!  
Unread 19-11-2015, 19:06
Bernstern Bernstern is offline
Registered User
FRC #2141 (Spartonics)
Team Role: Programmer
 
Join Date: Nov 2015
Rookie Year: 2015
Location: Clayton
Posts: 30
Bernstern is an unknown quantity at this point
Newbie How to control a spike

In our code for a tshirt cannon (Im a freshman and get all the bad jobs) I was tasked with making the relay (Spike) shoot the actual cannon. I have no idea. I tinkered and set this up like so:

Subsystem
package org.usfirst.frc.team2141.robot.subsystems;

import org.usfirst.frc.team2141.robot.RobotMap;
import org.usfirst.frc.team2141.robot.commands.CannonCont rol;

import edu.wpi.first.wpilibj.Relay;
import edu.wpi.first.wpilibj.Relay.Direction;
import edu.wpi.first.wpilibj.Relay.Value;
import edu.wpi.first.wpilibj.command.Subsystem;

/**
*
*/
public class Cannon extends Subsystem {

Relay cannonFire;


public Cannon() {

cannonFire = new Relay(RobotMap.CANNON_CHANNEL);

}


public void cannonFire() {
cannonFire.set(Value.kOn);

}
// 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());
setDefaultCommand(new CannonControl());
}
}


Command
package org.usfirst.frc.team2141.robot.commands;

import org.usfirst.frc.team2141.robot.OI;
import org.usfirst.frc.team2141.robot.Robot;

import edu.wpi.first.wpilibj.command.Command;

/**
*
*/
public class CannonControl extends Command {

public CannonControl() {
// Use requires() here to declare subsystem dependencies
// eg. requires(chassis);
requires(Robot.cannon);
}

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

// Called repeatedly when this Command is scheduled to run
protected void execute() {
if (Robot.oi.getButtons()[5].get()) {
Robot.cannon.cannonFire();
}}

// 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() {
}
}


What am I doing wrong?
Reply With Quote
 


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 00:43.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi