mirror of
https://github.com/Team4388/Robot-Electronics-Test.git
synced 2026-06-08 16:28:00 -06:00
SparkMax test code >B)
This commit is contained in:
+3
-3
@@ -18,12 +18,12 @@
|
||||
},
|
||||
"###Joysticks": {
|
||||
"Collapsed": "0",
|
||||
"Pos": "250,465",
|
||||
"Pos": "208,458",
|
||||
"Size": "796,240"
|
||||
},
|
||||
"###NetworkTables": {
|
||||
"Collapsed": "0",
|
||||
"Pos": "250,277",
|
||||
"Pos": "224,71",
|
||||
"Size": "750,185"
|
||||
},
|
||||
"###Other Devices": {
|
||||
@@ -39,7 +39,7 @@
|
||||
"###Timing": {
|
||||
"Collapsed": "0",
|
||||
"Pos": "5,150",
|
||||
"Size": "135,127"
|
||||
"Size": "135,150"
|
||||
},
|
||||
"Debug##Default": {
|
||||
"Collapsed": "0",
|
||||
|
||||
@@ -1,6 +1,11 @@
|
||||
{
|
||||
"HALProvider": {
|
||||
"Other Devices": {
|
||||
"SPARK MAX [2]": {
|
||||
"header": {
|
||||
"open": true
|
||||
}
|
||||
},
|
||||
"Talon FX[1]": {
|
||||
"header": {
|
||||
"open": true
|
||||
@@ -13,6 +18,7 @@
|
||||
"/FMSInfo": "FMSInfo",
|
||||
"/LiveWindow/FalconTester": "Subsystem",
|
||||
"/LiveWindow/LED": "Subsystem",
|
||||
"/LiveWindow/SparkTester": "Subsystem",
|
||||
"/LiveWindow/Ungrouped/Scheduler": "Scheduler"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,4 +42,7 @@ public final class Constants {
|
||||
public static final class FalconTesterConstants {
|
||||
public static final int CAN_ID = 1;
|
||||
}
|
||||
public static final class SparkTesterConstants {
|
||||
public static final int CAN_ID = 2;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@ import edu.wpi.first.wpilibj2.command.button.JoystickButton;
|
||||
import frc4388.robot.Constants.*;
|
||||
import frc4388.robot.subsystems.FalconTester;
|
||||
import frc4388.robot.subsystems.LED;
|
||||
import frc4388.robot.subsystems.SparkTester;
|
||||
import frc4388.utility.LEDPatterns;
|
||||
import frc4388.utility.controller.IHandController;
|
||||
import frc4388.utility.controller.XboxController;
|
||||
@@ -34,7 +35,8 @@ public class RobotContainer {
|
||||
|
||||
private final LED m_robotLED = new LED(m_robotMap.LEDController);
|
||||
|
||||
private final FalconTester m_falconTester = new FalconTester(m_robotMap.falconTestMotor);
|
||||
// private final FalconTester m_falconTester = new FalconTester(m_robotMap.falconTestMotor);
|
||||
private final SparkTester m_SparkTester = new SparkTester(m_robotMap.sparkTestMotor);
|
||||
|
||||
/* Controllers */
|
||||
private final XboxController m_driverXbox = new XboxController(OIConstants.XBOX_DRIVER_ID);
|
||||
@@ -48,13 +50,19 @@ public class RobotContainer {
|
||||
|
||||
/* Default Commands */
|
||||
// drives the robot with a two-axis input from the driver controller
|
||||
m_falconTester.setDefaultCommand(
|
||||
new RunCommand(() -> m_falconTester.setMotorSpeed(0.1d * getDriverController().getLeftYAxis()),
|
||||
m_falconTester));
|
||||
|
||||
// m_falconTester.setDefaultCommand(
|
||||
// new RunCommand(() -> m_falconTester.setMotorSpeed(0.1d * getDriverController().getLeftYAxis()),
|
||||
// m_falconTester));
|
||||
|
||||
m_SparkTester.setDefaultCommand(
|
||||
new RunCommand(() -> m_SparkTester.setMotorSpeed(0.25d * getDriverController().getLeftYAxis()),
|
||||
m_SparkTester));
|
||||
// continually sends updates to the Blinkin LED controller to keep the lights on
|
||||
m_robotLED.setDefaultCommand(new RunCommand(() -> m_robotLED.updateLED(), m_robotLED));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Use this method to define your button->command mappings. Buttons can be
|
||||
* created by instantiating a {@link GenericHID} or one of its subclasses
|
||||
|
||||
@@ -12,11 +12,15 @@ import com.ctre.phoenix.motorcontrol.NeutralMode;
|
||||
import com.ctre.phoenix.motorcontrol.can.WPI_TalonFX;
|
||||
import com.ctre.phoenix.sensors.PigeonIMU;
|
||||
|
||||
import com.revrobotics.CANSparkMax;
|
||||
import com.revrobotics.CANSparkMaxLowLevel.MotorType;
|
||||
|
||||
import edu.wpi.first.wpilibj.motorcontrol.Spark;
|
||||
import edu.wpi.first.wpilibj.drive.DifferentialDrive;
|
||||
import frc4388.robot.Constants.DriveConstants;
|
||||
import frc4388.robot.Constants.FalconTesterConstants;
|
||||
import frc4388.robot.Constants.LEDConstants;
|
||||
import frc4388.robot.Constants.SparkTesterConstants;
|
||||
import frc4388.robot.subsystems.FalconTester;
|
||||
|
||||
/**
|
||||
@@ -28,6 +32,7 @@ public class RobotMap {
|
||||
public RobotMap() {
|
||||
configureLEDMotorControllers();
|
||||
configureFalconTestMotorControllers();
|
||||
configureSparkTestMotor();
|
||||
}
|
||||
|
||||
/* LED Subsystem */
|
||||
@@ -37,9 +42,16 @@ public class RobotMap {
|
||||
|
||||
}
|
||||
|
||||
/* Falcon Tester */
|
||||
public final WPI_TalonFX falconTestMotor = new WPI_TalonFX(FalconTesterConstants.CAN_ID);
|
||||
void configureFalconTestMotorControllers() {
|
||||
falconTestMotor.configFactoryDefault();
|
||||
falconTestMotor.setNeutralMode(NeutralMode.Brake);
|
||||
}
|
||||
|
||||
/* SparkMax Tester*/
|
||||
public final CANSparkMax sparkTestMotor = new CANSparkMax(SparkTesterConstants.CAN_ID, MotorType.kBrushless);
|
||||
void configureSparkTestMotor() {
|
||||
sparkTestMotor.restoreFactoryDefaults();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,13 +17,13 @@ public class SparkTester extends SubsystemBase {
|
||||
}
|
||||
|
||||
public void setMotorSpeed(double speed) {
|
||||
speed = Double.max(Double.min(speed, 1.d), -1.d);
|
||||
// speed = Double.max(Double.min(speed, 1.d), -1.d);
|
||||
m_sparkMaxTestMotor.set(speed);
|
||||
System.err.println(speed);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void periodic() {
|
||||
// This method will be called once per scheduler run
|
||||
//Test
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user