Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#472] Retuned and made spot for tuning #480

Merged
merged 1 commit into from
Mar 23, 2024
Merged
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
56 changes: 41 additions & 15 deletions src/main/java/frc/robot/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@ public static final boolean isMercury() {

public class DrivetrainConstants { // TODO Get new for new robot
public static final double MaxSpeed = 6; // 6 meters per second desired top speed
private static final double WHEELBASE = TunerConstants.kFrontLeftXPosInches * 2; // 2 * x distance from center
// of robot to wheel
private static final double WHEELBASE = TunerConstants.kFrontLeftXPosInches * 2; // 2 * x distance from center of robot to wheel
public static final double MaxAngularRate = 2 * Math.PI * ( // convert to radians per second
TunerConstants.kSpeedAt12VoltsMps / Math.PI * Math.sqrt(2 * Math.pow(WHEELBASE, 2))); // free speed / circumference of circle with radius of wheelbase

Expand Down Expand Up @@ -132,8 +131,7 @@ public static class AutonomousConstants {

public static final double CONTROL_LOOP_PERIOD = 0.01;

public static final PathConstraints PATH_CONSTRAINTS = new PathConstraints(2.0, 1, 1.0, 0.5); // TODO get
// constants
public static final PathConstraints PATH_CONSTRAINTS = new PathConstraints(2.0, 1, 1.0, 0.5); // TODO get constants

public static final double BLUE_CHASE_BOUNDARY = 8.5; // The highest X value the robot can be at before ending.
// Prevents going over center line.
Expand Down Expand Up @@ -426,19 +424,19 @@ public class FlywheelConstants {
public static final double TOP_1_MOTOR_KA = 0;

// SLOT 0 BOTTOM, 0 - 49 RPS
public static final double BOTTOM_0_MOTOR_KP = 0.15;
public static final double BOTTOM_0_MOTOR_KP = 0.155;
public static final double BOTTOM_0_MOTOR_KI = 0;
public static final double BOTTOM_0_MOTOR_KD = 0;
public static final double BOTTOM_0_MOTOR_KS = 0.3;
public static final double BOTTOM_0_MOTOR_KV = 0.11;
public static final double BOTTOM_0_MOTOR_KS = 0.35;
public static final double BOTTOM_0_MOTOR_KV = 0.112;
public static final double BOTTOM_0_MOTOR_KA = 0;

// SLOT 1 BOTTOM, 50 - 107 RPS
public static final double BOTTOM_1_MOTOR_KP = 0.16;
public static final double BOTTOM_1_MOTOR_KP = 0.15;
public static final double BOTTOM_1_MOTOR_KI = 0;
public static final double BOTTOM_1_MOTOR_KD = 0;
public static final double BOTTOM_1_MOTOR_KS = 0.3;
public static final double BOTTOM_1_MOTOR_KV = 0.1155;
public static final double BOTTOM_1_MOTOR_KS = 0.35;
public static final double BOTTOM_1_MOTOR_KV = 0.114;
public static final double BOTTOM_1_MOTOR_KA = 0;

public static final double RPM_TOLERANCE = 50d;
Expand Down Expand Up @@ -540,7 +538,7 @@ public class ShooterConstants {
public static final double FAR_WING_X = 3.3;

// Distance in meters, angle in degrees
public static final InterpolationMap ANGLE_MAP = new InterpolationMap() {
public static final InterpolationMap TUBE_ANGLE_MAP = new InterpolationMap() {
{
// As distance gets smaller angle goes up
put(1.21d, 52d);
Expand All @@ -554,7 +552,35 @@ public class ShooterConstants {
};

// Distance in meters, speed in RPM
public static final InterpolationMap SPEED_MAP = new InterpolationMap() {
public static final InterpolationMap TUBE_SPEED_MAP = new InterpolationMap() {
{
// As distance get smaller RPM gets smaller
put(1.21d, 2000d);
put(2d, 2500d);
put(2.5d, 3000d);
put(3d, 3500d);
put(3.5d, 4000d);
put(4.09d, 3600d);
put(4.86d, 4600d);
}
};

// Distance in meters, angle in degrees
public static final InterpolationMap STEALTH_ANGLE_MAP = new InterpolationMap() {
{
// As distance gets smaller angle goes up
put(1.21d, 52d);
put(2d, 45d);
put(2.5d, 41.5d);
put(3d, 37d);
put(3.5d, 30d);
put(4.09d, 26.5d);
put(4.86, 26.5d);
}
};

// Distance in meters, speed in RPM
public static final InterpolationMap STEALTH_SPEED_MAP = new InterpolationMap() {
{
// As distance get smaller RPM gets smaller
put(1.21d, 2000d);
Expand Down Expand Up @@ -655,9 +681,9 @@ public class LEDsConstants {

public static final Map<Integer, Integer> STRAND_LENGTH = new HashMap<Integer, Integer>() {
{
put(-1, LEDsConstants.LED_LENGTH);
put(0, 14);
put(1, 14);
put(-1, LEDsConstants.LED_LENGTH);
put(0, 14);
put(1, 14);
}
};

Expand Down
11 changes: 9 additions & 2 deletions src/main/java/frc/robot/command/shoot/SmartShoot.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import edu.wpi.first.wpilibj.DataLogManager;
import edu.wpi.first.util.datalog.DoubleLogEntry;
import edu.wpi.first.util.datalog.StringLogEntry;
import frc.robot.Constants;
import frc.robot.RobotContainer;
import frc.robot.Constants.CandConstants;
import frc.robot.Constants.LEDsConstants.LED_STATES;
Expand Down Expand Up @@ -144,7 +145,10 @@ public boolean onTarget() {
* @return Angle to set pivot to
*/
public double calculateTargetAngle(double distance) {
return ShooterConstants.ANGLE_MAP.get(distance);
if(Constants.isMercury()){
return ShooterConstants.TUBE_ANGLE_MAP.get(distance);
}
return ShooterConstants.STEALTH_ANGLE_MAP.get(distance);
}

/**
Expand All @@ -153,6 +157,9 @@ public double calculateTargetAngle(double distance) {
* @return RPM to set the Flywheels
*/
public double calculateTargetRPM(double distance) {
return ShooterConstants.SPEED_MAP.get(distance);
if(Constants.isMercury()){
return ShooterConstants.TUBE_SPEED_MAP.get(distance);
}
return ShooterConstants.STEALTH_SPEED_MAP.get(distance);
}
}
11 changes: 9 additions & 2 deletions src/main/java/frc/robot/command/shoot/preAim.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package frc.robot.command.shoot;

import edu.wpi.first.wpilibj2.command.Command;
import frc.robot.Constants;
import frc.robot.Constants.ShooterConstants;
import frc.robot.subsystems.Flywheel;
import frc.robot.subsystems.Pivot;
Expand Down Expand Up @@ -49,7 +50,10 @@ public boolean isFinished() {
* @return Angle to set pivot to
*/
public double calculateTargetAngle(double distance) {
return ShooterConstants.ANGLE_MAP.get(distance);
if(Constants.isMercury()){
return ShooterConstants.TUBE_ANGLE_MAP.get(distance);
}
return ShooterConstants.STEALTH_ANGLE_MAP.get(distance);
}

/**
Expand All @@ -59,6 +63,9 @@ public double calculateTargetAngle(double distance) {
* @return RPM to set the Flywheels
*/
public double calculateTargetRPM(double distance) {
return ShooterConstants.SPEED_MAP.get(distance);
if(Constants.isMercury()){
return ShooterConstants.TUBE_SPEED_MAP.get(distance);
}
return ShooterConstants.STEALTH_SPEED_MAP.get(distance);
}
}
Loading