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