Added robot drive and some dashboard
This commit is contained in:
parent
edd9b9eba0
commit
e4928925fa
@ -7,6 +7,8 @@ package frc.robot;
|
|||||||
import edu.wpi.first.wpilibj.GenericHID;
|
import edu.wpi.first.wpilibj.GenericHID;
|
||||||
import edu.wpi.first.wpilibj.XboxController;
|
import edu.wpi.first.wpilibj.XboxController;
|
||||||
import edu.wpi.first.wpilibj2.command.Command;
|
import edu.wpi.first.wpilibj2.command.Command;
|
||||||
|
import frc.robot.commands.Drive;
|
||||||
|
import frc.robot.subsystems.DriveTrain;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class is where the bulk of the robot should be declared. Since Command-based is a
|
* This class is where the bulk of the robot should be declared. Since Command-based is a
|
||||||
@ -15,13 +17,21 @@ import edu.wpi.first.wpilibj2.command.Command;
|
|||||||
* subsystems, commands, and button mappings) should be declared here.
|
* subsystems, commands, and button mappings) should be declared here.
|
||||||
*/
|
*/
|
||||||
public class RobotContainer {
|
public class RobotContainer {
|
||||||
// The robot's subsystems and commands are defined here...
|
|
||||||
|
|
||||||
|
private final XboxController controller = new XboxController(0);
|
||||||
|
|
||||||
|
// The robot's subsystems and commands are defined here...
|
||||||
|
private final DriveTrain driveTrain = new DriveTrain();
|
||||||
|
|
||||||
|
private final Drive drive = new Drive(driveTrain, () -> controller.getLeftY(), () -> controller.getLeftX());
|
||||||
|
|
||||||
/** The container for the robot. Contains subsystems, OI devices, and commands. */
|
/** The container for the robot. Contains subsystems, OI devices, and commands. */
|
||||||
public RobotContainer() {
|
public RobotContainer() {
|
||||||
// Configure the button bindings
|
// Configure the button bindings
|
||||||
configureButtonBindings();
|
configureButtonBindings();
|
||||||
|
|
||||||
|
driveTrain.setDefaultCommand(drive);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
62
src/main/java/frc/robot/commands/Drive.java
Normal file
62
src/main/java/frc/robot/commands/Drive.java
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
// Copyright (c) FIRST and other WPILib contributors.
|
||||||
|
// Open Source Software; you can modify and/or share it under the terms of
|
||||||
|
// the WPILib BSD license file in the root directory of this project.
|
||||||
|
|
||||||
|
package frc.robot.commands;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.function.DoubleSupplier;
|
||||||
|
|
||||||
|
import edu.wpi.first.networktables.NetworkTableEntry;
|
||||||
|
import edu.wpi.first.wpilibj.shuffleboard.BuiltInWidgets;
|
||||||
|
import edu.wpi.first.wpilibj.shuffleboard.Shuffleboard;
|
||||||
|
import edu.wpi.first.wpilibj.shuffleboard.ShuffleboardTab;
|
||||||
|
import edu.wpi.first.wpilibj2.command.CommandBase;
|
||||||
|
import frc.robot.subsystems.DriveTrain;
|
||||||
|
|
||||||
|
public class Drive extends CommandBase {
|
||||||
|
|
||||||
|
private final DriveTrain driveTrain;
|
||||||
|
private final DoubleSupplier speed;
|
||||||
|
private final DoubleSupplier rotation;
|
||||||
|
|
||||||
|
private final ShuffleboardTab tab = Shuffleboard.getTab("Peanut");
|
||||||
|
private final NetworkTableEntry maxSpeed = tab.addPersistent("Max Speed", 0.5)
|
||||||
|
.withWidget(BuiltInWidgets.kNumberSlider)
|
||||||
|
.withSize(2, 1)
|
||||||
|
.withProperties(Map.of("min", 0, "max", 1))
|
||||||
|
.getEntry();
|
||||||
|
|
||||||
|
/** Creates a new Drive. */
|
||||||
|
public Drive(DriveTrain driveTrain, DoubleSupplier speed, DoubleSupplier rotation) {
|
||||||
|
this.driveTrain = driveTrain;
|
||||||
|
this.speed = speed;
|
||||||
|
this.rotation = rotation;
|
||||||
|
// Use addRequirements() here to declare subsystem dependencies.
|
||||||
|
addRequirements(driveTrain);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Called when the command is initially scheduled.
|
||||||
|
@Override
|
||||||
|
public void initialize() {}
|
||||||
|
|
||||||
|
// Called every time the scheduler runs while the command is scheduled.
|
||||||
|
@Override
|
||||||
|
public void execute() {
|
||||||
|
double max = maxSpeed.getDouble(0.5);
|
||||||
|
double spd = speed.getAsDouble() * max;
|
||||||
|
double rot = rotation.getAsDouble() * max;
|
||||||
|
|
||||||
|
driveTrain.arcadeDrive(spd, rot);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Called once the command ends or is interrupted.
|
||||||
|
@Override
|
||||||
|
public void end(boolean interrupted) {}
|
||||||
|
|
||||||
|
// Returns true when the command should end.
|
||||||
|
@Override
|
||||||
|
public boolean isFinished() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
40
src/main/java/frc/robot/subsystems/DriveTrain.java
Normal file
40
src/main/java/frc/robot/subsystems/DriveTrain.java
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
// Copyright (c) FIRST and other WPILib contributors.
|
||||||
|
// Open Source Software; you can modify and/or share it under the terms of
|
||||||
|
// the WPILib BSD license file in the root directory of this project.
|
||||||
|
|
||||||
|
package frc.robot.subsystems;
|
||||||
|
|
||||||
|
import com.ctre.phoenix.motorcontrol.can.WPI_TalonSRX;
|
||||||
|
|
||||||
|
import edu.wpi.first.wpilibj.drive.DifferentialDrive;
|
||||||
|
import edu.wpi.first.wpilibj.shuffleboard.Shuffleboard;
|
||||||
|
import edu.wpi.first.wpilibj.shuffleboard.ShuffleboardTab;
|
||||||
|
import edu.wpi.first.wpilibj2.command.SubsystemBase;
|
||||||
|
|
||||||
|
public class DriveTrain extends SubsystemBase {
|
||||||
|
|
||||||
|
private final WPI_TalonSRX roueGauche = new WPI_TalonSRX(1);
|
||||||
|
private final WPI_TalonSRX roueDroite = new WPI_TalonSRX(2);
|
||||||
|
|
||||||
|
private final DifferentialDrive drive = new DifferentialDrive(roueGauche, roueDroite);
|
||||||
|
|
||||||
|
private final ShuffleboardTab tab = Shuffleboard.getTab("Peanut");
|
||||||
|
|
||||||
|
/** Creates a new DriveTrain. */
|
||||||
|
public DriveTrain() {
|
||||||
|
tab.add("Drive Train", drive);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void arcadeDrive(double spd, double rot) {
|
||||||
|
drive.arcadeDrive(spd, rot);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void arcadeDrive(double spd, double rot, boolean squared) {
|
||||||
|
drive.arcadeDrive(spd, rot, squared);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void periodic() {
|
||||||
|
// This method will be called once per scheduler run
|
||||||
|
}
|
||||||
|
}
|
257
vendordeps/Phoenix.json
Normal file
257
vendordeps/Phoenix.json
Normal file
@ -0,0 +1,257 @@
|
|||||||
|
{
|
||||||
|
"fileName": "Phoenix.json",
|
||||||
|
"name": "CTRE-Phoenix",
|
||||||
|
"version": "5.21.2",
|
||||||
|
"frcYear": 2022,
|
||||||
|
"uuid": "ab676553-b602-441f-a38d-f1296eff6537",
|
||||||
|
"mavenUrls": [
|
||||||
|
"https://maven.ctr-electronics.com/release/"
|
||||||
|
],
|
||||||
|
"jsonUrl": "https://maven.ctr-electronics.com/release/com/ctre/phoenix/Phoenix-frc2022-latest.json",
|
||||||
|
"javaDependencies": [
|
||||||
|
{
|
||||||
|
"groupId": "com.ctre.phoenix",
|
||||||
|
"artifactId": "api-java",
|
||||||
|
"version": "5.21.2"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"groupId": "com.ctre.phoenix",
|
||||||
|
"artifactId": "wpiapi-java",
|
||||||
|
"version": "5.21.2"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"jniDependencies": [
|
||||||
|
{
|
||||||
|
"groupId": "com.ctre.phoenix",
|
||||||
|
"artifactId": "cci",
|
||||||
|
"version": "5.21.2",
|
||||||
|
"isJar": false,
|
||||||
|
"skipInvalidPlatforms": true,
|
||||||
|
"validPlatforms": [
|
||||||
|
"linuxathena"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"groupId": "com.ctre.phoenix.sim",
|
||||||
|
"artifactId": "cci-sim",
|
||||||
|
"version": "5.21.2",
|
||||||
|
"isJar": false,
|
||||||
|
"skipInvalidPlatforms": true,
|
||||||
|
"validPlatforms": [
|
||||||
|
"windowsx86-64",
|
||||||
|
"linuxx86-64",
|
||||||
|
"osxx86-64"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"groupId": "com.ctre.phoenix.sim",
|
||||||
|
"artifactId": "simTalonSRX",
|
||||||
|
"version": "5.21.2",
|
||||||
|
"isJar": false,
|
||||||
|
"skipInvalidPlatforms": true,
|
||||||
|
"validPlatforms": [
|
||||||
|
"windowsx86-64",
|
||||||
|
"linuxx86-64",
|
||||||
|
"osxx86-64"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"groupId": "com.ctre.phoenix.sim",
|
||||||
|
"artifactId": "simTalonFX",
|
||||||
|
"version": "5.21.2",
|
||||||
|
"isJar": false,
|
||||||
|
"skipInvalidPlatforms": true,
|
||||||
|
"validPlatforms": [
|
||||||
|
"windowsx86-64",
|
||||||
|
"linuxx86-64",
|
||||||
|
"osxx86-64"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"groupId": "com.ctre.phoenix.sim",
|
||||||
|
"artifactId": "simVictorSPX",
|
||||||
|
"version": "5.21.2",
|
||||||
|
"isJar": false,
|
||||||
|
"skipInvalidPlatforms": true,
|
||||||
|
"validPlatforms": [
|
||||||
|
"windowsx86-64",
|
||||||
|
"linuxx86-64",
|
||||||
|
"osxx86-64"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"groupId": "com.ctre.phoenix.sim",
|
||||||
|
"artifactId": "simPigeonIMU",
|
||||||
|
"version": "5.21.2",
|
||||||
|
"isJar": false,
|
||||||
|
"skipInvalidPlatforms": true,
|
||||||
|
"validPlatforms": [
|
||||||
|
"windowsx86-64",
|
||||||
|
"linuxx86-64",
|
||||||
|
"osxx86-64"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"groupId": "com.ctre.phoenix.sim",
|
||||||
|
"artifactId": "simCANCoder",
|
||||||
|
"version": "5.21.2",
|
||||||
|
"isJar": false,
|
||||||
|
"skipInvalidPlatforms": true,
|
||||||
|
"validPlatforms": [
|
||||||
|
"windowsx86-64",
|
||||||
|
"linuxx86-64",
|
||||||
|
"osxx86-64"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"cppDependencies": [
|
||||||
|
{
|
||||||
|
"groupId": "com.ctre.phoenix",
|
||||||
|
"artifactId": "wpiapi-cpp",
|
||||||
|
"version": "5.21.2",
|
||||||
|
"libName": "CTRE_Phoenix_WPI",
|
||||||
|
"headerClassifier": "headers",
|
||||||
|
"sharedLibrary": true,
|
||||||
|
"skipInvalidPlatforms": true,
|
||||||
|
"binaryPlatforms": [
|
||||||
|
"linuxathena"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"groupId": "com.ctre.phoenix",
|
||||||
|
"artifactId": "api-cpp",
|
||||||
|
"version": "5.21.2",
|
||||||
|
"libName": "CTRE_Phoenix",
|
||||||
|
"headerClassifier": "headers",
|
||||||
|
"sharedLibrary": true,
|
||||||
|
"skipInvalidPlatforms": true,
|
||||||
|
"binaryPlatforms": [
|
||||||
|
"linuxathena"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"groupId": "com.ctre.phoenix",
|
||||||
|
"artifactId": "cci",
|
||||||
|
"version": "5.21.2",
|
||||||
|
"libName": "CTRE_PhoenixCCI",
|
||||||
|
"headerClassifier": "headers",
|
||||||
|
"sharedLibrary": true,
|
||||||
|
"skipInvalidPlatforms": true,
|
||||||
|
"binaryPlatforms": [
|
||||||
|
"linuxathena"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"groupId": "com.ctre.phoenix.sim",
|
||||||
|
"artifactId": "wpiapi-cpp-sim",
|
||||||
|
"version": "5.21.2",
|
||||||
|
"libName": "CTRE_Phoenix_WPISim",
|
||||||
|
"headerClassifier": "headers",
|
||||||
|
"sharedLibrary": true,
|
||||||
|
"skipInvalidPlatforms": true,
|
||||||
|
"binaryPlatforms": [
|
||||||
|
"windowsx86-64",
|
||||||
|
"linuxx86-64",
|
||||||
|
"osxx86-64"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"groupId": "com.ctre.phoenix.sim",
|
||||||
|
"artifactId": "api-cpp-sim",
|
||||||
|
"version": "5.21.2",
|
||||||
|
"libName": "CTRE_PhoenixSim",
|
||||||
|
"headerClassifier": "headers",
|
||||||
|
"sharedLibrary": true,
|
||||||
|
"skipInvalidPlatforms": true,
|
||||||
|
"binaryPlatforms": [
|
||||||
|
"windowsx86-64",
|
||||||
|
"linuxx86-64",
|
||||||
|
"osxx86-64"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"groupId": "com.ctre.phoenix.sim",
|
||||||
|
"artifactId": "cci-sim",
|
||||||
|
"version": "5.21.2",
|
||||||
|
"libName": "CTRE_PhoenixCCISim",
|
||||||
|
"headerClassifier": "headers",
|
||||||
|
"sharedLibrary": true,
|
||||||
|
"skipInvalidPlatforms": true,
|
||||||
|
"binaryPlatforms": [
|
||||||
|
"windowsx86-64",
|
||||||
|
"linuxx86-64",
|
||||||
|
"osxx86-64"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"groupId": "com.ctre.phoenix.sim",
|
||||||
|
"artifactId": "simTalonSRX",
|
||||||
|
"version": "5.21.2",
|
||||||
|
"libName": "CTRE_SimTalonSRX",
|
||||||
|
"headerClassifier": "headers",
|
||||||
|
"sharedLibrary": true,
|
||||||
|
"skipInvalidPlatforms": true,
|
||||||
|
"binaryPlatforms": [
|
||||||
|
"windowsx86-64",
|
||||||
|
"linuxx86-64",
|
||||||
|
"osxx86-64"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"groupId": "com.ctre.phoenix.sim",
|
||||||
|
"artifactId": "simTalonFX",
|
||||||
|
"version": "5.21.2",
|
||||||
|
"libName": "CTRE_SimTalonFX",
|
||||||
|
"headerClassifier": "headers",
|
||||||
|
"sharedLibrary": true,
|
||||||
|
"skipInvalidPlatforms": true,
|
||||||
|
"binaryPlatforms": [
|
||||||
|
"windowsx86-64",
|
||||||
|
"linuxx86-64",
|
||||||
|
"osxx86-64"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"groupId": "com.ctre.phoenix.sim",
|
||||||
|
"artifactId": "simVictorSPX",
|
||||||
|
"version": "5.21.2",
|
||||||
|
"libName": "CTRE_SimVictorSPX",
|
||||||
|
"headerClassifier": "headers",
|
||||||
|
"sharedLibrary": true,
|
||||||
|
"skipInvalidPlatforms": true,
|
||||||
|
"binaryPlatforms": [
|
||||||
|
"windowsx86-64",
|
||||||
|
"linuxx86-64",
|
||||||
|
"osxx86-64"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"groupId": "com.ctre.phoenix.sim",
|
||||||
|
"artifactId": "simPigeonIMU",
|
||||||
|
"version": "5.21.2",
|
||||||
|
"libName": "CTRE_SimPigeonIMU",
|
||||||
|
"headerClassifier": "headers",
|
||||||
|
"sharedLibrary": true,
|
||||||
|
"skipInvalidPlatforms": true,
|
||||||
|
"binaryPlatforms": [
|
||||||
|
"windowsx86-64",
|
||||||
|
"linuxx86-64",
|
||||||
|
"osxx86-64"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"groupId": "com.ctre.phoenix.sim",
|
||||||
|
"artifactId": "simCANCoder",
|
||||||
|
"version": "5.21.2",
|
||||||
|
"libName": "CTRE_SimCANCoder",
|
||||||
|
"headerClassifier": "headers",
|
||||||
|
"sharedLibrary": true,
|
||||||
|
"skipInvalidPlatforms": true,
|
||||||
|
"binaryPlatforms": [
|
||||||
|
"windowsx86-64",
|
||||||
|
"linuxx86-64",
|
||||||
|
"osxx86-64"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user