Skip to content
This repository has been archived by the owner on Jul 10, 2019. It is now read-only.

Wrote code for bridge balancing piston #8

Merged
merged 3 commits into from
Mar 20, 2012
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/edu/stuy/RobotMap.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ public class RobotMap {
public static final int GEAR_SHIFT_HIGH = 4;
public static final int TUSKS_SOLENOID_RETRACT = 5;
public static final int TUSKS_SOLENOID_EXTEND = 6;
public static final int BRIDGE_BALANCING_EXTEND = 7;
public static final int BRIDGE_BALANCING_RETRACT = 8;

/* VIRSYSJ */
public static final int[] VIRSYS_OUTPUT_MAP = new int[15];
Expand Down
32 changes: 32 additions & 0 deletions src/edu/stuy/commands/BridgePistonExtend.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package edu.stuy.commands;

/**
*
* @author admin
*/
public class BridgePistonExtend extends CommandBase {
public BridgePistonExtend() {
requires(bridgePiston);
}

protected void initialize() {
}

protected void execute() {
bridgePiston.extend();
}

protected boolean isFinished() {
return bridgePiston.isExtended();
}

protected void end() {
}

protected void interrupted() {
}
}
33 changes: 33 additions & 0 deletions src/edu/stuy/commands/BridgePistonRetract.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package edu.stuy.commands;

/**
*
* @author admin
*/
public class BridgePistonRetract extends CommandBase {
public BridgePistonRetract() {
requires(bridgePiston);
}

protected void initialize() {
}

protected void execute() {
bridgePiston.retract();
}

protected boolean isFinished() {
return !bridgePiston.isExtended();
}

protected void end() {
}

protected void interrupted() {
}

}
3 changes: 3 additions & 0 deletions src/edu/stuy/commands/CommandBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public abstract class CommandBase extends Command {
public static Acquirer acquirer;
public static Conveyor conveyor;
public static Camera camera;
public static BridgePiston bridgePiston;

static {
drivetrain = new Drivetrain();
Expand All @@ -35,6 +36,7 @@ public abstract class CommandBase extends Command {
if (!Devmode.DEV_MODE) {
tusks = new Tusks();
}
bridgePiston = new BridgePiston();
}

public static void init() {
Expand All @@ -53,6 +55,7 @@ public static void init() {
SmartDashboard.putData(acquirer);
SmartDashboard.putData(conveyor);
SmartDashboard.putData(camera);
SmartDashboard.putData(bridgePiston);
}
}

Expand Down
41 changes: 41 additions & 0 deletions src/edu/stuy/subsystems/BridgePiston.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package edu.stuy.subsystems;

import edu.stuy.RobotMap;
import edu.wpi.first.wpilibj.Solenoid;
import edu.wpi.first.wpilibj.command.Subsystem;

/**
*
* @author admin
*/
public class BridgePiston extends Subsystem {
Solenoid PistonExtend;
Solenoid PistonRetract;

public BridgePiston() {
PistonExtend = new Solenoid(2, RobotMap.BRIDGE_BALANCING_EXTEND);
PistonRetract = new Solenoid(2, RobotMap.BRIDGE_BALANCING_RETRACT);
}

public void initDefaultCommand() {

}

public void extend() {
PistonExtend.set(true);
PistonRetract.set(false);
}

public void retract() {
PistonExtend.set(false);
PistonRetract.set(true);
}

public boolean isExtended() {
return PistonExtend.get();
}
}