Skip to content
Open
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
5 changes: 5 additions & 0 deletions Java/CommandBased/.classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="output" path="bin"/>
</classpath>
17 changes: 17 additions & 0 deletions Java/CommandBased/.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>CommandBased</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
13 changes: 13 additions & 0 deletions Java/jankCenterSwitch/.classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="var" path="wpilib" sourcepath="wpilib.sources"/>
<classpathentry kind="var" path="networktables" sourcepath="ntcore.sources"/>
<classpathentry kind="var" path="opencv" sourcepath="opencv.sources"/>
<classpathentry kind="var" path="cscore" sourcepath="cscore.sources"/>
<classpathentry kind="var" path="wpiutil" sourcepath="wpiutil.sources"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="var" path="USERLIBS_DIR/CTRE_Phoenix-sources.jar"/>
<classpathentry kind="var" path="USERLIBS_DIR/CTRE_Phoenix.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>
18 changes: 18 additions & 0 deletions Java/jankCenterSwitch/.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>jankCenterSwitch</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>edu.wpi.first.wpilib.plugins.core.nature.FRCProjectNature</nature>
</natures>
</projectDescription>
1 change: 1 addition & 0 deletions Java/jankCenterSwitch/bin/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/org/
4 changes: 4 additions & 0 deletions Java/jankCenterSwitch/build.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Project specific information
package=org.usfirst.frc.team1665.robot
robot.class=${package}.Robot
simulation.world.file=/usr/share/frcsim/worlds/GearsBotDemo.world
30 changes: 30 additions & 0 deletions Java/jankCenterSwitch/build.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="UTF-8"?>

<project name="FRC Deployment" default="deploy">

<!--
The following properties can be defined to override system level
settings. These should not be touched unless you know what you're
doing. The primary use is to override the wpilib version when
working with older robots that can't compile with the latest
libraries.
-->

<!-- By default the system version of WPI is used -->
<!-- <property name="version" value=""/> -->

<!-- By default the system team number is used -->
<!-- <property name="team-number" value=""/> -->

<!-- By default the target is set to 10.TE.AM.2 -->
<!-- <property name="target" value=""/> -->

<!-- Any other property in build.properties can also be overridden. -->

<property file="${user.home}/wpilib/wpilib.properties"/>
<property file="build.properties"/>
<property file="${user.home}/wpilib/java/${version}/ant/build.properties"/>

<import file="${wpilib.ant.dir}/build.xml"/>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package org.usfirst.frc.team1665.robot;

import edu.wpi.first.wpilibj.SpeedControllerGroup;
import edu.wpi.first.wpilibj.VictorSP;
import edu.wpi.first.wpilibj.drive.DifferentialDrive;

public class Drivetrain{

// Initializing left drivetrain controllers
public static VictorSP driveControllerLeft1 = new VictorSP(1);
public static VictorSP driveControllerLeft2 = new VictorSP(2);
public static SpeedControllerGroup driveControllersLeft = new SpeedControllerGroup(driveControllerLeft1,
driveControllerLeft2);

// Initializing right drivetrain controllers
public static VictorSP driveControllerRight1 = new VictorSP(2);
public static VictorSP driveControllerRight2 = new VictorSP(3);
public static SpeedControllerGroup driveControllersRight = new SpeedControllerGroup(driveControllerRight1,
driveControllerRight2);

// Initializing drivetrain
public static DifferentialDrive drivetrain = new DifferentialDrive(driveControllersLeft, driveControllersRight);


public Drivetrain() {
}

//Split stick arcade drive
public void drive(double Throttle, double Turn) {
drivetrain.arcadeDrive(Throttle,Turn);
}

}
133 changes: 133 additions & 0 deletions Java/jankCenterSwitch/src/org/usfirst/frc/team1665/robot/Robot.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2017-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.frc.team1665.robot;

import edu.wpi.first.wpilibj.Timer;
import edu.wpi.first.networktables.NetworkTable;
import edu.wpi.first.networktables.NetworkTableInstance;
import edu.wpi.first.wpilibj.DriverStation;
import edu.wpi.first.wpilibj.DriverStation.Alliance;

import edu.wpi.first.wpilibj.IterativeRobot;
import edu.wpi.first.wpilibj.smartdashboard.SendableChooser;
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;

