Skip to content

Commit

Permalink
Merge pull request #149 from frc5024/wpi2021
Browse files Browse the repository at this point in the history
  • Loading branch information
ewpratten authored Nov 8, 2020
2 parents 0660536 + a228b7f commit 2824046
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 4 deletions.
6 changes: 6 additions & 0 deletions .wpilib/wpilib_preferences.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"currentLanguage": "java",
"enableCppIntellisense": false,
"projectYear": "2021",
"teamNumber": 5024
}
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ buildscript {
dependencies {
// Update this version number to update GradleRIO
// Also update the number below
classpath "edu.wpi.first:GradleRIO:2020.+"
classpath "edu.wpi.first:GradleRIO:2021.+"
}
}

Expand Down
3 changes: 2 additions & 1 deletion gradle5k/gradle5k.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ apply plugin: "edu.wpi.first.GradleRIO"
def versions = [

// Core FRC libraries
wpilib: "2020.3.+" // See: https://github.com/wpilibsuite/allwpilib/releases
// Using a "+" here will allow you to use beta versions of libraries
wpilib: "2021.1.1-alpha-1" // See: https://github.com/wpilibsuite/allwpilib/releases
// ctre "5.+" // See: http://devsite.ctr-electronics.com/maven/release/com/ctre/phoenix/wpiapi-java/
// navx "3.+" // See: https://www.kauailabs.com/dist/frc/2020/navx_frc.json (Check ["javaDependencies"][0]["version"])
// rev_color "1.+" // See: https://github.com/REVrobotics/Color-Sensor-v3/releases
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,21 @@
import edu.wpi.first.wpilibj.geometry.Pose2d;
import edu.wpi.first.wpilibj.geometry.Rotation2d;
import edu.wpi.first.wpilibj.geometry.Translation2d;
import edu.wpi.first.wpilibj.simulation.Field2d;
import edu.wpi.first.wpilibj2.command.SubsystemBase;
import io.github.frc5024.common_drive.gearing.Gear;
import io.github.frc5024.lib5k.bases.drivetrain.commands.PathFollowerCommand;
import io.github.frc5024.lib5k.bases.drivetrain.commands.TurnToCommand;
import io.github.frc5024.lib5k.hardware.common.drivebase.IDifferentialDrivebase;
import io.github.frc5024.lib5k.logging.RobotLogger;
import io.github.frc5024.lib5k.utils.FRCFieldConstants;
import io.github.frc5024.lib5k.utils.interfaces.SafeSystem;
import io.github.frc5024.libkontrol.statemachines.StateMachine;
import io.github.frc5024.libkontrol.statemachines.StateMetadata;
import io.github.frc5024.purepursuit.pathgen.Path;

public abstract class AbstractDriveTrain extends SubsystemBase implements IDifferentialDrivebase, SafeSystem, AutoCloseable {
public abstract class AbstractDriveTrain extends SubsystemBase
implements IDifferentialDrivebase, SafeSystem, AutoCloseable {

// Logging
protected RobotLogger logger = RobotLogger.getInstance();
Expand All @@ -35,6 +38,9 @@ protected enum State {
private Translation2d goalPoseEpsilon = null;
private boolean waitingForNextLoop = false;

// Simulation
private Field2d simField = new Field2d();

/**
* Create an AbstractDriveTrain
*/
Expand Down Expand Up @@ -205,6 +211,9 @@ public void periodic() {
// Run state machine
stateMachine.update();
waitingForNextLoop = false;

// Save the field location
simField.setRobotPose(getPose().plus(FRCFieldConstants.LIB5K_TO_WPILIB_COORDINATE_TRANSFORM));
}

/**
Expand Down Expand Up @@ -271,7 +280,7 @@ public void reset() {

@Override
public void close() throws Exception {

}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package io.github.frc5024.lib5k.utils;

import edu.wpi.first.wpilibj.geometry.Rotation2d;
import edu.wpi.first.wpilibj.geometry.Transform2d;
import edu.wpi.first.wpilibj.geometry.Translation2d;
import edu.wpi.first.wpilibj.util.Units;

/**
* Standard FRC field measurements. Anything year-specific should be added as
* needed
*/
public class FRCFieldConstants {

public static final Translation2d FIELD_SIZE = new Translation2d(Units.inchesToMeters(629.25),
Units.inchesToMeters(323.25));
public static final Translation2d HALF_FIELD_SIZE = FIELD_SIZE.div(2);
public static final Translation2d HALF_FIELD_WIDTH = new Translation2d(0, HALF_FIELD_SIZE.getY());
public static final Translation2d HALF_FIELD_LENGTH = new Translation2d(HALF_FIELD_SIZE.getX(), 0);

// Transformation that will convert a Lib5K coordinate to a WPILib coordinate
public static final Transform2d LIB5K_TO_WPILIB_COORDINATE_TRANSFORM = new Transform2d(HALF_FIELD_WIDTH, new Rotation2d());

}

0 comments on commit 2824046

Please sign in to comment.