2023-01-07 13:36:56 -07:00
|
|
|
/*----------------------------------------------------------------------------*/
|
|
|
|
|
/* Copyright (c) 2018-2019 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 frc4388.robot;
|
|
|
|
|
|
|
|
|
|
import com.ctre.phoenix.motorcontrol.can.WPI_TalonFX;
|
2023-01-14 12:58:18 -07:00
|
|
|
import com.ctre.phoenix.sensors.CANCoder;
|
2023-01-14 13:20:04 -07:00
|
|
|
import com.ctre.phoenix.sensors.WPI_Pigeon2;
|
2023-01-07 13:36:56 -07:00
|
|
|
|
2023-01-07 14:23:01 -07:00
|
|
|
import edu.wpi.first.wpilibj.motorcontrol.Spark;
|
2023-01-07 13:36:56 -07:00
|
|
|
import frc4388.robot.Constants.LEDConstants;
|
2023-01-14 12:58:18 -07:00
|
|
|
import frc4388.robot.Constants.SwerveDriveConstants;
|
2023-01-14 13:20:04 -07:00
|
|
|
import frc4388.robot.subsystems.SwerveModule;
|
2023-01-21 15:16:22 -07:00
|
|
|
import frc4388.utility.RobotEncoder;
|
2023-01-07 13:36:56 -07:00
|
|
|
import frc4388.utility.RobotGyro;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Defines and holds all I/O objects on the Roborio. This is useful for unit
|
|
|
|
|
* testing and modularization.
|
|
|
|
|
*/
|
|
|
|
|
public class RobotMap {
|
2023-01-20 21:04:58 -07:00
|
|
|
// private WPI_Pigeon2 m_pigeon2 = new WPI_Pigeon2(14);
|
|
|
|
|
// public RobotGyro gyro = new RobotGyro(m_pigeon2);
|
2023-01-07 13:36:56 -07:00
|
|
|
|
|
|
|
|
|
2023-01-14 13:20:04 -07:00
|
|
|
public SwerveModule leftFront;
|
|
|
|
|
public SwerveModule rightFront;
|
|
|
|
|
public SwerveModule leftBack;
|
|
|
|
|
public SwerveModule rightBack;
|
|
|
|
|
|
|
|
|
|
|
2023-01-14 12:58:18 -07:00
|
|
|
public RobotMap() {
|
|
|
|
|
configureLEDMotorControllers();
|
|
|
|
|
configureDriveMotors();
|
|
|
|
|
}
|
2023-01-07 13:36:56 -07:00
|
|
|
|
2023-01-14 12:58:18 -07:00
|
|
|
/* LED Subsystem */
|
2023-01-20 21:04:58 -07:00
|
|
|
// public final Spark LEDController = new Spark(LEDConstants.LED_SPARK_ID);
|
2023-01-07 13:36:56 -07:00
|
|
|
|
2023-01-14 12:58:18 -07:00
|
|
|
void configureLEDMotorControllers() {
|
2023-01-07 13:36:56 -07:00
|
|
|
|
2023-01-14 12:58:18 -07:00
|
|
|
}
|
2023-01-07 13:36:56 -07:00
|
|
|
|
2023-01-14 12:58:18 -07:00
|
|
|
// swerve drive subsystem
|
|
|
|
|
public final WPI_TalonFX leftFrontWheel = new WPI_TalonFX(SwerveDriveConstants.IDs.LEFT_FRONT_WHEEL_ID);
|
|
|
|
|
public final WPI_TalonFX leftFrontSteer = new WPI_TalonFX(SwerveDriveConstants.IDs.LEFT_FRONT_STEER_ID);
|
|
|
|
|
public final CANCoder leftFrontEncoder = new CANCoder(SwerveDriveConstants.IDs.LEFT_FRONT_ENCODER_ID);
|
2023-01-21 15:16:22 -07:00
|
|
|
//public final RobotEncoder leftFrontEncoder = new RobotEncoder(SwerveDriveConstants.IDs.LEFT_FRONT_ENCODER_ID, 268.900);
|
2023-01-14 12:58:18 -07:00
|
|
|
|
|
|
|
|
public final WPI_TalonFX rightFrontWheel = new WPI_TalonFX(SwerveDriveConstants.IDs.RIGHT_FRONT_WHEEL_ID);
|
|
|
|
|
public final WPI_TalonFX rightFrontSteer = new WPI_TalonFX(SwerveDriveConstants.IDs.RIGHT_FRONT_STEER_ID);
|
|
|
|
|
public final CANCoder rightFrontEncoder = new CANCoder(SwerveDriveConstants.IDs.RIGHT_FRONT_ENCODER_ID);
|
2023-01-21 15:16:22 -07:00
|
|
|
//public final RobotEncoder rightFrontEncoder = new RobotEncoder(SwerveDriveConstants.IDs.RIGHT_FRONT_ENCODER_ID, 266.700);
|
2023-01-14 12:58:18 -07:00
|
|
|
|
|
|
|
|
public final WPI_TalonFX leftBackWheel = new WPI_TalonFX(SwerveDriveConstants.IDs.LEFT_BACK_WHEEL_ID);
|
|
|
|
|
public final WPI_TalonFX leftBackSteer = new WPI_TalonFX(SwerveDriveConstants.IDs.LEFT_BACK_STEER_ID);
|
|
|
|
|
public final CANCoder leftBackEncoder = new CANCoder(SwerveDriveConstants.IDs.LEFT_BACK_ENCODER_ID);
|
2023-01-21 15:16:22 -07:00
|
|
|
//public final RobotEncoder leftBackEncoder = new RobotEncoder(SwerveDriveConstants.IDs.LEFT_BACK_ENCODER_ID, 268.285);
|
2023-01-14 12:58:18 -07:00
|
|
|
|
|
|
|
|
public final WPI_TalonFX rightBackWheel = new WPI_TalonFX(SwerveDriveConstants.IDs.RIGHT_BACK_WHEEL_ID);
|
|
|
|
|
public final WPI_TalonFX rightBackSteer = new WPI_TalonFX(SwerveDriveConstants.IDs.RIGHT_BACK_STEER_ID);
|
|
|
|
|
public final CANCoder rightBackEncoder = new CANCoder(SwerveDriveConstants.IDs.RIGHT_BACK_ENCODER_ID);
|
2023-01-21 15:16:22 -07:00
|
|
|
//public final RobotEncoder rightBackEncoder = new RobotEncoder(SwerveDriveConstants.IDs.RIGHT_BACK_ENCODER_ID, 86.965);
|
2023-01-14 12:58:18 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
void configureDriveMotors() {
|
|
|
|
|
// config factory default
|
|
|
|
|
leftFrontWheel.configFactoryDefault();
|
|
|
|
|
leftFrontSteer.configFactoryDefault();
|
|
|
|
|
|
|
|
|
|
rightFrontWheel.configFactoryDefault();
|
|
|
|
|
rightFrontSteer.configFactoryDefault();
|
|
|
|
|
|
|
|
|
|
leftBackWheel.configFactoryDefault();
|
|
|
|
|
leftBackSteer.configFactoryDefault();
|
|
|
|
|
|
|
|
|
|
rightBackWheel.configFactoryDefault();
|
|
|
|
|
rightBackSteer.configFactoryDefault();
|
|
|
|
|
|
|
|
|
|
// config open loop ramp
|
|
|
|
|
leftFrontWheel.configOpenloopRamp(SwerveDriveConstants.Configurations.OPEN_LOOP_RAMP_RATE, SwerveDriveConstants.TIMEOUT_MS);
|
|
|
|
|
leftFrontSteer.configOpenloopRamp(SwerveDriveConstants.Configurations.OPEN_LOOP_RAMP_RATE, SwerveDriveConstants.TIMEOUT_MS);
|
|
|
|
|
|
|
|
|
|
rightFrontWheel.configOpenloopRamp(SwerveDriveConstants.Configurations.OPEN_LOOP_RAMP_RATE, SwerveDriveConstants.TIMEOUT_MS);
|
|
|
|
|
rightFrontSteer.configOpenloopRamp(SwerveDriveConstants.Configurations.OPEN_LOOP_RAMP_RATE, SwerveDriveConstants.TIMEOUT_MS);
|
|
|
|
|
|
|
|
|
|
leftBackWheel.configOpenloopRamp(SwerveDriveConstants.Configurations.OPEN_LOOP_RAMP_RATE, SwerveDriveConstants.TIMEOUT_MS);
|
|
|
|
|
leftBackSteer.configOpenloopRamp(SwerveDriveConstants.Configurations.OPEN_LOOP_RAMP_RATE, SwerveDriveConstants.TIMEOUT_MS);
|
|
|
|
|
|
|
|
|
|
rightBackWheel.configOpenloopRamp(SwerveDriveConstants.Configurations.OPEN_LOOP_RAMP_RATE, SwerveDriveConstants.TIMEOUT_MS);
|
|
|
|
|
rightBackSteer.configOpenloopRamp(SwerveDriveConstants.Configurations.OPEN_LOOP_RAMP_RATE, SwerveDriveConstants.TIMEOUT_MS);
|
|
|
|
|
|
|
|
|
|
// config closed loop ramp
|
|
|
|
|
leftFrontWheel.configClosedloopRamp(SwerveDriveConstants.Configurations.CLOSED_LOOP_RAMP_RATE, SwerveDriveConstants.TIMEOUT_MS);
|
|
|
|
|
leftFrontSteer.configClosedloopRamp(SwerveDriveConstants.Configurations.CLOSED_LOOP_RAMP_RATE, SwerveDriveConstants.TIMEOUT_MS);
|
|
|
|
|
|
|
|
|
|
rightFrontWheel.configClosedloopRamp(SwerveDriveConstants.Configurations.CLOSED_LOOP_RAMP_RATE, SwerveDriveConstants.TIMEOUT_MS);
|
|
|
|
|
rightFrontSteer.configClosedloopRamp(SwerveDriveConstants.Configurations.CLOSED_LOOP_RAMP_RATE, SwerveDriveConstants.TIMEOUT_MS);
|
|
|
|
|
|
|
|
|
|
leftBackWheel.configClosedloopRamp(SwerveDriveConstants.Configurations.CLOSED_LOOP_RAMP_RATE, SwerveDriveConstants.TIMEOUT_MS);
|
|
|
|
|
leftBackSteer.configClosedloopRamp(SwerveDriveConstants.Configurations.CLOSED_LOOP_RAMP_RATE, SwerveDriveConstants.TIMEOUT_MS);
|
|
|
|
|
|
|
|
|
|
rightBackWheel.configClosedloopRamp(SwerveDriveConstants.Configurations.CLOSED_LOOP_RAMP_RATE, SwerveDriveConstants.TIMEOUT_MS);
|
|
|
|
|
rightBackSteer.configClosedloopRamp(SwerveDriveConstants.Configurations.CLOSED_LOOP_RAMP_RATE, SwerveDriveConstants.TIMEOUT_MS);
|
|
|
|
|
|
|
|
|
|
// config neutral deadband
|
2023-01-21 15:16:22 -07:00
|
|
|
leftFrontSteer.configNeutralDeadband(SwerveDriveConstants.Configurations.NEUTRAL_DEADBAND, SwerveDriveConstants.TIMEOUT_MS);
|
|
|
|
|
leftFrontWheel.configNeutralDeadband(SwerveDriveConstants.Configurations.NEUTRAL_DEADBAND, SwerveDriveConstants.TIMEOUT_MS);
|
2023-01-14 12:58:18 -07:00
|
|
|
|
2023-01-21 15:16:22 -07:00
|
|
|
rightFrontWheel.configNeutralDeadband(SwerveDriveConstants.Configurations.NEUTRAL_DEADBAND, SwerveDriveConstants.TIMEOUT_MS);
|
|
|
|
|
rightFrontSteer.configNeutralDeadband(SwerveDriveConstants.Configurations.NEUTRAL_DEADBAND, SwerveDriveConstants.TIMEOUT_MS);
|
2023-01-14 12:58:18 -07:00
|
|
|
|
2023-01-21 15:16:22 -07:00
|
|
|
leftBackWheel.configNeutralDeadband(SwerveDriveConstants.Configurations.NEUTRAL_DEADBAND, SwerveDriveConstants.TIMEOUT_MS);
|
|
|
|
|
leftBackSteer.configNeutralDeadband(SwerveDriveConstants.Configurations.NEUTRAL_DEADBAND, SwerveDriveConstants.TIMEOUT_MS);
|
2023-01-14 12:58:18 -07:00
|
|
|
|
2023-01-21 15:16:22 -07:00
|
|
|
rightBackWheel.configNeutralDeadband(SwerveDriveConstants.Configurations.NEUTRAL_DEADBAND, SwerveDriveConstants.TIMEOUT_MS);
|
|
|
|
|
rightBackSteer.configNeutralDeadband(SwerveDriveConstants.Configurations.NEUTRAL_DEADBAND, SwerveDriveConstants.TIMEOUT_MS);
|
2023-01-14 12:58:18 -07:00
|
|
|
|
|
|
|
|
// config magnet offset
|
2023-01-21 15:16:22 -07:00
|
|
|
// leftFrontEncoder.configMagnetOffset(90.0); //180.0); //270);//271.58203125);//SwerveDriveConstants.Configurations.LEFT_FRONT_ENCODER_OFFSET);
|
|
|
|
|
// rightFrontEncoder.configMagnetOffset(0.0); //180.0); //270);//271.58203125);//SwerveDriveConstants.Configurations.RIGHT_FRONT_ENCODER_OFFSET);
|
|
|
|
|
// leftBackEncoder.configMagnetOffset(23.99414); //0.0); //90.0);//92.98828125);//SwerveDriveConstants.Configurations.LEFT_BACK_ENCODER_OFFSET);
|
|
|
|
|
// rightBackEncoder.configMagnetOffset(225.0); //180.0); //270.0);//267.01171875);//SwerveDriveConstants.Configurations.RIGHT_BACK_ENCODER_OFFSET);
|
2023-01-14 12:58:18 -07:00
|
|
|
|
2023-01-14 13:20:04 -07:00
|
|
|
// initialize SwerveModules
|
2023-01-21 15:16:22 -07:00
|
|
|
this.leftFront = new SwerveModule(leftFrontWheel, leftFrontSteer, leftFrontEncoder, -180.0);//, 270);//, SwerveDriveConstants.Configurations.LEFT_FRONT_ENCODER_OFFSET);
|
|
|
|
|
this.rightFront = new SwerveModule(rightFrontWheel, rightFrontSteer, rightFrontEncoder, -267.0);//, 90);//, SwerveDriveConstants.Configurations.RIGHT_FRONT_ENCODER_OFFSET);
|
|
|
|
|
this.leftBack = new SwerveModule(leftBackWheel, leftBackSteer, leftBackEncoder, -245.0);//, 90);//, SwerveDriveConstants.Configurations.LEFT_BACK_ENCODER_OFFSET);
|
|
|
|
|
this.rightBack = new SwerveModule(rightBackWheel, rightBackSteer, rightBackEncoder, -42.0);//, 273);//, SwerveDriveConstants.Configurations.RIGHT_BACK_ENCODER_OFFSET);
|
2023-01-14 13:20:04 -07:00
|
|
|
|
2023-01-14 12:58:18 -07:00
|
|
|
}
|
2023-01-07 13:36:56 -07:00
|
|
|
}
|