Skip to content

Commit

Permalink
Merge pull request #53 from prosa100/feature/21-compressor-etc
Browse files Browse the repository at this point in the history
Issue #21: added compressor command and made some fixes to deal with mec...
  • Loading branch information
prosa100 committed Jan 21, 2014
2 parents 64876c8 + f98dde7 commit d9670aa
Show file tree
Hide file tree
Showing 5 changed files with 181 additions and 92 deletions.
174 changes: 87 additions & 87 deletions frc2022_2014/nbproject/project.xml
Original file line number Diff line number Diff line change
@@ -1,92 +1,92 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!--
This is a sample netbeans project file for a Sun Spot Application project.
You may edit it freely, it doesn't affect the ant-powered build.
--><project xmlns="http://www.netbeans.org/ns/project/1">
<type>org.netbeans.modules.ant.freeform</type>
<configuration>
<general-data xmlns="http://www.netbeans.org/ns/freeform-project/1">
<name>frc2022_2014</name>
<properties>
<property-file>${user.home}/.sunspotfrc.properties</property-file>
<property-file>build.properties</property-file>
<property-file>${sunspot.home}/default.properties</property-file>
</properties>
<folders>
<source-folder>
<label>src</label>
<type>java</type>
<location>src</location>
</source-folder>
</folders>
<ide-actions>
<action name="build">
<target>jar-app</target>
</action>
<action name="clean">
<target>clean</target>
</action>
<action name="run">
<target>deploy</target>
<target>run</target>
</action>
<action name="rebuild">
<target>clean</target>
<target>jar-app</target>
</action>
<action name="debug">
<target>deploy</target>
<target>debug-run</target>
</action>
<action name="javadoc">
<target>javadoc</target>
</action>
</ide-actions>
<export>
<type>folder</type>
<location>build</location>
<build-target>jar-app</build-target>
</export>
<view>
<items>
<source-folder style="packages">
<label>src</label>
<location>src</location>
</source-folder>
<source-file>
<location>build.xml</location>
</source-file>
</items>
<context-menu>
<ide-action name="build"/>
<ide-action name="clean"/>
<ide-action name="run"/>
<ide-action name="rebuild"/>
<ide-action name="debug"/>
<ide-action name="javadoc"/>
<action>
<label>Sun SPOT-deploy</label>
<target>deploy</target>
</action>
<action>
<label>Sun SPOT-jar-deploy</label>
<target>jar-deploy</target>
</action>
<separator/>
</context-menu>
</view>
<subprojects/>
</general-data>
<java-data xmlns="http://www.netbeans.org/ns/freeform-project-java/1">
<compilation-unit>
<package-root>src</package-root>
<classpath mode="boot">${sunspot.home}\lib\squawk.jar</classpath>
<classpath mode="compile">${sunspot.home}\lib\wpilibj.jar;${sunspot.home}\lib\networktables-crio.jar</classpath>
<built-to>build</built-to>
<source-level>1.4</source-level>
</compilation-unit>
</java-data>
</configuration>
</project>
--><project xmlns="http://www.netbeans.org/ns/project/1">
<type>org.netbeans.modules.ant.freeform</type>
<configuration>
<general-data xmlns="http://www.netbeans.org/ns/freeform-project/1">
<name>frc2022_2014</name>
<properties>
<property-file>${user.home}/.sunspotfrc.properties</property-file>
<property-file>build.properties</property-file>
<property-file>${sunspot.home}/default.properties</property-file>
</properties>
<folders>
<source-folder>
<label>src</label>
<type>java</type>
<location>src</location>
</source-folder>
</folders>
<ide-actions>
<action name="build">
<target>jar-app</target>
</action>
<action name="clean">
<target>clean</target>
</action>
<action name="run">
<target>deploy</target>
<target>run</target>
</action>
<action name="rebuild">
<target>clean</target>
<target>jar-app</target>
</action>
<action name="debug">
<target>deploy</target>
<target>debug-run</target>
</action>
<action name="javadoc">
<target>javadoc</target>
</action>
</ide-actions>
<export>
<type>folder</type>
<location>build</location>
<build-target>jar-app</build-target>
</export>
<view>
<items>
<source-folder style="packages">
<label>src</label>
<location>src</location>
</source-folder>
<source-file>
<location>build.xml</location>
</source-file>
</items>
<context-menu>
<ide-action name="build"/>
<ide-action name="clean"/>
<ide-action name="run"/>
<ide-action name="rebuild"/>
<ide-action name="debug"/>
<ide-action name="javadoc"/>
<action>
<label>Sun SPOT-deploy</label>
<target>deploy</target>
</action>
<action>
<label>Sun SPOT-jar-deploy</label>
<target>jar-deploy</target>
</action>
<separator/>
</context-menu>
</view>
<subprojects/>
</general-data>
<java-data xmlns="http://www.netbeans.org/ns/freeform-project-java/1">
<compilation-unit>
<package-root>src</package-root>
<classpath mode="boot">${sunspot.home}/lib/squawk.jar</classpath>
<classpath mode="compile">${sunspot.home}/lib/wpilibj.jar:${sunspot.home}/lib/networktables-crio.jar</classpath>
<built-to>build</built-to>
<source-level>1.4</source-level>
</compilation-unit>
</java-data>
</configuration>
</project>
15 changes: 12 additions & 3 deletions frc2022_2014/src/org/usfirst/frc2022_2014/RobotMap.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
* floating around.
*/
public class RobotMap {
// If the port isn't set yet, make it -1
// For example to map the left and right motors, you could define the
// following variables to use with your drivetrain subsystem.
// public static final int leftMotor = 1;
Expand All @@ -18,11 +19,19 @@ public class RobotMap {
// public static final int rangefinderModule = 1;
public static final int LeftMotorPort = 3;
public static final int RightMotorPort = 2;
public static final int ShooterPort = 15163;
public static final int ShooterPort = -1;
public static final int RetractorPort = -1;
public static final int CollectorPort = -1;
public static final int backLimitSwitchPort = -1;
public static final int frontLimitSwitchPort = -1;
public static final int SolenoidPort1 = -1;
public static final int SolenoidPort2 = -1;
public static final int BackLimitSwitchPort = -1;
public static final int FrontLimitSwitchPort = -1;

public static final int CompressSwitchChannel = -1;
public static final int CompressRelayChannel = -1;
public static final int LockRelayChannel = -1;
public static final int OutLimitSwitchChannel = -1;
public static final int InLimitSwitchChannel = -1;

/* For MecanumDrive */
public static final int FrontRightMotorPort = -1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import org.usfirst.frc2022_2014.subsystems.PinballShooter;
import org.usfirst.frc2022_2014.subsystems.TankDrivebase;
import org.usfirst.frc2022_2014.subsystems.BallCollection;
import org.usfirst.frc2022_2014.subsystems.CompressorSubsystem;
import org.usfirst.frc2022_2014.subsystems.MecanumDrive;

/**
Expand All @@ -25,7 +26,8 @@ public abstract class CommandBase extends Command {
public static ExampleSubsystem exampleSubsystem = new ExampleSubsystem();
public static TankDrivebase tankDrivebase = new TankDrivebase(RobotMap.LeftMotorPort, RobotMap.RightMotorPort);
public static PinballShooter shooter = new PinballShooter(RobotMap.ShooterPort);
public static BallCollection collector = new BallCollection(RobotMap.CollectorPort,RobotMap.RetractorPort, RobotMap.backLimitSwitchPort, RobotMap.frontLimitSwitchPort);
public static BallCollection collector = new BallCollection(RobotMap.CollectorPort,RobotMap.RetractorPort, RobotMap.BackLimitSwitchPort, RobotMap.FrontLimitSwitchPort);
public static CompressorSubsystem compressor = new CompressorSubsystem(RobotMap.SolenoidPort1, RobotMap.SolenoidPort1, RobotMap.CompressSwitchChannel, RobotMap.CompressRelayChannel,RobotMap.LockRelayChannel, RobotMap.OutLimitSwitchChannel, RobotMap.InLimitSwitchChannel);
public static MecanumDrive mecanumDrive = new MecanumDrive(RobotMap.FrontLeftMotorPort, RobotMap.FrontRightMotorPort, RobotMap.BackLeftMotorPort, RobotMap.BackRightMotorPort);

public static void init() {
Expand All @@ -35,6 +37,8 @@ public static void init() {
// yet. Thus, their requires() statements may grab null pointers. Bad
// news. Don't move it.
oi = new OI();

compressor.start();

// Show what command your subsystem is running on the SmartDashboard
SmartDashboard.putData(exampleSubsystem);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package org.usfirst.frc2022_2014.commands;

/**
*
1) Turn back solenoid
2) Turn on electromagnet (relay)
3) Wait until fully back (limit switch)
4) Turn forward solenoid
The two subsystems for the pinball shooter and the compressor should be merged
*
* @author Emma
*/
public class CompressorController extends CommandBase {

public CompressorController(){
requires(compressor);

}

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

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

// 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() {
if(compressor.pistonOut()){
compressor.forwardSolenoid();
compressor.stop();
}
}

// Called when another command which requires one or more of the same
// subsystems is scheduled to run
protected void interrupted() {
compressor.stop();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import edu.wpi.first.wpilibj.Relay;
import edu.wpi.first.wpilibj.Solenoid;
import edu.wpi.first.wpilibj.command.Subsystem;
import org.usfirst.frc2022_2014.custom.LimitSwitch;

/**
*
Expand All @@ -19,10 +20,19 @@ public class CompressorSubsystem extends Subsystem {

private Compressor compressor;
private DoubleSolenoid dsol;
private Relay spikerelay;
private LimitSwitch lswitchout;
private LimitSwitch lswitchin;


public CompressorSubsystem(int sol1Port, int sol2Port, int compSwitchChannel, int compRelayChannel){
public CompressorSubsystem(int sol1Port, int sol2Port, int compSwitchChannel, int compRelayChannel, int emlRelayChanel, int
limitSwitch1Channel, int limitSwitch2Channel){
compressor = new Compressor(compSwitchChannel, compRelayChannel);
dsol = new DoubleSolenoid(sol1Port, sol2Port);
spikerelay = new Relay(emlRelayChanel);
lswitchout = new LimitSwitch(limitSwitch1Channel);
lswitchin = new LimitSwitch(limitSwitch2Channel);

}

public void start(){
Expand All @@ -33,6 +43,23 @@ public void start(){
public void stop(){
dsol.set(DoubleSolenoid.Value.kOff);
compressor.stop();
spikerelay.set(Relay.Value.kOff);
}

public void relayOn(){
spikerelay.set(Relay.Value.kOn);
}

public void relayOff(){
spikerelay.set(Relay.Value.kOff);
}

public boolean pistonOut(){
return lswitchout.isTriggered();
}

public boolean pistonIn(){
return lswitchin.isTriggered();
}

public void closeSolenoid(){
Expand Down

0 comments on commit d9670aa

Please sign in to comment.