Skip to content

Commit

Permalink
Resolve Merge conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
m10653 committed Jan 27, 2024
2 parents 479914e + c137937 commit bd40da2
Show file tree
Hide file tree
Showing 15 changed files with 532 additions and 593 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -173,3 +173,5 @@ out/
ctre_sim/
src/main/java/org/jmhsrobotics/frc2024/BuildConstants.java
*.wpilog
simgui-ds.json
simgui.json
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ def includeDesktopSupport = false
// Also defines JUnit 5.
dependencies {
implementation 'com.github.FRC-Team-620:WarCore:v1.1'
implementation 'com.github.shueja:Monologue:v1.0.0-beta4'
implementation wpi.java.deps.wpilib()
implementation wpi.java.vendor.java()

Expand Down
98 changes: 0 additions & 98 deletions simgui-ds.json

This file was deleted.

70 changes: 0 additions & 70 deletions simgui.json

This file was deleted.

146 changes: 146 additions & 0 deletions src/main/java/org/jmhsrobotics/frc2024/Constants.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
package org.jmhsrobotics.frc2024;

import com.revrobotics.CANSparkBase.IdleMode;

import edu.wpi.first.math.geometry.Translation2d;
import edu.wpi.first.math.kinematics.SwerveDriveKinematics;
import edu.wpi.first.math.util.Units;

public class Constants {
public static class SwerveConstants {
// SPARK MAX CAN IDs
public static final int kFrontLeftDrivingCanId = 10;
public static final int kRearLeftDrivingCanId = 12;
public static final int kFrontRightDrivingCanId = 11;
public static final int kRearRightDrivingCanId = 13;

public static final int kFrontLeftTurningCanId = 20;
public static final int kRearLeftTurningCanId = 22;
public static final int kFrontRightTurningCanId = 21;
public static final int kRearRightTurningCanId = 23;

public static final int kGyroCanId = 62;
public static final boolean kGyroReversed = false;

public static final double dtOffset = 0.02;

public static final double kMaxXSpeed = 0.8;
public static final double kMaxYSpeed = 0.8;
public static final double kMaxRotationSpeed = 0.8;
public static final boolean kFieldRelative = true;
public static final boolean kRateLimit = false;

// drive deadband constants
public static final double kDeadBand = 0.05;
// Driving Parameters - Note that these are not the maximum capable speeds of
// the robot, rather the allowed maximum speeds
public static final double kMaxSpeedMetersPerSecond = 4.2;
public static final double kMaxAngularSpeed = Math.PI; // radians per second

public static final double kDirectionSlewRate = 1.4; // radians per second
public static final double kMagnitudeSlewRate = 1.8; // percent per second (1 = 100%)
public static final double kRotationalSlewRate = 2.0; // percent per second (1 = 100%)

private static final double kRobotWidthWheelDifference = 1.75 * 2;

// Chassis configuration
// Distance between centers of right and left wheels on robot
public static final double kTrackWidth = Units.inchesToMeters(26 - kRobotWidthWheelDifference);
// Distance between centers of front and back wheels on robot
public static final double kWheelBase = Units.inchesToMeters(26 - kRobotWidthWheelDifference);

public static final SwerveDriveKinematics kDriveKinematics = new SwerveDriveKinematics(
new Translation2d(kWheelBase / 2, kTrackWidth / 2), new Translation2d(kWheelBase / 2, -kTrackWidth / 2),
new Translation2d(-kWheelBase / 2, kTrackWidth / 2),
new Translation2d(-kWheelBase / 2, -kTrackWidth / 2));

// Angular offsets of the modules relative to the chassis in radians
public static final double kFrontLeftChassisAngularOffset = -Math.PI / 2;
public static final double kFrontRightChassisAngularOffset = 0;
public static final double kBackLeftChassisAngularOffset = Math.PI;
public static final double kBackRightChassisAngularOffset = Math.PI / 2;
}

public enum ModuleSpeed {
HIGH(14), MEDIUM(13), LOW(12);

public final int pinionTeeth;

ModuleSpeed(int pinionTeeth) {
this.pinionTeeth = pinionTeeth;
}

}

public static final class ModuleConstants {
// The MAXSwerve module can be configured with one of three pinion gears: 12T,
// 13T, or 14T.
// This changes the drive speed of the module (a pinion gear with more teeth
// will result in a
// robot that drives faster).
public static final int kDrivingMotorPinionTeeth = ModuleSpeed.HIGH.pinionTeeth;

// Invert the turning encoder, since the output shaft rotates in the opposite
// direction of
// the steering motor in the MAXSwerve Module.
public static final boolean kTurningEncoderInverted = true;

// Calculations required for driving motor conversion factors and feed forward
public static final double kDrivingMotorFreeSpeedRps = NeoMotorConstants.kFreeSpeedRpm / 60;
public static final double kWheelDiameterMeters = 0.0762;
public static final double kWheelCircumferenceMeters = kWheelDiameterMeters * Math.PI;
// 45 teeth on the wheel's bevel gear, 22 teeth on the first-stage spur gear, 15
// teeth on the bevel pinion
public static final double kDrivingMotorReduction = (45.0 * 22) / (kDrivingMotorPinionTeeth * 15);
public static final double kDriveWheelFreeSpeedRps = (kDrivingMotorFreeSpeedRps * kWheelCircumferenceMeters)
/ kDrivingMotorReduction;

// used
public static final double kDrivingEncoderPositionFactor = (kWheelDiameterMeters * Math.PI)
/ kDrivingMotorReduction; // meters
// used
public static final double kDrivingEncoderVelocityFactor = ((kWheelDiameterMeters * Math.PI)
/ kDrivingMotorReduction) / 60.0; // meters per second

public static final double kTurningEncoderPositionFactor = (2 * Math.PI); // radians
public static final double kTurningEncoderVelocityFactor = (2 * Math.PI) / 60.0; // radians per second

public static final double kTurningEncoderPositionPIDMinInput = 0; // radians
public static final double kTurningEncoderPositionPIDMaxInput = kTurningEncoderPositionFactor; // radians

public static final double kDrivingP = 0.04;
public static final double kDrivingI = 0;
public static final double kDrivingD = 0;
public static final double kDrivingFF = 1 / kDriveWheelFreeSpeedRps;
public static final double kDrivingMinOutput = -1;
public static final double kDrivingMaxOutput = 1;

public static final double kTurningP = 1;
public static final double kTurningI = 0;
public static final double kTurningD = 0;
public static final double kTurningFF = 0;
public static final double kTurningMinOutput = -1;
public static final double kTurningMaxOutput = 1;

public static final IdleMode kDrivingMotorIdleMode = IdleMode.kBrake;
public static final IdleMode kTurningMotorIdleMode = IdleMode.kBrake;

public static final int kDrivingMotorCurrentLimit = 50; // amps
public static final int kTurningMotorCurrentLimit = 20; // amps
}

// TODO: Clean up auto constants later
public static final class AutoConstants {

}

public static final class NeoMotorConstants {
public static final double kFreeSpeedRpm = 5676;
}

public static final class LEDConstants {
public static final int LEDPortID = 9;
public static final int LEDLength = 60;
public static final int rainbowSpeed = 3;
}
}
10 changes: 8 additions & 2 deletions src/main/java/org/jmhsrobotics/frc2024/Robot.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,10 @@
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
import edu.wpi.first.wpilibj2.command.Command;
import edu.wpi.first.wpilibj2.command.CommandScheduler;
import monologue.Logged;
import monologue.Monologue;

public class Robot extends TimedRobot {
public class Robot extends TimedRobot implements Logged {
private Command autonomousCommand;

private RobotContainer m_robotContainer;
Expand All @@ -40,18 +42,22 @@ public void robotInit() {
public void setupLogs() {
if (Robot.isSimulation()) {
// Filesystem.getOperatingDirectory().getAbsolutePath().
DataLogManager.start(Filesystem.getOperatingDirectory().getAbsolutePath() + "\\logs");
DataLogManager.start(Filesystem.getOperatingDirectory().getAbsolutePath() + "/logs");
} else {
DataLogManager.start();
}
DataLogManager.logNetworkTables(true);
DriverStation.startDataLog(DataLogManager.getLog());
BuildDataLogger.LogToNetworkTables(BuildConstants.class);
BuildDataLogger.LogToWpiLib(DataLogManager.getLog(), BuildConstants.class);
boolean fileOnly = false;
boolean lazyLogging = false;
Monologue.setupMonologue(this, "Robot", fileOnly, lazyLogging);
}

@Override
public void robotPeriodic() {
Monologue.updateAll();
CommandScheduler.getInstance().run();
}

Expand Down
Loading

0 comments on commit bd40da2

Please sign in to comment.