diff --git a/2019robot/build.gradle b/2019robot/build.gradle index f15e84c..d4fbe1c 100644 --- a/2019robot/build.gradle +++ b/2019robot/build.gradle @@ -1,6 +1,6 @@ plugins { id "java" - id "edu.wpi.first.GradleRIO" version "2019.1.1" + id "edu.wpi.first.GradleRIO" version "2019.2.1" } def ROBOT_MAIN_CLASS = "org.usfirst.frc4388.robot.Main" @@ -50,7 +50,7 @@ dependencies { nativeZip wpi.deps.vendor.jni(wpi.platforms.roborio) nativeDesktopZip wpi.deps.vendor.jni(wpi.platforms.desktop) testCompile 'junit:junit:4.12' - compile pathfinder() + //compile pathfinder() } // Setting up my Jar File. In this case, adding all libraries into the main jar ('fat jar') diff --git a/2019robot/src/main/java/org/usfirst/frc4388/robot/Robot.java b/2019robot/src/main/java/org/usfirst/frc4388/robot/Robot.java index 5d66455..8baa5be 100644 --- a/2019robot/src/main/java/org/usfirst/frc4388/robot/Robot.java +++ b/2019robot/src/main/java/org/usfirst/frc4388/robot/Robot.java @@ -34,7 +34,8 @@ public class Robot extends IterativeRobot public static final Arm arm = new Arm(); public static final Climber climber = new Climber(); - public static final Pnumatics pnumatics = new Pnumatics(); + public static final Pnumatics pnumatics = new Pnumatics(); + public static final Rangefinder rangefinder = new Rangefinder(); public static final long periodMS = 10; public static final ControlLooper controlLoop = new ControlLooper("Main control loop", periodMS); diff --git a/2019robot/src/main/java/org/usfirst/frc4388/robot/commands/LaserToDash.java b/2019robot/src/main/java/org/usfirst/frc4388/robot/commands/LaserToDash.java new file mode 100644 index 0000000..c3a1ad5 --- /dev/null +++ b/2019robot/src/main/java/org/usfirst/frc4388/robot/commands/LaserToDash.java @@ -0,0 +1,50 @@ +/*----------------------------------------------------------------------------*/ +/* Copyright (c) 2018 FIRST. All Rights Reserved. */ +/* Open Source Software - may be modified and shared by FRC teams. The code */ +/* must be accompanied by the FIRST BSD license file in the root directory of */ +/* the project. */ +/*----------------------------------------------------------------------------*/ + +package org.usfirst.frc4388.robot.commands; + +import org.usfirst.frc4388.robot.Robot; + +import edu.wpi.first.wpilibj.command.Command; +import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard; + +public class LaserToDash extends Command { + public LaserToDash() { + // Use requires() here to declare subsystem dependencies + // eg. requires(chassis); + requires(Robot.rangefinder); + } + + // Called just before this Command runs the first time + @Override + protected void initialize() { + + } + + // Called repeatedly when this Command is scheduled to run + @Override + protected void execute() { + SmartDashboard.putNumber("Laser Raw Out", Robot.rangefinder.getDistance()); + } + + // Make this return true when this Command no longer needs to run execute() + @Override + protected boolean isFinished() { + return false; + } + + // Called once after isFinished returns true + @Override + protected void end() { + } + + // Called when another command which requires one or more of the same + // subsystems is scheduled to run + @Override + protected void interrupted() { + } +} diff --git a/2019robot/src/main/java/org/usfirst/frc4388/robot/subsystems/Rangefinder.java b/2019robot/src/main/java/org/usfirst/frc4388/robot/subsystems/Rangefinder.java new file mode 100644 index 0000000..373ab6c --- /dev/null +++ b/2019robot/src/main/java/org/usfirst/frc4388/robot/subsystems/Rangefinder.java @@ -0,0 +1,34 @@ +/*----------------------------------------------------------------------------*/ +/* Copyright (c) 2018 FIRST. All Rights Reserved. */ +/* Open Source Software - may be modified and shared by FRC teams. The code */ +/* must be accompanied by the FIRST BSD license file in the root directory of */ +/* the project. */ +/*----------------------------------------------------------------------------*/ + +package org.usfirst.frc4388.robot.subsystems; + +import org.usfirst.frc4388.robot.Constants; +import org.usfirst.frc4388.robot.commands.LaserToDash; + +import edu.wpi.first.wpilibj.SerialPort; +import edu.wpi.first.wpilibj.SerialPort.Port; +import edu.wpi.first.wpilibj.command.Subsystem; + +/** + * Add your docs here. + */ +public class Rangefinder extends Subsystem { + // Put methods for controlling this subsystem + // here. Call these from Commands. + private SerialPort laser1 = new SerialPort(9600, Port.kOnboard); + + @Override + public void initDefaultCommand() { + // Set the default command for a subsystem here. + // setDefaultCommand(new MySpecialCommand()); + setDefaultCommand(new LaserToDash()); + } + public double getDistance(){ + return Double.valueOf(laser1.readString()); + } +}