2020-01-09 23:55:46 +00:00
|
|
|
/*----------------------------------------------------------------------------*/
|
|
|
|
|
/* Copyright (c) 2018 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.subsystems;
|
|
|
|
|
|
2020-02-10 22:47:54 -07:00
|
|
|
import java.io.File;
|
2020-02-25 23:18:17 -07:00
|
|
|
|
2020-02-07 21:49:04 -07:00
|
|
|
import com.ctre.phoenix.motorcontrol.ControlMode;
|
2020-01-23 16:42:20 -07:00
|
|
|
import com.ctre.phoenix.motorcontrol.DemandType;
|
2020-01-18 16:12:56 -07:00
|
|
|
import com.ctre.phoenix.motorcontrol.FeedbackDevice;
|
2020-01-23 16:42:20 -07:00
|
|
|
import com.ctre.phoenix.motorcontrol.FollowerType;
|
2020-01-09 23:55:46 +00:00
|
|
|
import com.ctre.phoenix.motorcontrol.NeutralMode;
|
2020-01-20 10:40:12 -07:00
|
|
|
import com.ctre.phoenix.motorcontrol.RemoteSensorSource;
|
2020-01-18 16:12:56 -07:00
|
|
|
import com.ctre.phoenix.motorcontrol.SensorTerm;
|
2020-01-20 10:40:12 -07:00
|
|
|
import com.ctre.phoenix.motorcontrol.StatusFrame;
|
2020-01-16 17:56:18 -07:00
|
|
|
import com.ctre.phoenix.motorcontrol.TalonFXControlMode;
|
2020-01-10 23:13:59 -07:00
|
|
|
import com.ctre.phoenix.motorcontrol.can.WPI_TalonFX;
|
2020-02-09 18:33:27 -07:00
|
|
|
import com.ctre.phoenix.music.Orchestra;
|
2020-01-09 18:05:16 -07:00
|
|
|
import com.ctre.phoenix.sensors.PigeonIMU;
|
2020-01-23 16:42:20 -07:00
|
|
|
import com.ctre.phoenix.sensors.PigeonIMU_StatusFrame;
|
2020-01-09 23:55:46 +00:00
|
|
|
|
2020-02-10 22:47:54 -07:00
|
|
|
import edu.wpi.first.wpilibj.Filesystem;
|
2020-02-08 13:01:25 -07:00
|
|
|
import edu.wpi.first.wpilibj.DoubleSolenoid;
|
2020-01-09 23:55:46 +00:00
|
|
|
import edu.wpi.first.wpilibj.drive.DifferentialDrive;
|
2020-02-10 20:13:15 -07:00
|
|
|
import edu.wpi.first.wpilibj.geometry.Pose2d;
|
|
|
|
|
import edu.wpi.first.wpilibj.geometry.Rotation2d;
|
|
|
|
|
import edu.wpi.first.wpilibj.kinematics.DifferentialDriveOdometry;
|
2020-02-21 16:43:42 -07:00
|
|
|
import edu.wpi.first.wpilibj.kinematics.DifferentialDriveWheelSpeeds;
|
2020-01-20 11:59:23 -07:00
|
|
|
import edu.wpi.first.wpilibj.shuffleboard.Shuffleboard;
|
|
|
|
|
import edu.wpi.first.wpilibj.smartdashboard.SendableChooser;
|
2020-01-11 10:30:37 -07:00
|
|
|
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
|
2020-01-09 23:55:46 +00:00
|
|
|
import edu.wpi.first.wpilibj2.command.SubsystemBase;
|
2020-02-25 23:18:17 -07:00
|
|
|
|
2020-01-09 23:55:46 +00:00
|
|
|
import frc4388.robot.Constants.DriveConstants;
|
2020-01-17 17:30:04 -07:00
|
|
|
import frc4388.robot.Gains;
|
2020-01-09 23:55:46 +00:00
|
|
|
|
2020-01-13 17:53:42 -07:00
|
|
|
public class Drive extends SubsystemBase {
|
2020-02-25 22:39:18 -07:00
|
|
|
/* Create Motors, Gyros, Solenoids, etc */
|
2020-02-01 15:30:41 -07:00
|
|
|
public WPI_TalonFX m_leftFrontMotor = new WPI_TalonFX(DriveConstants.DRIVE_LEFT_FRONT_CAN_ID);
|
|
|
|
|
public WPI_TalonFX m_rightFrontMotor = new WPI_TalonFX(DriveConstants.DRIVE_RIGHT_FRONT_CAN_ID);
|
|
|
|
|
public WPI_TalonFX m_leftBackMotor = new WPI_TalonFX(DriveConstants.DRIVE_LEFT_BACK_CAN_ID);
|
|
|
|
|
public WPI_TalonFX m_rightBackMotor = new WPI_TalonFX(DriveConstants.DRIVE_RIGHT_BACK_CAN_ID);
|
2020-01-09 18:05:16 -07:00
|
|
|
public static PigeonIMU m_pigeon = new PigeonIMU(DriveConstants.PIGEON_ID);
|
2020-02-25 22:39:18 -07:00
|
|
|
public DoubleSolenoid m_speedShift = new DoubleSolenoid(7,0,1);
|
|
|
|
|
public DoubleSolenoid m_coolFalcon = new DoubleSolenoid(7,3,2);
|
|
|
|
|
|
|
|
|
|
/* Drive objects to manage Drive Train */
|
2020-02-25 23:18:17 -07:00
|
|
|
public DifferentialDrive m_driveTrain;
|
2020-02-25 22:39:18 -07:00
|
|
|
public final DifferentialDriveOdometry m_odometry;
|
2020-02-25 23:18:17 -07:00
|
|
|
public Orchestra m_orchestra;
|
2020-01-09 23:55:46 +00:00
|
|
|
|
2020-02-25 22:39:18 -07:00
|
|
|
/* Low Gear Gains */
|
2020-02-25 16:15:48 -07:00
|
|
|
public static Gains m_gainsDistanceLow = DriveConstants.DRIVE_DISTANCE_GAINS_LOW;
|
|
|
|
|
public static Gains m_gainsVelocityLow = DriveConstants.DRIVE_VELOCITY_GAINS_LOW;
|
|
|
|
|
public static Gains m_gainsTurningLow = DriveConstants.DRIVE_TURNING_GAINS_LOW;
|
|
|
|
|
public static Gains m_gainsMotionMagicLow = DriveConstants.DRIVE_MOTION_MAGIC_GAINS_LOW;
|
|
|
|
|
|
2020-02-25 22:39:18 -07:00
|
|
|
/* High Gear Gains */
|
2020-02-25 16:15:48 -07:00
|
|
|
public static Gains m_gainsDistanceHigh = DriveConstants.DRIVE_DISTANCE_GAINS_HIGH;
|
|
|
|
|
public static Gains m_gainsVelocityHigh = DriveConstants.DRIVE_VELOCITY_GAINS_HIGH;
|
|
|
|
|
public static Gains m_gainsTurningHigh = DriveConstants.DRIVE_TURNING_GAINS_HIGH;
|
|
|
|
|
public static Gains m_gainsMotionMagicHigh = DriveConstants.DRIVE_MOTION_MAGIC_GAINS_HIGH;
|
2020-02-21 16:48:22 -07:00
|
|
|
|
2020-02-25 22:39:18 -07:00
|
|
|
/* Timey Whimey */
|
2020-02-25 23:34:38 -07:00
|
|
|
public long m_currentTimeMs = System.currentTimeMillis();
|
|
|
|
|
public long m_lastTimeMs = m_currentTimeMs;
|
|
|
|
|
public long m_deltaTimeMs = 0;
|
|
|
|
|
public long m_currentTimeSec = m_currentTimeMs / 1000;
|
2020-02-12 22:15:50 -07:00
|
|
|
|
2020-02-25 22:39:18 -07:00
|
|
|
/* Position Tracking */
|
|
|
|
|
public double m_rightFrontMotorPos = 0;
|
|
|
|
|
public double m_rightFrontMotorVel = 0;
|
2020-02-12 22:15:50 -07:00
|
|
|
|
2020-02-25 17:47:47 -07:00
|
|
|
public double m_totalLeftDistanceInches = 0;
|
|
|
|
|
public double m_totalRightDistanceInches = 0;
|
2020-02-25 22:39:18 -07:00
|
|
|
|
2020-02-25 23:34:38 -07:00
|
|
|
public double m_currentLeftPosTicks = 0;
|
|
|
|
|
public double m_currentRightPosTicks = 0;
|
2020-02-25 17:47:47 -07:00
|
|
|
public double m_lastLeftPosTicks = 0;
|
|
|
|
|
public double m_lastRightPosTicks = 0;
|
2020-02-25 23:18:17 -07:00
|
|
|
|
2020-02-25 22:39:18 -07:00
|
|
|
public double m_lastAngleYaw = 0;
|
|
|
|
|
public double m_currentAngleYaw = 0;
|
|
|
|
|
|
|
|
|
|
/* Smart Dashboard Objects */
|
|
|
|
|
SendableChooser<String> m_songChooser = new SendableChooser<String>();
|
|
|
|
|
|
|
|
|
|
/* Misc */
|
|
|
|
|
public boolean m_isSpeedShiftHigh;
|
2020-02-25 23:34:38 -07:00
|
|
|
String m_currentSong = "";
|
2020-02-25 17:47:47 -07:00
|
|
|
|
2020-01-09 23:55:46 +00:00
|
|
|
/**
|
|
|
|
|
* Add your docs here.
|
|
|
|
|
*/
|
2020-01-10 21:29:45 -07:00
|
|
|
public Drive() {
|
2020-01-09 23:55:46 +00:00
|
|
|
/* factory default values */
|
|
|
|
|
m_leftFrontMotor.configFactoryDefault();
|
|
|
|
|
m_rightFrontMotor.configFactoryDefault();
|
|
|
|
|
m_leftBackMotor.configFactoryDefault();
|
|
|
|
|
m_rightBackMotor.configFactoryDefault();
|
2020-02-07 17:50:23 -07:00
|
|
|
m_pigeon.configFactoryDefault();
|
|
|
|
|
resetGyroYaw();
|
2020-02-01 13:48:52 -07:00
|
|
|
|
2020-02-01 16:10:39 -07:00
|
|
|
/* flip input so forward becomes back, etc */
|
2020-02-25 23:18:17 -07:00
|
|
|
m_leftFrontMotor.setInverted(DriveConstants.isLeftMotorInverted);
|
|
|
|
|
m_rightFrontMotor.setInverted(DriveConstants.isRightMotorInverted);
|
|
|
|
|
m_leftBackMotor.setInverted(DriveConstants.isLeftMotorInverted);
|
|
|
|
|
m_rightBackMotor.setInverted(DriveConstants.isRightMotorInverted);
|
|
|
|
|
m_driveTrain.setRightSideInverted(DriveConstants.isRightArcadeInverted);
|
|
|
|
|
|
|
|
|
|
/* Config Open Loop Ramp so we don't make sudden output changes */
|
|
|
|
|
m_rightFrontMotor.configOpenloopRamp(DriveConstants.OPEN_LOOP_RAMP_RATE, DriveConstants.DRIVE_TIMEOUT_MS);
|
|
|
|
|
m_rightBackMotor.configOpenloopRamp(DriveConstants.OPEN_LOOP_RAMP_RATE, DriveConstants.DRIVE_TIMEOUT_MS);
|
|
|
|
|
m_leftFrontMotor.configOpenloopRamp(DriveConstants.OPEN_LOOP_RAMP_RATE, DriveConstants.DRIVE_TIMEOUT_MS);
|
|
|
|
|
m_leftBackMotor.configOpenloopRamp(DriveConstants.OPEN_LOOP_RAMP_RATE, DriveConstants.DRIVE_TIMEOUT_MS);
|
|
|
|
|
|
|
|
|
|
/* Config Supply Current Limit (Use only for debugging) */
|
|
|
|
|
m_rightFrontMotor.configSupplyCurrentLimit(DriveConstants.SUPPLY_CURRENT_LIMIT_CONFIG);
|
|
|
|
|
m_leftFrontMotor.configSupplyCurrentLimit(DriveConstants.SUPPLY_CURRENT_LIMIT_CONFIG);
|
|
|
|
|
m_rightBackMotor.configSupplyCurrentLimit(DriveConstants.SUPPLY_CURRENT_LIMIT_CONFIG);
|
|
|
|
|
m_leftBackMotor.configSupplyCurrentLimit(DriveConstants.SUPPLY_CURRENT_LIMIT_CONFIG);
|
|
|
|
|
|
|
|
|
|
/* Config deadbands so that */
|
|
|
|
|
m_leftBackMotor.configNeutralDeadband(DriveConstants.NEUTRAL_DEADBAND, DriveConstants.DRIVE_TIMEOUT_MS);
|
|
|
|
|
m_rightBackMotor.configNeutralDeadband(DriveConstants.NEUTRAL_DEADBAND, DriveConstants.DRIVE_TIMEOUT_MS);
|
|
|
|
|
m_leftFrontMotor.configNeutralDeadband(DriveConstants.NEUTRAL_DEADBAND, DriveConstants.DRIVE_TIMEOUT_MS);
|
|
|
|
|
m_rightFrontMotor.configNeutralDeadband(DriveConstants.NEUTRAL_DEADBAND, DriveConstants.DRIVE_TIMEOUT_MS);
|
2020-02-17 13:06:51 -07:00
|
|
|
|
|
|
|
|
/* PID for Front Motor Control in Teleop */
|
2020-02-25 23:18:17 -07:00
|
|
|
setRightMotorGains(false);
|
2020-02-07 21:49:04 -07:00
|
|
|
|
2020-02-25 23:18:17 -07:00
|
|
|
/* PID for Back Motor Control in Tank Drive Vel */
|
2020-02-17 13:06:51 -07:00
|
|
|
m_rightBackMotor.selectProfileSlot(DriveConstants.SLOT_VELOCITY, DriveConstants.PID_PRIMARY);
|
2020-02-25 16:15:48 -07:00
|
|
|
m_rightBackMotor.config_kF(DriveConstants.SLOT_VELOCITY, m_gainsVelocityLow.m_kF, DriveConstants.DRIVE_TIMEOUT_MS);
|
|
|
|
|
m_rightBackMotor.config_kP(DriveConstants.SLOT_VELOCITY, m_gainsVelocityLow.m_kP, DriveConstants.DRIVE_TIMEOUT_MS);
|
|
|
|
|
m_rightBackMotor.config_kI(DriveConstants.SLOT_VELOCITY, m_gainsVelocityLow.m_kI, DriveConstants.DRIVE_TIMEOUT_MS);
|
|
|
|
|
m_rightBackMotor.config_kD(DriveConstants.SLOT_VELOCITY, m_gainsVelocityLow.m_kD, DriveConstants.DRIVE_TIMEOUT_MS);
|
|
|
|
|
m_rightBackMotor.configClosedLoopPeakOutput(DriveConstants.SLOT_VELOCITY, m_gainsVelocityLow.m_kPeakOutput, DriveConstants.DRIVE_TIMEOUT_MS);
|
2020-02-17 13:06:51 -07:00
|
|
|
|
|
|
|
|
m_leftBackMotor.selectProfileSlot(DriveConstants.SLOT_VELOCITY, DriveConstants.PID_PRIMARY);
|
2020-02-25 16:15:48 -07:00
|
|
|
m_leftBackMotor.config_kF(DriveConstants.SLOT_VELOCITY, m_gainsVelocityLow.m_kF, DriveConstants.DRIVE_TIMEOUT_MS);
|
|
|
|
|
m_leftBackMotor.config_kP(DriveConstants.SLOT_VELOCITY, m_gainsVelocityLow.m_kP, DriveConstants.DRIVE_TIMEOUT_MS);
|
|
|
|
|
m_leftBackMotor.config_kI(DriveConstants.SLOT_VELOCITY, m_gainsVelocityLow.m_kI, DriveConstants.DRIVE_TIMEOUT_MS);
|
|
|
|
|
m_leftBackMotor.config_kD(DriveConstants.SLOT_VELOCITY, m_gainsVelocityLow.m_kD, DriveConstants.DRIVE_TIMEOUT_MS);
|
|
|
|
|
m_leftBackMotor.configClosedLoopPeakOutput(DriveConstants.SLOT_VELOCITY, m_gainsVelocityLow.m_kPeakOutput, DriveConstants.DRIVE_TIMEOUT_MS);
|
2020-02-17 13:06:51 -07:00
|
|
|
|
2020-02-25 23:18:17 -07:00
|
|
|
/* Reset Sensors for WPI_TalonFXs */
|
2020-02-10 20:13:15 -07:00
|
|
|
resetEncoders();
|
2020-02-06 18:36:04 -07:00
|
|
|
|
2020-01-20 10:40:12 -07:00
|
|
|
/* Configure the left Talon's selected sensor as local QuadEncoder */
|
2020-02-12 21:42:48 -07:00
|
|
|
m_leftFrontMotor.configSelectedFeedbackSensor( FeedbackDevice.IntegratedSensor, // Local Feedback Source
|
|
|
|
|
DriveConstants.PID_PRIMARY, // PID Index for Source [0, 1]
|
|
|
|
|
DriveConstants.DRIVE_TIMEOUT_MS); // Configuration Timeout
|
2020-02-10 20:13:15 -07:00
|
|
|
|
2020-02-17 13:06:51 -07:00
|
|
|
/* Configure the left back Talon's selected sensor as local QuadEncoder */
|
|
|
|
|
m_leftBackMotor.configSelectedFeedbackSensor( FeedbackDevice.IntegratedSensor, // Local Feedback Source
|
|
|
|
|
DriveConstants.PID_PRIMARY, // PID Index for Source [0, 1]
|
|
|
|
|
DriveConstants.DRIVE_TIMEOUT_MS); // Configuration Timeout
|
|
|
|
|
|
|
|
|
|
/* Configure the right back Talon's selected sensor as local QuadEncoder */
|
|
|
|
|
m_rightBackMotor.configSelectedFeedbackSensor( FeedbackDevice.IntegratedSensor, // Local Feedback Source
|
|
|
|
|
DriveConstants.PID_PRIMARY, // PID Index for Source [0, 1]
|
|
|
|
|
DriveConstants.DRIVE_TIMEOUT_MS); // Configuration Timeout
|
|
|
|
|
|
|
|
|
|
/* Configure the Remote Talon's selected sensor as a remote sensor for the right Talon */
|
2020-02-12 21:42:48 -07:00
|
|
|
m_rightFrontMotor.configRemoteFeedbackFilter( m_leftFrontMotor.getDeviceID(), // Device ID of Source
|
2020-02-25 23:18:17 -07:00
|
|
|
RemoteSensorSource.TalonSRX_SelectedSensor,
|
|
|
|
|
DriveConstants.REMOTE_0, // Source number [0, 1]
|
2020-02-12 21:42:48 -07:00
|
|
|
DriveConstants.DRIVE_TIMEOUT_MS); // Configuration Timeout
|
2020-02-10 20:13:15 -07:00
|
|
|
|
2020-02-25 23:18:17 -07:00
|
|
|
/* Diff Signal signal to be used for Distance*/
|
2020-02-07 20:03:13 -07:00
|
|
|
m_rightFrontMotor.configSensorTerm(SensorTerm.Diff1, FeedbackDevice.RemoteSensor0, DriveConstants.DRIVE_TIMEOUT_MS);
|
|
|
|
|
m_rightFrontMotor.configSensorTerm(SensorTerm.Diff0, FeedbackDevice.IntegratedSensor, DriveConstants.DRIVE_TIMEOUT_MS);
|
2020-01-20 10:40:12 -07:00
|
|
|
|
2020-02-25 23:18:17 -07:00
|
|
|
/* Configure Diff [Sum of both QuadEncoders] to be used for Primary PID Index */
|
|
|
|
|
m_rightFrontMotor.configSelectedFeedbackSensor( FeedbackDevice.SensorDifference,
|
|
|
|
|
DriveConstants.PID_PRIMARY,
|
|
|
|
|
DriveConstants.DRIVE_TIMEOUT_MS);
|
2020-02-10 20:13:15 -07:00
|
|
|
|
2020-02-25 23:18:17 -07:00
|
|
|
/* Configure the Pigeon IMU to the other Remote Slot available on the right Talon */
|
|
|
|
|
m_rightFrontMotor.configRemoteFeedbackFilter( m_pigeon.getDeviceID(), RemoteSensorSource.Pigeon_Yaw,
|
|
|
|
|
DriveConstants.REMOTE_1, DriveConstants.DRIVE_TIMEOUT_MS);
|
2020-01-27 19:06:23 -07:00
|
|
|
|
2020-02-25 23:18:17 -07:00
|
|
|
/* Config Remote1 to be used for Aux PID Index */
|
2020-02-17 13:06:51 -07:00
|
|
|
m_rightFrontMotor.configSelectedFeedbackSensor( FeedbackDevice.RemoteSensor1,
|
|
|
|
|
DriveConstants.PID_TURN,
|
2020-02-12 21:42:48 -07:00
|
|
|
DriveConstants.DRIVE_TIMEOUT_MS);
|
2020-01-20 10:40:12 -07:00
|
|
|
|
2020-02-25 23:18:17 -07:00
|
|
|
/**
|
|
|
|
|
* configAuxPIDPolarity(boolean invert, int timeoutMs) false means talon's local
|
|
|
|
|
* output is PID0 + PID1, and other side Talon is PID0 - PID1 true means talon's
|
|
|
|
|
* local output is PID0 - PID1, and other side Talon is PID0 + PID1
|
|
|
|
|
*/
|
|
|
|
|
m_rightFrontMotor.configAuxPIDPolarity(DriveConstants.isAuxPIDInverted, DriveConstants.DRIVE_TIMEOUT_MS);
|
2020-02-10 20:13:15 -07:00
|
|
|
|
|
|
|
|
/* Set status frame periods to ensure we don't have stale data */
|
|
|
|
|
m_rightFrontMotor.setStatusFramePeriod(StatusFrame.Status_12_Feedback1, 20, DriveConstants.DRIVE_TIMEOUT_MS);
|
|
|
|
|
m_rightFrontMotor.setStatusFramePeriod(StatusFrame.Status_13_Base_PIDF0, 20, DriveConstants.DRIVE_TIMEOUT_MS);
|
|
|
|
|
m_rightFrontMotor.setStatusFramePeriod(StatusFrame.Status_14_Turn_PIDF1, 20, DriveConstants.DRIVE_TIMEOUT_MS);
|
2020-02-06 18:36:04 -07:00
|
|
|
m_leftFrontMotor.setStatusFramePeriod(StatusFrame.Status_2_Feedback0, 5, DriveConstants.DRIVE_TIMEOUT_MS);
|
2020-02-17 13:06:51 -07:00
|
|
|
m_leftBackMotor.setStatusFramePeriod(StatusFrame.Status_13_Base_PIDF0, 20, DriveConstants.DRIVE_TIMEOUT_MS);
|
|
|
|
|
m_rightBackMotor.setStatusFramePeriod(StatusFrame.Status_13_Base_PIDF0, 20, DriveConstants.DRIVE_TIMEOUT_MS);
|
2020-02-25 23:18:17 -07:00
|
|
|
m_pigeon.setStatusFramePeriod(PigeonIMU_StatusFrame.CondStatus_9_SixDeg_YPR, 5, DriveConstants.DRIVE_TIMEOUT_MS);
|
2020-02-06 18:36:04 -07:00
|
|
|
|
2020-02-10 20:13:15 -07:00
|
|
|
/**
|
|
|
|
|
* Max out the peak output (for all modes). However you can limit the output of
|
|
|
|
|
* a given PID object with configClosedLoopPeakOutput().
|
|
|
|
|
*/
|
|
|
|
|
m_leftFrontMotor.configPeakOutputForward(+1, DriveConstants.DRIVE_TIMEOUT_MS);
|
|
|
|
|
m_leftFrontMotor.configPeakOutputReverse(-1, DriveConstants.DRIVE_TIMEOUT_MS);
|
|
|
|
|
m_rightFrontMotor.configPeakOutputForward(+1, DriveConstants.DRIVE_TIMEOUT_MS);
|
|
|
|
|
m_rightFrontMotor.configPeakOutputReverse(-1, DriveConstants.DRIVE_TIMEOUT_MS);
|
2020-01-23 16:42:20 -07:00
|
|
|
|
2020-02-17 13:06:51 -07:00
|
|
|
m_leftBackMotor.configPeakOutputForward(+1, DriveConstants.DRIVE_TIMEOUT_MS);
|
|
|
|
|
m_leftBackMotor.configPeakOutputReverse(-1, DriveConstants.DRIVE_TIMEOUT_MS);
|
|
|
|
|
m_rightBackMotor.configPeakOutputForward(+1, DriveConstants.DRIVE_TIMEOUT_MS);
|
|
|
|
|
m_rightBackMotor.configPeakOutputReverse(-1, DriveConstants.DRIVE_TIMEOUT_MS);
|
|
|
|
|
|
2020-01-20 10:40:12 -07:00
|
|
|
/**
|
2020-02-10 20:13:15 -07:00
|
|
|
* 1ms per loop. PID loop can be slowed down if need be. For example, - if
|
|
|
|
|
* sensor updates are too slow - sensor deltas are very small per update, so
|
|
|
|
|
* derivative error never gets large enough to be useful. - sensor movement is
|
|
|
|
|
* very slow causing the derivative error to be near zero.
|
|
|
|
|
*/
|
|
|
|
|
m_rightFrontMotor.configClosedLoopPeriod( DriveConstants.PID_PRIMARY,
|
2020-02-25 23:18:17 -07:00
|
|
|
DriveConstants.CLOSED_LOOP_TIME_MS,
|
2020-02-10 20:13:15 -07:00
|
|
|
DriveConstants.DRIVE_TIMEOUT_MS);
|
|
|
|
|
|
|
|
|
|
m_rightFrontMotor.configClosedLoopPeriod( DriveConstants.PID_TURN,
|
2020-02-25 23:18:17 -07:00
|
|
|
DriveConstants.CLOSED_LOOP_TIME_MS,
|
2020-02-10 20:13:15 -07:00
|
|
|
DriveConstants.DRIVE_TIMEOUT_MS);
|
2020-02-17 13:06:51 -07:00
|
|
|
|
|
|
|
|
m_leftBackMotor.configClosedLoopPeriod( DriveConstants.PID_PRIMARY,
|
2020-02-25 23:18:17 -07:00
|
|
|
DriveConstants.CLOSED_LOOP_TIME_MS,
|
2020-02-17 13:06:51 -07:00
|
|
|
DriveConstants.DRIVE_TIMEOUT_MS);
|
|
|
|
|
|
2020-02-25 23:18:17 -07:00
|
|
|
m_rightBackMotor.configClosedLoopPeriod( DriveConstants.PID_PRIMARY,
|
|
|
|
|
DriveConstants.CLOSED_LOOP_TIME_MS,
|
2020-02-17 13:06:51 -07:00
|
|
|
DriveConstants.DRIVE_TIMEOUT_MS);
|
2020-02-25 23:18:17 -07:00
|
|
|
|
|
|
|
|
/* Set up Differential Drive */
|
|
|
|
|
m_driveTrain = new DifferentialDrive(m_leftFrontMotor, m_rightFrontMotor);
|
2020-02-12 22:15:50 -07:00
|
|
|
|
2020-02-25 23:18:17 -07:00
|
|
|
/* Set up Differential Drive Odometry. */
|
|
|
|
|
m_odometry = new DifferentialDriveOdometry( Rotation2d.fromDegrees(getHeading()),
|
|
|
|
|
new Pose2d(0, 0, new Rotation2d()));
|
|
|
|
|
|
|
|
|
|
/* Set up Orchestra */
|
|
|
|
|
m_orchestra = new Orchestra();
|
2020-02-21 23:41:01 +00:00
|
|
|
|
2020-02-25 23:18:17 -07:00
|
|
|
/* Set up music for drive train */
|
2020-02-11 16:55:04 -07:00
|
|
|
m_orchestra.addInstrument(m_leftBackMotor);
|
2020-02-10 21:49:54 -07:00
|
|
|
m_orchestra.addInstrument(m_rightFrontMotor);
|
2020-02-11 16:55:04 -07:00
|
|
|
m_orchestra.addInstrument(m_rightBackMotor);
|
|
|
|
|
m_orchestra.addInstrument(m_leftFrontMotor);
|
2020-02-09 18:33:27 -07:00
|
|
|
|
2020-02-25 23:18:17 -07:00
|
|
|
/* Create chooser to choose song to play */
|
2020-02-11 15:15:31 -07:00
|
|
|
File songsDir = new File(Filesystem.getDeployDirectory().getAbsolutePath() + "/songs");
|
|
|
|
|
System.err.println(songsDir.getPath());
|
2020-02-10 22:47:54 -07:00
|
|
|
String[] songsStrings = songsDir.list();
|
|
|
|
|
for (String songString : songsStrings){
|
2020-02-11 15:15:31 -07:00
|
|
|
m_songChooser.addOption(songString, songsDir.getAbsolutePath() + "/" + songString);
|
2020-02-10 22:47:54 -07:00
|
|
|
}
|
|
|
|
|
Shuffleboard.getTab("Songs").add(m_songChooser);
|
2020-02-25 23:18:17 -07:00
|
|
|
|
|
|
|
|
/* Start counting time */
|
2020-02-25 23:34:38 -07:00
|
|
|
m_lastTimeMs = System.currentTimeMillis();
|
|
|
|
|
}
|
2020-01-09 23:55:46 +00:00
|
|
|
|
2020-01-11 10:30:37 -07:00
|
|
|
@Override
|
|
|
|
|
public void periodic() {
|
2020-02-25 23:34:38 -07:00
|
|
|
m_lastTimeMs = m_currentTimeMs;
|
|
|
|
|
m_currentTimeMs = System.currentTimeMillis();
|
|
|
|
|
m_currentTimeSec = m_currentTimeMs / 1000;
|
|
|
|
|
m_deltaTimeMs = m_currentTimeMs - m_lastTimeMs;
|
2020-02-18 19:28:05 -07:00
|
|
|
|
2020-02-12 22:15:50 -07:00
|
|
|
m_lastAngleYaw = m_currentAngleYaw;
|
|
|
|
|
m_currentAngleYaw = getGyroYaw();
|
2020-02-18 16:56:56 -07:00
|
|
|
|
|
|
|
|
m_rightFrontMotorPos = m_rightFrontMotor.getSelectedSensorPosition();
|
|
|
|
|
m_rightFrontMotorVel = m_rightFrontMotor.getSelectedSensorVelocity();
|
2020-02-25 17:47:47 -07:00
|
|
|
|
2020-02-25 23:34:38 -07:00
|
|
|
m_lastRightPosTicks = m_currentRightPosTicks;
|
|
|
|
|
m_lastLeftPosTicks = m_currentLeftPosTicks;
|
|
|
|
|
m_currentRightPosTicks = m_rightFrontMotor.getSensorCollection().getIntegratedSensorPosition();
|
|
|
|
|
m_currentLeftPosTicks = m_leftFrontMotor.getSensorCollection().getIntegratedSensorPosition();
|
|
|
|
|
|
|
|
|
|
m_totalRightDistanceInches += ticksToInches(m_currentRightPosTicks - m_lastRightPosTicks);
|
|
|
|
|
m_totalLeftDistanceInches += ticksToInches(m_currentLeftPosTicks - m_lastLeftPosTicks);
|
2020-02-25 17:47:47 -07:00
|
|
|
|
|
|
|
|
m_odometry.update(Rotation2d.fromDegrees( getHeading()),
|
2020-02-25 23:34:38 -07:00
|
|
|
getDistanceInches(m_leftFrontMotor),
|
2020-02-25 17:47:47 -07:00
|
|
|
-getDistanceInches(m_rightFrontMotor));
|
2020-02-25 23:34:38 -07:00
|
|
|
|
2020-02-25 23:47:19 -07:00
|
|
|
runFalconCooling();
|
|
|
|
|
updateSmartDashboard();
|
2020-01-11 11:51:21 -07:00
|
|
|
}
|
|
|
|
|
|
2020-01-09 23:55:46 +00:00
|
|
|
/**
|
2020-02-12 20:28:55 -07:00
|
|
|
* Runs percent output control on the moving and steering of the drive train,
|
|
|
|
|
* using the Differential Drive class to manage the two inputs
|
2020-01-09 23:55:46 +00:00
|
|
|
*/
|
2020-02-10 20:13:15 -07:00
|
|
|
public void driveWithInput(double move, double steer) {
|
2020-02-21 17:48:05 -07:00
|
|
|
m_driveTrain.arcadeDrive(steer, move);
|
2020-02-17 13:06:51 -07:00
|
|
|
m_leftBackMotor.follow(m_leftFrontMotor);
|
|
|
|
|
m_rightBackMotor.follow(m_rightFrontMotor);
|
2020-01-09 23:55:46 +00:00
|
|
|
}
|
2020-02-07 17:50:23 -07:00
|
|
|
|
2020-02-07 17:02:43 -07:00
|
|
|
/**
|
2020-02-12 20:28:55 -07:00
|
|
|
* Runs percent output control on the drive train while using an AUX PID for rotation
|
|
|
|
|
* @param targetPos The position to drive to in units
|
|
|
|
|
* @param targetGyro The angle to drive at in units
|
|
|
|
|
*/
|
2020-02-08 12:37:48 -07:00
|
|
|
public void driveWithInputAux(double move, double targetGyro) {
|
|
|
|
|
m_rightFrontMotor.selectProfileSlot(DriveConstants.SLOT_TURNING, DriveConstants.PID_TURN);
|
|
|
|
|
|
|
|
|
|
m_rightFrontMotor.set(TalonFXControlMode.PercentOutput, move, DemandType.AuxPID, targetGyro);
|
|
|
|
|
m_leftFrontMotor.follow(m_rightFrontMotor, FollowerType.AuxOutput1);
|
2020-02-17 13:06:51 -07:00
|
|
|
m_leftBackMotor.follow(m_leftFrontMotor);
|
|
|
|
|
m_rightBackMotor.follow(m_rightFrontMotor);
|
2020-02-08 12:37:48 -07:00
|
|
|
|
|
|
|
|
m_driveTrain.feedWatchdog();
|
|
|
|
|
}
|
|
|
|
|
|
2020-02-12 21:00:54 -07:00
|
|
|
/**
|
2020-02-13 17:51:54 -07:00
|
|
|
* Runs position PID.
|
2020-02-12 21:00:54 -07:00
|
|
|
* Position is absolute and displacement should be handled on the command side.
|
|
|
|
|
* @param targetPos The position to drive to in units
|
2020-02-07 17:02:43 -07:00
|
|
|
* @param targetGyro The angle to drive at in units
|
|
|
|
|
*/
|
2020-02-13 17:51:54 -07:00
|
|
|
public void runDrivePositionPID(double targetPos, double targetGyro) {
|
2020-02-06 19:43:37 -07:00
|
|
|
m_rightFrontMotor.selectProfileSlot(DriveConstants.SLOT_DISTANCE, DriveConstants.PID_PRIMARY);
|
|
|
|
|
m_rightFrontMotor.selectProfileSlot(DriveConstants.SLOT_TURNING, DriveConstants.PID_TURN);
|
|
|
|
|
|
|
|
|
|
m_rightFrontMotor.set(TalonFXControlMode.Position, targetPos, DemandType.AuxPID, targetGyro);
|
|
|
|
|
m_leftFrontMotor.follow(m_rightFrontMotor, FollowerType.AuxOutput1);
|
2020-02-17 13:06:51 -07:00
|
|
|
m_leftBackMotor.follow(m_leftFrontMotor);
|
|
|
|
|
m_rightBackMotor.follow(m_rightFrontMotor);
|
2020-02-01 15:30:41 -07:00
|
|
|
|
2020-02-25 17:47:47 -07:00
|
|
|
m_driveTrain.feedWatchdog();
|
2020-01-16 20:11:48 -07:00
|
|
|
}
|
2020-02-07 17:50:23 -07:00
|
|
|
|
2020-02-07 17:02:43 -07:00
|
|
|
/**
|
2020-02-13 17:51:54 -07:00
|
|
|
* Runs velocity PID
|
2020-02-10 20:13:15 -07:00
|
|
|
*
|
|
|
|
|
* @param targetVel The velocity to drive at in units
|
2020-02-07 17:02:43 -07:00
|
|
|
* @param targetGyro The angle to drive at in units
|
|
|
|
|
*/
|
2020-02-13 17:51:54 -07:00
|
|
|
public void runDriveVelocityPID(double targetVel, double targetGyro) {
|
2020-02-06 18:36:04 -07:00
|
|
|
m_rightFrontMotor.selectProfileSlot(DriveConstants.SLOT_VELOCITY, DriveConstants.PID_PRIMARY);
|
|
|
|
|
m_rightFrontMotor.selectProfileSlot(DriveConstants.SLOT_TURNING, DriveConstants.PID_TURN);
|
2020-02-17 13:06:51 -07:00
|
|
|
|
2020-02-06 18:36:04 -07:00
|
|
|
m_rightFrontMotor.set(TalonFXControlMode.Velocity, targetVel, DemandType.AuxPID, targetGyro);
|
|
|
|
|
m_leftFrontMotor.follow(m_rightFrontMotor, FollowerType.AuxOutput1);
|
2020-02-17 13:06:51 -07:00
|
|
|
m_leftBackMotor.follow(m_leftFrontMotor);
|
|
|
|
|
m_rightBackMotor.follow(m_rightFrontMotor);
|
2020-02-06 19:43:37 -07:00
|
|
|
|
2020-02-25 17:47:47 -07:00
|
|
|
m_driveTrain.feedWatchdog();
|
2020-01-16 20:11:48 -07:00
|
|
|
}
|
2020-02-07 17:50:23 -07:00
|
|
|
|
2020-02-07 17:02:43 -07:00
|
|
|
/**
|
2020-02-12 20:28:55 -07:00
|
|
|
* Runs motion magic PID while driving straight
|
2020-02-07 17:02:43 -07:00
|
|
|
* @param targetPos The position to drive to in units
|
|
|
|
|
* @param targetGyro The angle to drive at in units
|
|
|
|
|
*/
|
2020-02-10 20:13:15 -07:00
|
|
|
public void runMotionMagicPID(double targetPos, double targetGyro) {
|
2020-01-31 17:50:43 -07:00
|
|
|
m_rightFrontMotor.selectProfileSlot(DriveConstants.SLOT_MOTION_MAGIC, DriveConstants.PID_PRIMARY);
|
|
|
|
|
m_rightFrontMotor.selectProfileSlot(DriveConstants.SLOT_TURNING, DriveConstants.PID_TURN);
|
2020-02-10 20:13:15 -07:00
|
|
|
|
2020-02-07 21:49:04 -07:00
|
|
|
m_rightFrontMotor.set(ControlMode.MotionMagic, targetPos, DemandType.AuxPID, targetGyro);
|
2020-01-31 17:50:43 -07:00
|
|
|
m_leftFrontMotor.follow(m_rightFrontMotor, FollowerType.AuxOutput1);
|
2020-02-21 20:46:52 -07:00
|
|
|
|
2020-02-17 13:06:51 -07:00
|
|
|
m_leftBackMotor.follow(m_leftFrontMotor);
|
|
|
|
|
m_rightBackMotor.follow(m_rightFrontMotor);
|
2020-02-10 20:13:15 -07:00
|
|
|
|
2020-02-01 15:30:41 -07:00
|
|
|
m_driveTrain.feedWatchdog();
|
2020-02-13 17:57:25 -07:00
|
|
|
|
2020-01-16 20:22:50 -07:00
|
|
|
}
|
|
|
|
|
|
2020-01-30 21:46:56 -07:00
|
|
|
/**
|
|
|
|
|
* Runs a Turning PID to rotate a to a target angle
|
2020-02-10 20:13:15 -07:00
|
|
|
*
|
2020-01-30 21:46:56 -07:00
|
|
|
* @param targetAngle target angle in degrees
|
|
|
|
|
*/
|
2020-02-10 20:13:15 -07:00
|
|
|
public void runTurningPID(double targetAngle) {
|
2020-02-21 19:44:51 -07:00
|
|
|
//double targetGyro = (targetAngle / 360) * DriveConstants.TICKS_PER_GYRO_REV;
|
2020-02-10 20:13:15 -07:00
|
|
|
|
2020-02-21 19:44:51 -07:00
|
|
|
runDriveVelocityPID(0, targetAngle);
|
2020-01-23 16:42:20 -07:00
|
|
|
}
|
|
|
|
|
|
2020-02-13 00:28:55 -07:00
|
|
|
/**
|
|
|
|
|
* Controls the left and right sides of the drive with velocity targets.
|
|
|
|
|
*
|
2020-02-17 13:06:51 -07:00
|
|
|
* @param leftSpeed the commanded left speed
|
|
|
|
|
* @param rightSpeed the commanded right speed
|
2020-02-13 00:28:55 -07:00
|
|
|
*/
|
|
|
|
|
public void tankDriveVelocity(double leftSpeed, double rightSpeed) {
|
2020-02-17 13:06:51 -07:00
|
|
|
//DifferentialDriveWheelSpeeds wheelSpeeds = new DifferentialDriveWheelSpeeds(leftSpeed, rightSpeed);
|
|
|
|
|
//ChassisSpeeds chassisSpeeds = DriveConstants.kDriveKinematics.toChassisSpeeds(wheelSpeeds);
|
|
|
|
|
//double moveVelMPS = chassisSpeeds.vxMetersPerSecond;
|
|
|
|
|
//double angleVelRad = chassisSpeeds.omegaRadiansPerSecond;
|
|
|
|
|
//double angleVelDeg = Math.toDegrees(angleVelRad);
|
|
|
|
|
|
|
|
|
|
//m_kinematicsTargetAngle += angleVelDeg * (m_deltaTime/1000);
|
|
|
|
|
//m_kinematicsTargetAngle = MathUtil.clamp( m_kinematicsTargetAngle,
|
|
|
|
|
// m_currentAngleYaw-(360),
|
|
|
|
|
// m_currentAngleYaw+(360));
|
|
|
|
|
//double targetGyro = (m_kinematicsTargetAngle / 360) * DriveConstants.TICKS_PER_GYRO_REV;
|
|
|
|
|
double moveVelLeft = inchesToTicks(metersToInches(leftSpeed))/DriveConstants.SECONDS_TO_TICK_TIME;
|
|
|
|
|
double moveVelRight = inchesToTicks(metersToInches(rightSpeed))/DriveConstants.SECONDS_TO_TICK_TIME;
|
2020-02-13 00:28:55 -07:00
|
|
|
|
2020-02-14 08:32:32 -07:00
|
|
|
//SmartDashboard.putNumber("Move Vel Left", moveVelLeft);
|
|
|
|
|
//SmartDashboard.putNumber("Move Vel Right", moveVelRight);
|
2020-02-13 17:46:15 -07:00
|
|
|
|
2020-02-17 13:06:51 -07:00
|
|
|
//runDriveVelocityPID(moveVel*2, targetGyro);
|
2020-02-14 08:32:32 -07:00
|
|
|
|
2020-02-17 13:06:51 -07:00
|
|
|
m_rightBackMotor.selectProfileSlot(DriveConstants.SLOT_VELOCITY, DriveConstants.PID_PRIMARY);
|
|
|
|
|
m_leftBackMotor.selectProfileSlot(DriveConstants.SLOT_VELOCITY, DriveConstants.PID_PRIMARY);
|
2020-02-14 08:32:32 -07:00
|
|
|
|
2020-02-20 20:14:51 -07:00
|
|
|
System.err.println(moveVelLeft);
|
|
|
|
|
|
2020-02-17 13:06:51 -07:00
|
|
|
m_rightBackMotor.set(TalonFXControlMode.Velocity, moveVelRight);
|
|
|
|
|
m_leftBackMotor.set(TalonFXControlMode.Velocity, moveVelLeft);
|
2020-02-20 16:53:13 -07:00
|
|
|
m_leftFrontMotor.follow(m_leftBackMotor);
|
|
|
|
|
m_rightFrontMotor.follow(m_rightBackMotor);
|
2020-02-17 13:06:51 -07:00
|
|
|
|
|
|
|
|
m_driveTrain.feedWatchdog();
|
2020-02-13 00:28:55 -07:00
|
|
|
}
|
|
|
|
|
|
2020-02-07 17:50:23 -07:00
|
|
|
/**
|
2020-02-25 23:47:19 -07:00
|
|
|
* Set to high or low gear based on boolean state, true = high, false = low
|
|
|
|
|
* @param state Chooses between high or low gear
|
2020-02-07 17:50:23 -07:00
|
|
|
*/
|
2020-02-25 23:47:19 -07:00
|
|
|
public void setShiftState(boolean state) {
|
|
|
|
|
if (state == true) {
|
|
|
|
|
m_speedShift.set(DoubleSolenoid.Value.kReverse);
|
|
|
|
|
}
|
|
|
|
|
if (state == false) {
|
|
|
|
|
m_speedShift.set(DoubleSolenoid.Value.kForward);
|
|
|
|
|
}
|
|
|
|
|
setRightMotorGains(state);
|
|
|
|
|
m_isSpeedShiftHigh = state;
|
|
|
|
|
}
|
2020-02-10 20:13:15 -07:00
|
|
|
|
2020-02-25 23:47:19 -07:00
|
|
|
/**
|
|
|
|
|
* Set to open or close solenoid that cools the falcon, true = open, false = close
|
|
|
|
|
* @param state Chooses between open and close
|
|
|
|
|
*/
|
|
|
|
|
public void coolFalcon(boolean state) {
|
|
|
|
|
if (state == true) {
|
|
|
|
|
m_coolFalcon.set(DoubleSolenoid.Value.kForward);
|
|
|
|
|
}
|
|
|
|
|
if (state == false) {
|
|
|
|
|
m_coolFalcon.set(DoubleSolenoid.Value.kReverse);
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-01-09 18:05:16 -07:00
|
|
|
|
2020-02-07 17:50:23 -07:00
|
|
|
/**
|
2020-02-25 23:47:19 -07:00
|
|
|
*
|
2020-02-07 17:50:23 -07:00
|
|
|
*/
|
2020-02-25 23:47:19 -07:00
|
|
|
public void runFalconCooling() {
|
|
|
|
|
if (m_currentTimeSec % 30 == 0) {
|
|
|
|
|
coolFalcon(true);
|
|
|
|
|
SmartDashboard.putBoolean("Solenoid", true);
|
|
|
|
|
} else if ((m_currentTimeSec - 1) % 30 == 0) {
|
|
|
|
|
coolFalcon(false);
|
|
|
|
|
SmartDashboard.putBoolean("Solenoid", false);
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-02-10 20:13:15 -07:00
|
|
|
|
2020-02-25 23:47:19 -07:00
|
|
|
/**
|
|
|
|
|
* Selects a song to play!
|
|
|
|
|
* @param song The name of the song to be played
|
|
|
|
|
*/
|
|
|
|
|
public void selectSong(String song) {
|
|
|
|
|
SmartDashboard.putString("Selected Song", song);
|
|
|
|
|
m_orchestra.loadMusic(song);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Plays Music!
|
|
|
|
|
*/
|
|
|
|
|
public void playSong() {
|
|
|
|
|
m_orchestra.play();
|
2020-01-09 18:05:16 -07:00
|
|
|
}
|
2020-01-10 21:29:45 -07:00
|
|
|
|
2020-02-07 17:50:23 -07:00
|
|
|
/**
|
2020-02-25 23:47:19 -07:00
|
|
|
* Resets the encoders for both motors.
|
2020-02-07 17:50:23 -07:00
|
|
|
*/
|
2020-02-25 23:47:19 -07:00
|
|
|
public void resetEncoders() {
|
|
|
|
|
m_leftFrontMotor.getSensorCollection().setIntegratedSensorPosition(0, DriveConstants.DRIVE_TIMEOUT_MS);
|
|
|
|
|
m_rightFrontMotor.getSensorCollection().setIntegratedSensorPosition(0, DriveConstants.DRIVE_TIMEOUT_MS);
|
|
|
|
|
m_leftBackMotor.getSensorCollection().setIntegratedSensorPosition(0, DriveConstants.DRIVE_TIMEOUT_MS);
|
|
|
|
|
m_rightBackMotor.getSensorCollection().setIntegratedSensorPosition(0, DriveConstants.DRIVE_TIMEOUT_MS);
|
2020-02-10 20:13:15 -07:00
|
|
|
|
2020-02-25 23:47:19 -07:00
|
|
|
m_totalLeftDistanceInches = 0;
|
|
|
|
|
m_totalRightDistanceInches = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Resets the odometry to the specified pose.
|
|
|
|
|
*
|
|
|
|
|
* @param pose The pose to which to set the odometry.
|
|
|
|
|
*/
|
|
|
|
|
public void setOdometry(Pose2d pose) {
|
|
|
|
|
resetEncoders();
|
|
|
|
|
m_odometry.resetPosition(pose, Rotation2d.fromDegrees(getHeading()));
|
2020-01-09 18:05:16 -07:00
|
|
|
}
|
|
|
|
|
|
2020-02-07 17:50:23 -07:00
|
|
|
/**
|
|
|
|
|
* Resets the yaw of the pigeon
|
|
|
|
|
*/
|
2020-01-09 18:05:16 -07:00
|
|
|
public void resetGyroYaw() {
|
|
|
|
|
m_pigeon.setYaw(0);
|
|
|
|
|
m_pigeon.setAccumZAngle(0);
|
2020-02-13 00:28:55 -07:00
|
|
|
resetGyroAngles();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Add docs here
|
|
|
|
|
*/
|
|
|
|
|
public void resetGyroAngles() {
|
2020-02-12 22:15:50 -07:00
|
|
|
m_lastAngleYaw = 0;
|
|
|
|
|
m_currentAngleYaw = 0;
|
2020-01-09 18:05:16 -07:00
|
|
|
}
|
2020-02-25 23:47:19 -07:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Returns the current yaw of the pigeon
|
|
|
|
|
*/
|
|
|
|
|
public double getGyroYaw() {
|
|
|
|
|
|
|
|
|
|
double[] ypr = new double[3];
|
|
|
|
|
|
|
|
|
|
m_pigeon.getYawPitchRoll(ypr);
|
|
|
|
|
return ypr[0];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Returns the current pitch of the pigeon
|
|
|
|
|
*/
|
|
|
|
|
public double getGyroPitch() {
|
|
|
|
|
double[] ypr = new double[3];
|
|
|
|
|
|
|
|
|
|
m_pigeon.getYawPitchRoll(ypr);
|
|
|
|
|
return ypr[1];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Returns the current roll of the pigeon
|
|
|
|
|
*/
|
|
|
|
|
public double getGyroRoll() {
|
|
|
|
|
double[] ypr = new double[3];
|
|
|
|
|
|
|
|
|
|
m_pigeon.getYawPitchRoll(ypr);
|
|
|
|
|
return ypr[2];
|
|
|
|
|
}
|
|
|
|
|
|
2020-02-20 20:14:51 -07:00
|
|
|
//lol
|
|
|
|
|
//sko
|
|
|
|
|
//ridge
|
|
|
|
|
//brayden=bad coder
|
2020-02-25 23:47:19 -07:00
|
|
|
|
2020-02-25 17:47:47 -07:00
|
|
|
/**
|
|
|
|
|
* Returns the heading of the robot
|
2020-02-10 20:13:15 -07:00
|
|
|
* @return The robot's heading in degrees, from -180 to 180
|
|
|
|
|
*/
|
|
|
|
|
public double getHeading() {
|
|
|
|
|
return Math.IEEEremainder(getGyroYaw(), 360);
|
|
|
|
|
}
|
|
|
|
|
|
2020-02-12 22:15:50 -07:00
|
|
|
/**
|
|
|
|
|
* Returns the turn rate of the robot.
|
|
|
|
|
*
|
|
|
|
|
* @return The turn rate of the robot, in degrees per second
|
|
|
|
|
*/
|
|
|
|
|
public double getTurnRate() {
|
|
|
|
|
double deltaYaw = m_currentAngleYaw - m_lastAngleYaw;
|
2020-02-25 23:34:38 -07:00
|
|
|
double turnRate = 1000 * deltaYaw / m_deltaTimeMs;
|
2020-02-19 19:15:45 -07:00
|
|
|
return turnRate;
|
2020-02-12 22:15:50 -07:00
|
|
|
}
|
|
|
|
|
|
2020-02-10 20:13:15 -07:00
|
|
|
/**
|
|
|
|
|
* Returns the currently-estimated pose of the robot.
|
|
|
|
|
* @return The pose.
|
|
|
|
|
*/
|
|
|
|
|
public Pose2d getPose() {
|
|
|
|
|
return m_odometry.getPoseMeters();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Returns current wheel speeds of robot.
|
|
|
|
|
* @return The current wheel speeds.
|
|
|
|
|
*/
|
|
|
|
|
public DifferentialDriveWheelSpeeds getWheelSpeeds() {
|
2020-02-25 16:15:48 -07:00
|
|
|
return new DifferentialDriveWheelSpeeds( getVelocityInchesPerSecond(m_leftBackMotor),
|
|
|
|
|
-getVelocityInchesPerSecond(m_rightBackMotor));
|
2020-02-10 20:13:15 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Gets the encoder value (position) of a motor
|
|
|
|
|
* @param falcon The motor to get the position of
|
|
|
|
|
* @return The position of the motor in inches
|
|
|
|
|
*/
|
|
|
|
|
public double getDistanceInches(WPI_TalonFX falcon) {
|
|
|
|
|
return ticksToInches(falcon.getSensorCollection().getIntegratedSensorPosition());
|
|
|
|
|
}
|
|
|
|
|
|
2020-02-12 21:32:33 -07:00
|
|
|
/**
|
|
|
|
|
* Gets the encoder value (velocity) of a motor
|
|
|
|
|
* @param falcon The motor to get the velocity of
|
|
|
|
|
* @return The velocity of the motor in inches per second
|
|
|
|
|
*/
|
|
|
|
|
public double getVelocityInchesPerSecond(WPI_TalonFX falcon) {
|
|
|
|
|
return ticksToInches(falcon.getSensorCollection().getIntegratedSensorPosition()/DriveConstants.TICK_TIME_TO_SECONDS);
|
|
|
|
|
}
|
|
|
|
|
|
2020-02-10 20:13:15 -07:00
|
|
|
/**
|
|
|
|
|
* Converts a value in ticks to inches.
|
|
|
|
|
* @param ticks The value in ticks to convert
|
|
|
|
|
* @return The converted value in inches
|
|
|
|
|
*/
|
2020-02-19 17:38:15 -07:00
|
|
|
public double ticksToInches(double ticks) {
|
2020-02-25 16:15:48 -07:00
|
|
|
if (m_isSpeedShiftHigh) {
|
|
|
|
|
return ticks * DriveConstants.INCHES_PER_TICK_HIGH;
|
|
|
|
|
} else {
|
|
|
|
|
return ticks * DriveConstants.INCHES_PER_TICK_LOW;
|
|
|
|
|
}
|
2020-02-10 20:13:15 -07:00
|
|
|
}
|
2020-02-12 21:32:33 -07:00
|
|
|
|
2020-02-13 00:28:55 -07:00
|
|
|
/**
|
|
|
|
|
* Converts a value in inches to ticks.
|
|
|
|
|
* @param inches The value in inches to convert
|
|
|
|
|
* @return The converted value in ticks
|
|
|
|
|
*/
|
|
|
|
|
public double inchesToTicks(double inches) {
|
2020-02-25 16:15:48 -07:00
|
|
|
if (m_isSpeedShiftHigh) {
|
|
|
|
|
return inches * DriveConstants.TICKS_PER_INCH_HIGH;
|
|
|
|
|
} else {
|
|
|
|
|
return inches * DriveConstants.TICKS_PER_INCH_LOW;
|
|
|
|
|
}
|
2020-02-13 00:28:55 -07:00
|
|
|
}
|
|
|
|
|
|
2020-02-12 21:32:33 -07:00
|
|
|
/**
|
|
|
|
|
* Converts a value in inches to meters.
|
|
|
|
|
* @param inches The value in inches to convert
|
|
|
|
|
* @return The converted value in meters
|
|
|
|
|
*/
|
|
|
|
|
public double inchesToMeters(double inches) {
|
2020-02-13 17:58:45 -07:00
|
|
|
return inches * DriveConstants.METERS_PER_INCH;
|
2020-02-12 21:32:33 -07:00
|
|
|
}
|
2020-02-13 00:28:55 -07:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Converts a value in meters to inches.
|
|
|
|
|
* @param meters The value in meters to convert
|
|
|
|
|
* @return The converted value in inches
|
|
|
|
|
*/
|
|
|
|
|
public double metersToInches(double meters) {
|
|
|
|
|
return meters * DriveConstants.INCHES_PER_METER;
|
|
|
|
|
}
|
2020-02-10 21:49:25 -07:00
|
|
|
|
2020-02-25 23:47:19 -07:00
|
|
|
public void setRightMotorGains(boolean isHighGear) {
|
|
|
|
|
if (!isHighGear) {
|
|
|
|
|
m_rightFrontMotor.selectProfileSlot(DriveConstants.SLOT_VELOCITY, DriveConstants.PID_PRIMARY);
|
|
|
|
|
m_rightFrontMotor.config_kF(DriveConstants.SLOT_VELOCITY, m_gainsVelocityLow.m_kF, DriveConstants.DRIVE_TIMEOUT_MS);
|
|
|
|
|
m_rightFrontMotor.config_kP(DriveConstants.SLOT_VELOCITY, m_gainsVelocityLow.m_kP, DriveConstants.DRIVE_TIMEOUT_MS);
|
|
|
|
|
m_rightFrontMotor.config_kI(DriveConstants.SLOT_VELOCITY, m_gainsVelocityLow.m_kI, DriveConstants.DRIVE_TIMEOUT_MS);
|
|
|
|
|
m_rightFrontMotor.config_kD(DriveConstants.SLOT_VELOCITY, m_gainsVelocityLow.m_kD, DriveConstants.DRIVE_TIMEOUT_MS);
|
|
|
|
|
m_rightFrontMotor.configClosedLoopPeakOutput(DriveConstants.SLOT_VELOCITY, m_gainsVelocityLow.m_kPeakOutput, DriveConstants.DRIVE_TIMEOUT_MS);
|
|
|
|
|
|
|
|
|
|
m_rightFrontMotor.selectProfileSlot(DriveConstants.SLOT_TURNING, DriveConstants.PID_TURN);
|
|
|
|
|
m_rightFrontMotor.config_kF(DriveConstants.SLOT_TURNING, m_gainsTurningLow.m_kF, DriveConstants.DRIVE_TIMEOUT_MS);
|
|
|
|
|
m_rightFrontMotor.config_kP(DriveConstants.SLOT_TURNING, m_gainsTurningLow.m_kP, DriveConstants.DRIVE_TIMEOUT_MS);
|
|
|
|
|
m_rightFrontMotor.config_kI(DriveConstants.SLOT_TURNING, m_gainsTurningLow.m_kI, DriveConstants.DRIVE_TIMEOUT_MS);
|
|
|
|
|
m_rightFrontMotor.config_kD(DriveConstants.SLOT_TURNING, m_gainsTurningLow.m_kD, DriveConstants.DRIVE_TIMEOUT_MS);
|
|
|
|
|
m_rightFrontMotor.configClosedLoopPeakOutput(DriveConstants.SLOT_TURNING, m_gainsTurningLow.m_kPeakOutput, DriveConstants.DRIVE_TIMEOUT_MS);
|
|
|
|
|
|
|
|
|
|
m_rightFrontMotor.selectProfileSlot(DriveConstants.SLOT_DISTANCE, DriveConstants.PID_PRIMARY);
|
|
|
|
|
m_rightFrontMotor.config_kF(DriveConstants.SLOT_DISTANCE, m_gainsDistanceLow.m_kF, DriveConstants.DRIVE_TIMEOUT_MS);
|
|
|
|
|
m_rightFrontMotor.config_kP(DriveConstants.SLOT_DISTANCE, m_gainsDistanceLow.m_kP, DriveConstants.DRIVE_TIMEOUT_MS);
|
|
|
|
|
m_rightFrontMotor.config_kI(DriveConstants.SLOT_DISTANCE, m_gainsDistanceLow.m_kI, DriveConstants.DRIVE_TIMEOUT_MS);
|
|
|
|
|
m_rightFrontMotor.config_kD(DriveConstants.SLOT_DISTANCE, m_gainsDistanceLow.m_kD, DriveConstants.DRIVE_TIMEOUT_MS);
|
|
|
|
|
m_rightFrontMotor.configClosedLoopPeakOutput( DriveConstants.SLOT_DISTANCE, m_gainsDistanceLow.m_kPeakOutput, DriveConstants.DRIVE_TIMEOUT_MS);
|
|
|
|
|
|
|
|
|
|
m_rightFrontMotor.selectProfileSlot(DriveConstants.SLOT_MOTION_MAGIC, DriveConstants.PID_PRIMARY);
|
|
|
|
|
m_rightFrontMotor.config_kF(DriveConstants.SLOT_MOTION_MAGIC, m_gainsMotionMagicLow.m_kF, DriveConstants.DRIVE_TIMEOUT_MS);
|
|
|
|
|
m_rightFrontMotor.config_kP(DriveConstants.SLOT_MOTION_MAGIC, m_gainsMotionMagicLow.m_kP, DriveConstants.DRIVE_TIMEOUT_MS);
|
|
|
|
|
m_rightFrontMotor.config_kI(DriveConstants.SLOT_MOTION_MAGIC, m_gainsMotionMagicLow.m_kI, DriveConstants.DRIVE_TIMEOUT_MS);
|
|
|
|
|
m_rightFrontMotor.config_kD(DriveConstants.SLOT_MOTION_MAGIC, m_gainsMotionMagicLow.m_kD, DriveConstants.DRIVE_TIMEOUT_MS);
|
|
|
|
|
m_rightFrontMotor.configClosedLoopPeakOutput( DriveConstants.SLOT_MOTION_MAGIC, m_gainsMotionMagicLow.m_kPeakOutput, DriveConstants.DRIVE_TIMEOUT_MS);
|
|
|
|
|
m_rightFrontMotor.configMotionCruiseVelocity(DriveConstants.DRIVE_CRUISE_VELOCITY, DriveConstants.DRIVE_TIMEOUT_MS);
|
|
|
|
|
m_rightFrontMotor.configMotionAcceleration(DriveConstants.DRIVE_ACCELERATION, DriveConstants.DRIVE_TIMEOUT_MS);
|
|
|
|
|
m_rightFrontMotor.configMotionSCurveStrength(0, DriveConstants.DRIVE_TIMEOUT_MS);
|
|
|
|
|
} else {
|
|
|
|
|
m_rightFrontMotor.selectProfileSlot(DriveConstants.SLOT_VELOCITY, DriveConstants.PID_PRIMARY);
|
|
|
|
|
m_rightFrontMotor.config_kF(DriveConstants.SLOT_VELOCITY, m_gainsVelocityHigh.m_kF, DriveConstants.DRIVE_TIMEOUT_MS);
|
|
|
|
|
m_rightFrontMotor.config_kP(DriveConstants.SLOT_VELOCITY, m_gainsVelocityHigh.m_kP, DriveConstants.DRIVE_TIMEOUT_MS);
|
|
|
|
|
m_rightFrontMotor.config_kI(DriveConstants.SLOT_VELOCITY, m_gainsVelocityHigh.m_kI, DriveConstants.DRIVE_TIMEOUT_MS);
|
|
|
|
|
m_rightFrontMotor.config_kD(DriveConstants.SLOT_VELOCITY, m_gainsVelocityHigh.m_kD, DriveConstants.DRIVE_TIMEOUT_MS);
|
|
|
|
|
m_rightFrontMotor.configClosedLoopPeakOutput(DriveConstants.SLOT_VELOCITY, m_gainsVelocityHigh.m_kPeakOutput, DriveConstants.DRIVE_TIMEOUT_MS);
|
|
|
|
|
|
|
|
|
|
m_rightFrontMotor.selectProfileSlot(DriveConstants.SLOT_TURNING, DriveConstants.PID_TURN);
|
|
|
|
|
m_rightFrontMotor.config_kF(DriveConstants.SLOT_TURNING, m_gainsTurningHigh.m_kF, DriveConstants.DRIVE_TIMEOUT_MS);
|
|
|
|
|
m_rightFrontMotor.config_kP(DriveConstants.SLOT_TURNING, m_gainsTurningHigh.m_kP, DriveConstants.DRIVE_TIMEOUT_MS);
|
|
|
|
|
m_rightFrontMotor.config_kI(DriveConstants.SLOT_TURNING, m_gainsTurningHigh.m_kI, DriveConstants.DRIVE_TIMEOUT_MS);
|
|
|
|
|
m_rightFrontMotor.config_kD(DriveConstants.SLOT_TURNING, m_gainsTurningHigh.m_kD, DriveConstants.DRIVE_TIMEOUT_MS);
|
|
|
|
|
m_rightFrontMotor.configClosedLoopPeakOutput(DriveConstants.SLOT_TURNING, m_gainsTurningHigh.m_kPeakOutput, DriveConstants.DRIVE_TIMEOUT_MS);
|
|
|
|
|
|
|
|
|
|
m_rightFrontMotor.selectProfileSlot(DriveConstants.SLOT_DISTANCE, DriveConstants.PID_PRIMARY);
|
|
|
|
|
m_rightFrontMotor.config_kF(DriveConstants.SLOT_DISTANCE, m_gainsDistanceHigh.m_kF, DriveConstants.DRIVE_TIMEOUT_MS);
|
|
|
|
|
m_rightFrontMotor.config_kP(DriveConstants.SLOT_DISTANCE, m_gainsDistanceHigh.m_kP, DriveConstants.DRIVE_TIMEOUT_MS);
|
|
|
|
|
m_rightFrontMotor.config_kI(DriveConstants.SLOT_DISTANCE, m_gainsDistanceHigh.m_kI, DriveConstants.DRIVE_TIMEOUT_MS);
|
|
|
|
|
m_rightFrontMotor.config_kD(DriveConstants.SLOT_DISTANCE, m_gainsDistanceHigh.m_kD, DriveConstants.DRIVE_TIMEOUT_MS);
|
|
|
|
|
m_rightFrontMotor.configClosedLoopPeakOutput( DriveConstants.SLOT_DISTANCE, m_gainsDistanceHigh.m_kPeakOutput, DriveConstants.DRIVE_TIMEOUT_MS);
|
|
|
|
|
|
|
|
|
|
m_rightFrontMotor.selectProfileSlot(DriveConstants.SLOT_MOTION_MAGIC, DriveConstants.PID_PRIMARY);
|
|
|
|
|
m_rightFrontMotor.config_kF(DriveConstants.SLOT_MOTION_MAGIC, m_gainsMotionMagicHigh.m_kF, DriveConstants.DRIVE_TIMEOUT_MS);
|
|
|
|
|
m_rightFrontMotor.config_kP(DriveConstants.SLOT_MOTION_MAGIC, m_gainsMotionMagicHigh.m_kP, DriveConstants.DRIVE_TIMEOUT_MS);
|
|
|
|
|
m_rightFrontMotor.config_kI(DriveConstants.SLOT_MOTION_MAGIC, m_gainsMotionMagicHigh.m_kI, DriveConstants.DRIVE_TIMEOUT_MS);
|
|
|
|
|
m_rightFrontMotor.config_kD(DriveConstants.SLOT_MOTION_MAGIC, m_gainsMotionMagicHigh.m_kD, DriveConstants.DRIVE_TIMEOUT_MS);
|
|
|
|
|
m_rightFrontMotor.configClosedLoopPeakOutput( DriveConstants.SLOT_MOTION_MAGIC, m_gainsMotionMagicHigh.m_kPeakOutput, DriveConstants.DRIVE_TIMEOUT_MS);
|
|
|
|
|
m_rightFrontMotor.configMotionCruiseVelocity(DriveConstants.DRIVE_CRUISE_VELOCITY_HIGH, DriveConstants.DRIVE_TIMEOUT_MS);
|
|
|
|
|
m_rightFrontMotor.configMotionAcceleration(DriveConstants.DRIVE_ACCELERATION_HIGH, DriveConstants.DRIVE_TIMEOUT_MS);
|
|
|
|
|
m_rightFrontMotor.configMotionSCurveStrength(0, DriveConstants.DRIVE_TIMEOUT_MS);
|
2020-02-21 22:03:41 -07:00
|
|
|
}
|
2020-02-08 13:01:25 -07:00
|
|
|
}
|
2020-02-18 19:25:32 -07:00
|
|
|
|
|
|
|
|
/**
|
2020-02-25 23:47:19 -07:00
|
|
|
* Sets Motors to a NeutralMode.
|
|
|
|
|
*
|
|
|
|
|
* @param mode NeutralMode to set motors to
|
2020-02-18 19:25:32 -07:00
|
|
|
*/
|
2020-02-25 23:47:19 -07:00
|
|
|
public void setDriveTrainNeutralMode(NeutralMode mode) {
|
|
|
|
|
m_leftFrontMotor.setNeutralMode(mode);
|
|
|
|
|
m_rightFrontMotor.setNeutralMode(mode);
|
|
|
|
|
m_leftBackMotor.setNeutralMode(mode);
|
|
|
|
|
m_rightBackMotor.setNeutralMode(mode);
|
2020-02-18 19:25:32 -07:00
|
|
|
}
|
|
|
|
|
|
2020-02-25 23:47:19 -07:00
|
|
|
public void updateSmartDashboard() {
|
|
|
|
|
try {
|
|
|
|
|
//SmartDashboard.putNumber("Pigeon Yaw", getGyroYaw());
|
|
|
|
|
//SmartDashboard.putNumber("Pigeon Pitch", getGyroPitch());
|
|
|
|
|
//SmartDashboard.putNumber("Pigeon Roll", getGyroRoll());
|
|
|
|
|
SmartDashboard.putNumber("Left Front Output", m_leftFrontMotor.get());
|
|
|
|
|
SmartDashboard.putNumber("Right Front Output", m_rightFrontMotor.get());
|
|
|
|
|
SmartDashboard.putNumber("Left Back Output", m_leftBackMotor.get());
|
|
|
|
|
SmartDashboard.putNumber("Right Back Output", m_rightBackMotor.get());
|
|
|
|
|
|
|
|
|
|
//SmartDashboard.putNumber("Left Back Motor Velocity Raw", m_leftBackMotor.getSelectedSensorVelocity());
|
|
|
|
|
//SmartDashboard.putNumber("Right Back Motor Velocity Raw", m_rightBackMotor.getSelectedSensorVelocity());
|
|
|
|
|
//SmartDashboard.putNumber("Left Motor Position Raw", m_leftFrontMotor.getSelectedSensorPosition());
|
|
|
|
|
//SmartDashboard.putNumber("Right Motor Position Raw", m_rightFrontMotor.getSelectedSensorPosition(0));
|
|
|
|
|
|
|
|
|
|
//SmartDashboard.putNumber("Right Motor Velocity Int Sensor", m_rightFrontMotor.getSensorCollection().getIntegratedSensorVelocity());
|
|
|
|
|
//SmartDashboard.putNumber("Left Motor Velocity Int Sensor", m_leftFrontMotor.getSensorCollection().getIntegratedSensorVelocity());
|
|
|
|
|
SmartDashboard.putNumber("Left Motor Pos Inches", getDistanceInches(m_rightFrontMotor));
|
|
|
|
|
SmartDashboard.putNumber("Right Motor Pos Inches", getDistanceInches(m_leftFrontMotor));
|
|
|
|
|
|
|
|
|
|
/*SmartDashboard.putNumber("Right Front Velocity", m_rightFrontMotor.getSensorCollection().getIntegratedSensorVelocity());
|
|
|
|
|
SmartDashboard.putNumber("Left Front Velocity", m_leftFrontMotor.getSensorCollection().getIntegratedSensorVelocity());
|
|
|
|
|
SmartDashboard.putNumber("Right Back Velocity", m_rightBackMotor.getSensorCollection().getIntegratedSensorVelocity());
|
|
|
|
|
SmartDashboard.putNumber("Left Back Velocity", m_leftBackMotor.getSensorCollection().getIntegratedSensorVelocity());
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
SmartDashboard.putNumber("Right Motor Temp", m_rightFrontMotor.getTemperature());
|
|
|
|
|
SmartDashboard.putNumber("Left Motor Temp", m_leftFrontMotor.getTemperature());
|
|
|
|
|
|
|
|
|
|
SmartDashboard.putNumber("Right Front Motor Current Supply", m_rightFrontMotor.getSupplyCurrent());
|
|
|
|
|
SmartDashboard.putNumber("Left Front Motor Current Supply", m_leftFrontMotor.getSupplyCurrent());
|
|
|
|
|
SmartDashboard.putNumber("Right Back Motor Current Supply", m_rightBackMotor.getSupplyCurrent());
|
|
|
|
|
SmartDashboard.putNumber("Left Back Motor Current Supply", m_leftBackMotor.getSupplyCurrent());
|
|
|
|
|
|
|
|
|
|
SmartDashboard.putNumber("Right Front Motor Current Stator ", m_rightFrontMotor.getStatorCurrent());
|
|
|
|
|
SmartDashboard.putNumber("Left Front Motor Current Stator", m_leftFrontMotor.getStatorCurrent());
|
|
|
|
|
SmartDashboard.putNumber("Right Back Motor Current Stator ", m_rightBackMotor.getStatorCurrent());
|
|
|
|
|
SmartDashboard.putNumber("Left Back Motor Current Stator", m_leftBackMotor.getStatorCurrent());
|
|
|
|
|
|
|
|
|
|
//SmartDashboard.putNumber("PID 0 Error", m_rightFrontMotor.getClosedLoopError(DriveConstants.PID_PRIMARY));
|
|
|
|
|
//SmartDashboard.putNumber("PID 1 Error", m_rightFrontMotor.getClosedLoopError(DriveConstants.PID_TURN));
|
|
|
|
|
//SmartDashboard.putNumber("PID 0 Target", m_rightFrontMotor.getClosedLoopTarget(DriveConstants.PID_PRIMARY));
|
|
|
|
|
//SmartDashboard.putNumber("PID 1 Target", m_rightFrontMotor.getClosedLoopTarget(DriveConstants.PID_TURN));
|
|
|
|
|
//SmartDashboard.putNumber("PID 0 Pos", m_rightFrontMotor.getSelectedSensorPosition(DriveConstants.PID_PRIMARY));
|
|
|
|
|
//SmartDashboard.putNumber("PID 1 Pos", m_rightFrontMotor.getSelectedSensorPosition(DriveConstants.PID_TURN));
|
|
|
|
|
|
|
|
|
|
//SmartDashboard.putString("Odometry Values Meters", getPose().toString());
|
|
|
|
|
//SmartDashboard.putNumber("Odometry Heading", getHeading());
|
|
|
|
|
|
|
|
|
|
//SmartDashboard.putNumber("Time Seconds", m_currentTimeSec);
|
|
|
|
|
//SmartDashboard.putNumber("Delta Time", m_deltaTime);
|
|
|
|
|
|
|
|
|
|
if (m_currentSong != m_songChooser.getSelected()){
|
|
|
|
|
m_currentSong = m_songChooser.getSelected();
|
|
|
|
|
selectSong(m_currentSong);
|
|
|
|
|
//System.err.println(m_currentSong);
|
|
|
|
|
}
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
System.err.println("Error while using Drive SmartDashboard");
|
|
|
|
|
// e.printStackTrace(System.err);
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-01-09 23:55:46 +00:00
|
|
|
}
|