Skip to content

Commit

Permalink
Merge pull request #71 from Team5818/develop
Browse files Browse the repository at this point in the history
Version 1.0.0
  • Loading branch information
octylFractal authored Oct 10, 2017
2 parents 4ec1286 + 5b0057d commit e3bc5e2
Show file tree
Hide file tree
Showing 118 changed files with 4,884 additions and 1,951 deletions.
17 changes: 17 additions & 0 deletions HEADER.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
This file is part of ${name}, licensed under the GNU General Public License (GPLv3).

Copyright (c) ${organization} <${url}>
Copyright (c) contributors

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
621 changes: 621 additions & 0 deletions LICENSE.txt

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@
\_/__/ \/_/ \/_/
```
Rivera Robotics' real code for 2017.
Riviera Robotics' code for 2017.
![robot](https://i.imgur.com/cgTdZTO.jpg)
14 changes: 9 additions & 5 deletions ant-replacement.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// This file intends to replace the build.xml content of FRC.
// It may need to be updated when FRC build.xml updates occur.
buildscript {
repositories {
mavenCentral()
Expand Down Expand Up @@ -31,6 +33,7 @@ ext {
}
// === End B properties === //

// Setup a jar
jar {
manifest {
attributes(
Expand Down Expand Up @@ -74,7 +77,7 @@ List<String> getStaticIps() {
return [project.staticIP]
}
// Try each of these -- it's cheap
def possibleIps = [2, 30, 91]
def possibleIps = [2, 25, 30, 91]
int top = teamNumberInt / 100
int lower = teamNumberInt % 100
return (possibleIps.collect { lowBit -> "10.${top}.${lower}.${lowBit}" }) + project.noDnsIp
Expand Down Expand Up @@ -199,6 +202,7 @@ task checkRoboRIO(dependsOn: [checkSysProps, checkJRE]) {
description 'Checks that the roboRIO is what we expect.'
}

// Defines deploy tasks for regular and debug deploys.
void defineDeployTask(Object project, boolean debug) {
def task = project.tasks.create(name: 'deploy' + (debug ? 'Debug' : ''),
dependsOn: [shadowJar, checkRoboRIO]) {
Expand All @@ -220,12 +224,12 @@ void defineDeployTask(Object project, boolean debug) {
task.doLast {
ssh.run {
session(remotes.robotAdmin) {
println "Copying natives"
put from: natives, into: nativesTarget
//println "Copying natives"
//put from: natives, into: nativesTarget
//put from: netConsoleHost, into: "/usr/local/frc/bin/"
//execute 'chmod +x /usr/local/frc/bin/netconsole-host'
execute 'chmod -R +x /usr/local/frc/lib'
execute 'ldconfig', ignoreError: true
//execute 'chmod -R +x /usr/local/frc/lib'
//execute 'ldconfig', ignoreError: true
}
session(remotes.robot) {
println "Copying jar"
Expand Down
29 changes: 28 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ buildscript {
}
}
plugins {
id "net.ltgt.apt" version "0.9"
id "net.ltgt.apt" version "0.9"
id "com.github.hierynomus.license" version "0.13.1"
}
apply plugin: 'java'
apply plugin: 'eclipse'
Expand All @@ -41,12 +42,18 @@ repositories {
}

dependencies {
// Dependencies from /libs. These are copied from the FRC installation folder in your home directory.
compile group: 'edu.wpi', name: 'cscore', version: 'NONE'
compile group: 'edu.wpi', name: 'CTRLib', version: 'NONE'
compile group: 'edu.wpi', name: 'NetworkTables', version: 'NONE'
compile group: 'edu.wpi', name: 'opencv', version: 'NONE'
compile group: 'edu.wpi', name: 'WPILib', version: 'NONE'
compile group: 'com.kuailabs', name: 'navx_frc', version: 'NONE'

// Neat graph util
compile group: 'org.jfree', name: 'jfreechart', version: '1.0.19'

// Auto-value!
compileOnly group: 'com.google.auto.value', name: 'auto-value', version: '1.4-rc2'
apt group: 'com.google.auto.value', name: 'auto-value', version: '1.4-rc2'

Expand All @@ -58,9 +65,11 @@ eclipse.project.file.beforeMerged { proj ->
proj.natures.add('edu.wpi.first.wpilib.plugins.core.nature.FRCProjectNature')
}

// Move source into src
sourceSets.main.java.srcDirs = ['src']
sourceSets.main.resources.srcDirs = ['src']

// Setup compiling to be better.
configure([compileJava, compileTestJava]) {
options.compilerArgs += ['-Xlint:all', '-Xlint:-path']
options.deprecation = true
Expand All @@ -69,6 +78,24 @@ configure([compileJava, compileTestJava]) {
options.fork = true
}

// License configuration

license {
ext {
name = project.name
organization = project.organization
url = project.url
}
header = rootProject.file('HEADER.txt')
ignoreFailures = false
strictCheck = true
include '**/*.java'
mapping {
java = 'SLASHSTAR_STYLE'
}
}

// configurations for the ant-replacement code
ext.packageNumber = '5818'
ext.teamNumber = project.findProperty('teamNumber') ?: packageNumber
apply from: 'ant-replacement.gradle', to: project
5 changes: 5 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
name=Rogue-Cephalopod
group=org.rivierarobotics
url=https://github.com/Team5818
organization=Riviera Robotics
version=1.0.0-SNAPSHOT
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
3 changes: 1 addition & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#Wed Jan 25 22:15:40 PST 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-4.2-bin.zip
6 changes: 3 additions & 3 deletions gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ DEFAULT_JVM_OPTS=""
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"

warn ( ) {
warn () {
echo "$*"
}

die ( ) {
die () {
echo
echo "$*"
echo
Expand Down Expand Up @@ -155,7 +155,7 @@ if $cygwin ; then
fi

# Escape application args
save ( ) {
save () {
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
echo " "
}
Expand Down
Binary file added libs/com/kuailabs/navx_frc/NONE/navx_frc-NONE.jar
Binary file not shown.
1 change: 1 addition & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
rootProject.name = 'Rogue-Cephalopod'
108 changes: 75 additions & 33 deletions src/org/usfirst/frc/team5818/robot/Robot.java
Original file line number Diff line number Diff line change
@@ -1,15 +1,30 @@

/*
* This file is part of Rogue-Cephalopod, licensed under the GNU General Public License (GPLv3).
*
* Copyright (c) Riviera Robotics <https://github.com/Team5818>
* Copyright (c) contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.usfirst.frc.team5818.robot;

import org.usfirst.frc.team5818.robot.autos.NotPeteyTwoGearAuto;
import org.usfirst.frc.team5818.robot.autos.OneGearAuto;
import org.usfirst.frc.team5818.robot.autos.OneGearButFromTwoGearAuto;
import org.usfirst.frc.team5818.robot.autos.SidePegAuto;
import org.usfirst.frc.team5818.robot.autos.SlowTwoGearAuto;
import org.usfirst.frc.team5818.robot.autos.ThreeGearAuto;
import org.usfirst.frc.team5818.robot.autos.CenterOneGearAuto;
import org.usfirst.frc.team5818.robot.autos.MagicSideGear;
import org.usfirst.frc.team5818.robot.autos.TwoGearAutoLeft;
import org.usfirst.frc.team5818.robot.autos.TwoGearAutoRight;
import org.usfirst.frc.team5818.robot.commands.RequireAllSubsystems;
import org.usfirst.frc.team5818.robot.commands.TurretMoveToZero;
import org.usfirst.frc.team5818.robot.commands.placewithlimit.PlaceWithLimit;
import org.usfirst.frc.team5818.robot.commands.SetTurretAngle;
import org.usfirst.frc.team5818.robot.constants.Gear;
import org.usfirst.frc.team5818.robot.constants.Side;
import org.usfirst.frc.team5818.robot.controllers.Driver;
Expand All @@ -21,6 +36,7 @@
import org.usfirst.frc.team5818.robot.subsystems.DriveTrainSide;
import org.usfirst.frc.team5818.robot.subsystems.Turret;
import org.usfirst.frc.team5818.robot.subsystems.VisionTracker;
import org.usfirst.frc.team5818.robot.utils.MathUtil;

import edu.wpi.first.wpilibj.IterativeRobot;
import edu.wpi.first.wpilibj.command.Command;
Expand Down Expand Up @@ -49,7 +65,7 @@ public class Robot extends IterativeRobot {
public Turret turret;
public Climber climb;
public CameraController camCont;
public TurretMoveToZero turretZero;
public SetTurretAngle turretZero;
public boolean turretSafetyChecks = true;

private RequireAllSubsystems requireAllSubsystems;
Expand All @@ -65,6 +81,7 @@ public class Robot extends IterativeRobot {
*/
@Override
public void robotInit() {
/* Statically instantiate all subsystems */
runningRobot = this;
driveTrain = new DriveTrain();
vision = new VisionTracker();
Expand All @@ -75,17 +92,31 @@ public void robotInit() {
chooser = new SendableChooser<>();
camCont = new CameraController();
driver = new Driver();
turretZero = new TurretMoveToZero();
turretZero = new SetTurretAngle(Turret.TURRET_CENTER_POS);
requireAllSubsystems = new RequireAllSubsystems();

/* Old Autos -- Same as Ventura */
chooser.addObject("Do Nothing Auto", new TimedCommand(15));
chooser.addObject("One Gear Auto From Two Gear", new OneGearButFromTwoGearAuto());
chooser.addObject("Three Gear Auto", new ThreeGearAuto());
chooser.addObject("Place With Limit", new PlaceWithLimit());
chooser.addObject("Two Gear (Right)", new SlowTwoGearAuto());
// chooser.addObject("Two Gear (Left)", new NotPeteyTwoGearAuto());
chooser.addObject("Side Gear Auto", new SidePegAuto(180));
chooser.addObject("Center Two Gear (Gear Right)", new TwoGearAutoRight());
chooser.addObject("Center Two Gear (Gear Left)", new TwoGearAutoLeft());

/* Center */
chooser.addObject("Down Field 1 Gear Right", new CenterOneGearAuto(Side.RIGHT));
chooser.addObject("Down Field 1 Gear Left", new CenterOneGearAuto(Side.LEFT));

/*Side Pegs*/
chooser.addObject("Side Gear Blue Opposite", new MagicSideGear(MagicSideGear.Position.BLUE_OPPOSITE));
chooser.addObject("Side Gear Blue Boiler", new MagicSideGear(MagicSideGear.Position.BLUE_BOILER));
chooser.addObject("Side Gear Red Opposite", new MagicSideGear(MagicSideGear.Position.RED_OPPOSITE));
chooser.addObject("Side Gear Red Boiler", new MagicSideGear(MagicSideGear.Position.RED_BOILER));


SmartDashboard.putData("Auto mode", chooser);

/* Put robot in starting configuration */
vision.start();
driveTrain.shiftGears(Gear.LOW);
driveTrain.getGyro().reset();
}

/**
Expand All @@ -104,6 +135,7 @@ public void disabledInit() {
@Override
public void disabledPeriodic() {
Scheduler.getInstance().run();
printSmartDash();
}

/**
Expand All @@ -119,17 +151,10 @@ public void disabledPeriodic() {
*/
@Override
public void autonomousInit() {
autonomousCommand = new SlowTwoGearAuto();// = chooser.getSelected();

/*
* String autoSelected = SmartDashboard.getString("Auto Selector",
* "Default"); switch(autoSelected) { case "My Auto": autonomousCommand
* = new MyAutoCommand(); break; case "Default Auto": default:
* autonomousCommand = new ExampleCommand(); break; }
*/

// schedule the autonomous command (example)
driveTrain.shiftGears(Gear.LOW);
driveTrain.getGyro().zeroYaw();
driveTrain.shiftGears(Gear.HIGH);
autonomousCommand = chooser.getSelected();
if (autonomousCommand != null)
autonomousCommand.start();
}
Expand All @@ -151,11 +176,18 @@ public void teleopInit() {
// this line or comment it out.
if (autonomousCommand != null)
autonomousCommand.cancel();

/* Put robot in starting configuration */
turret.extend(false);
turret.punch(false);
driveTrain.getLeftSide().resetEnc();
driveTrain.getRightSide().resetEnc();
driveTrain.shiftGears(Gear.LOW);
driver.setupTeleopButtons();
camCont.enterGearMode();
vision.setLightsOn(false);

/* Put buttons in teleop mode */
driver.setupTeleopButtons();
}

/**
Expand Down Expand Up @@ -184,6 +216,7 @@ public void testInit() {
LiveWindow.run();
LiveWindow.setEnabled(false);
requireAllSubsystems.start();
/* Put buttons in testing mode */
driver.setupTestButtons();
}

Expand All @@ -197,20 +230,29 @@ public void testPeriodic() {
}

public void printSmartDash() {
SmartDashboard.putBoolean("VisDrive", driveTrain.isVisionDriving());
SmartDashboard.putBoolean("Passed Target", driveTrain.passedTarget());
/* Print readings from pretty much every sensor */
SmartDashboard.putBoolean("Turret Limit Switch", turret.getLimit());
SmartDashboard.putBoolean("Collector Limit Switch", collect.isLimitTriggered());
SmartDashboard.putNumber("Gyro heading", MathUtil.wrapAngleRad(driveTrain.getGyroHeading()));
SmartDashboard.putNumber("Gear X:", vision.getCurrentAngle());
SmartDashboard.putNumber("Turret Pot:", turret.getRawCounts());
SmartDashboard.putNumber("Turret Angle:", turret.getAngle());
SmartDashboard.putNumber("Sanic Reading:", driveTrain.readSanic());
SmartDashboard.putNumber("Turret Pot:", turret.getPositionRaw());
SmartDashboard.putNumber("Turret Angle:", turret.getPosition());
SmartDashboard.putNumber("Turret Speed:", turret.getVeleocity());
SmartDashboard.putNumber("Bot Current", collect.getBotCurrent());
SmartDashboard.putNumber("Arm Pos", arm.getPosition());
SmartDashboard.putNumber("Arm Raw", arm.getPositionRaw());
SmartDashboard.putNumber("Arm Vel", arm.getVelocity());
SmartDashboard.putNumber("Arm error", arm.getError());
SmartDashboard.putNumber("left drive encoder", driveTrain.getLeftSide().getSidePosition());
SmartDashboard.putNumber("right drive encoder", driveTrain.getRightSide().getSidePosition());
SmartDashboard.putNumber("left encoder raw", driveTrain.getLeftSide().getRawPos());
SmartDashboard.putNumber("right encoder raw", driveTrain.getRightSide().getRawPos());
SmartDashboard.putNumber("leftVel", driveTrain.getLeftSide().getSideVelocity());
SmartDashboard.putNumber("rightVel", driveTrain.getRightSide().getSideVelocity());
SmartDashboard.putNumber("leftVelRaw", driveTrain.getLeftSide().getRawSpeed());
SmartDashboard.putNumber("rightVelRaw", driveTrain.getRightSide().getRawSpeed());
SmartDashboard.putNumber("leftErr", driveTrain.getLeftSide().getSideError());
SmartDashboard.putNumber("rightErr", driveTrain.getRightSide().getSideError());
SmartDashboard.putBoolean("GyroCalibrating", driveTrain.getGyro().isCalibrating());
}
}
Loading

0 comments on commit e3bc5e2

Please sign in to comment.