Skip to content

Commit

Permalink
Fix the lift system
Browse files Browse the repository at this point in the history
  • Loading branch information
mastercoms committed Apr 4, 2015
1 parent 42e392a commit 7f629b5
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/org/usfirst/frc/team1002/robot/Robot.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@
import org.usfirst.frc.team1002.robot.subsystems.Drive;
import org.usfirst.frc.team1002.robot.subsystems.ExtArmSystem;
import org.usfirst.frc.team1002.robot.subsystems.ForkSystem;
import org.usfirst.frc.team1002.robot.subsystems.LiftSystem;

import edu.wpi.first.wpilibj.IterativeRobot;
import edu.wpi.first.wpilibj.Joystick;
import edu.wpi.first.wpilibj.command.Command;
import edu.wpi.first.wpilibj.command.Scheduler;
import edu.wpi.first.wpilibj.livewindow.LiveWindow;
Expand All @@ -16,18 +18,19 @@
public class Robot extends IterativeRobot {

// Static instances of systems
public static final Joystick joystickMove = new Joystick(RobotMap.stick[0]);
public static final Drive drive = new Drive();
public static final ForkSystem forkSystem = new ForkSystem();
public static final LiftSystem liftSystem = new LiftSystem();
public static final ExtArmSystem extArmSystem = new ExtArmSystem();
public static final Dashboard dash = new Dashboard();
public static OI oi;

// Secondary handlers
public static OI oi;
// Camera
public static AxisCamera camera;

// Secondary handlers
private Command auto;

private Command publishDash;

@Override
Expand Down Expand Up @@ -60,6 +63,12 @@ public void teleopInit() {
Scheduler.getInstance().add(publishDash);
}

@Override
public void teleopPeriodic() {
Scheduler.getInstance().run();
Drive.move(joystickMove);
}

@Override
public void testPeriodic() {
LiveWindow.run();
Expand Down
1 change: 1 addition & 0 deletions src/org/usfirst/frc/team1002/robot/commands/Lift.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.usfirst.frc.team1002.robot.commands;

import org.usfirst.frc.team1002.robot.Robot;
import org.usfirst.frc.team1002.robot.subsystems.LiftSystem;

public class Lift extends MotorCommand {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import org.usfirst.frc.team1002.robot.Robot;
import org.usfirst.frc.team1002.robot.subsystems.Dashboard;
import org.usfirst.frc.team1002.robot.subsystems.ForkSystem;
import org.usfirst.frc.team1002.robot.subsystems.LiftSystem;

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

Expand Down
37 changes: 37 additions & 0 deletions src/org/usfirst/frc/team1002/robot/subsystems/LiftSystem.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package org.usfirst.frc.team1002.robot.subsystems;

import org.usfirst.frc.team1002.robot.RobotMap;
import org.usfirst.frc.team1002.robot.commands.Lift;

import edu.wpi.first.wpilibj.CANTalon;
import edu.wpi.first.wpilibj.DigitalInput;
import edu.wpi.first.wpilibj.command.Subsystem;

public class LiftSystem extends Subsystem {
public static CANTalon liftMotor;

public static DigitalInput limitSensorTop;
public static DigitalInput limitSensorBot;

/**
* Internal lift speed setter. Use the Lift command instead.
*
* @param speed Internal speed value.
*/
public static void lift(double speed) {
if (limitSensorBot.get() && speed < 0 || limitSensorTop.get() && speed > 0 && !Dashboard.getButton(0)) speed = 0;
liftMotor.set(speed);
}

public LiftSystem() {
liftMotor = new CANTalon(RobotMap.liftMotor);
limitSensorTop = new DigitalInput(RobotMap.limitSwitches[0]);
limitSensorBot = new DigitalInput(RobotMap.limitSwitches[1]);
lift(0);
}

@Override
public void initDefaultCommand() {
setDefaultCommand(new Lift(0));
}
}

0 comments on commit 7f629b5

Please sign in to comment.