/**
* The VM is configured to automatically run this class, and to call the
* functions corresponding to each mode, as described in the IterativeRobot
* documentation. If you change the name of this class or the package after
* creating this project, you must also update the build.properties file in the
* project.
*/
public class Robot extends IterativeRobot {
private Drivetrain drivetrain = new Drivetrain();

/**
* This function is run when the robot is first started up and should be
* used for any initialization code.
*/
@Override
public void robotInit() {
}

/**
* This autonomous (along with the chooser code above) shows how to select
* between different autonomous modes using the dashboard. The sendable
* chooser code works with the Java SmartDashboard. If you prefer the
* LabVIEW Dashboard, remove all of the chooser code and uncomment the
* getString line to get the auto name from the text box below the Gyro
*
* <p>You can add additional auto modes by adding additional comparisons to
* the switch structure below with additional strings. If using the
* SendableChooser make sure to add them to the chooser code above as well.
*/
// Variables for auto modes
private Timer driveTimer = new Timer();
int autoState;

NetworkTable table;
String gameData;
Boolean allianceColorRed;
int allianceNumber;
Boolean goesLeft = true;


public void drive(double throttle, double turn) {
drivetrain.drive(throttle, turn);
}

@Override
public void autonomousInit() {
// rest timer
driveTimer.reset();
// Start timer
driveTimer.start();

gameData = DriverStation.getInstance().getGameSpecificMessage();
allianceColorRed = DriverStation.getInstance().getAlliance() == DriverStation.Alliance.Red;
allianceNumber = DriverStation.getInstance().getLocation();


goesLeft = (gameData.charAt(0) == 'L');
}



/**
* This function is called periodically during autonomous.
*/
@Override
public void autonomousPeriodic() {
autoState = 0;
switch (autoState) {
case 0: // Drive forward a tiny bit
drive(1, 0);
if (driveTimer.get() > 1000) {
driveTimer.reset();
autoState++;
}
break;
case 1: // Turn to angle
// use game data
double turnSpeed = 0.5;
if(goesLeft) { turnSpeed = -1*turnSpeed; }
drive(0, turnSpeed);
if (driveTimer.get() > 500) {
driveTimer.reset();
autoState++;
}
break;
case 2: // Drive to Switch
drive(1, 0);
if (driveTimer.get() > 2500) {
drive(0, 0);
driveTimer.reset();
autoState++;
}
break;
case 3: // SCOREEEEEEE

// spit out here
break;
}
}

/**
* This function is called periodically during operator control.
*/
@Override
public void teleopPeriodic() {
}

/**
* This function is called periodically during test mode.
*/
@Override
public void testPeriodic() {
}
}
100 changes: 100 additions & 0 deletions Java/jankCenterSwitch/src/org/usfirst/frc/team1665/robot/Robot2.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2017-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.frc.team1665.robot;

import edu.wpi.first.wpilibj.Timer;
import edu.wpi.first.wpilibj.command.Command;
import edu.wpi.first.wpilibj.command.Scheduler;
import edu.wpi.first.networktables.NetworkTable;
import edu.wpi.first.networktables.NetworkTableInstance;
import edu.wpi.first.wpilibj.DriverStation;
import edu.wpi.first.wpilibj.DriverStation.Alliance;

import edu.wpi.first.wpilibj.IterativeRobot;
import edu.wpi.first.wpilibj.smartdashboard.SendableChooser;
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;

/**
* The VM is configured to automatically run this class, and to call the
* functions corresponding to each mode, as described in the IterativeRobot
* documentation. If you change the name of this class or the package after
* creating this project, you must also update the build.properties file in the
* project.
*/
public class Robot2 extends IterativeRobot {
private Drivetrain drivetrain = new Drivetrain();

/**
* This function is run when the robot is first started up and should be
* used for any initialization code.
*/
@Override
public void robotInit() {
}

/**
* This autonomous (along with the chooser code above) shows how to select
* between different autonomous modes using the dashboard. The sendable
* chooser code works with the Java SmartDashboard. If you prefer the
* LabVIEW Dashboard, remove all of the chooser code and uncomment the
* getString line to get the auto name from the text box below the Gyro
*
* <p>You can add additional auto modes by adding additional comparisons to
* the switch structure below with additional strings. If using the
* SendableChooser make sure to add them to the chooser code above as well.
*/
// Variables for auto modes
NetworkTable table;
String gameData;
Boolean allianceColorRed;
int allianceNumber;
Boolean goesLeft = true;

Command autonomousCommand;


@Override
public void autonomousInit() {

gameData = DriverStation.getInstance().getGameSpecificMessage();

goesLeft = (gameData.charAt(0) == 'L');

// put real drivetrain command here
autonomousCommand = new centerSwitchAuto(Drivetrain,goesLeft);

// Schedule the autonomous command (example)
if (autonomousCommand != null) {
autonomousCommand.start();
}
}



/**
* This function is called periodically during autonomous.
*/
@Override
public void autonomousPeriodic() {
Scheduler.getInstance().run();
}

/**
* This function is called periodically during operator control.
*/
@Override
public void teleopPeriodic() {
}

/**
* This function is called periodically during test mode.
*/
@Override
public void testPeriodic() {
}
}
Loading