Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Swerve Auto + Sim + Commands #10

Merged
merged 15 commits into from
Sep 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -177,5 +177,4 @@ logs/
# Folder that has CTRE Phoenix Sim device config storage
ctre_sim/


src/main/java/frc/robot/BuildConstants.java
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"java.test.defaultConfig": "WPIlibUnitTests",
"java.compile.nullAnalysis.mode": "automatic",
"cSpell.words": [
"odometry"
"odometry",
"telemeterize"
]
}
1 change: 1 addition & 0 deletions networktables.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[]
100 changes: 100 additions & 0 deletions simgui-ds.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
{
"keyboardJoysticks": [
{
"axisConfig": [
{
"decKey": 65,
"incKey": 68
},
{
"decKey": 87,
"incKey": 83
},
{
"decKey": 69,
"decayRate": 0.0,
"incKey": 82,
"keyRate": 0.009999999776482582
}
],
"axisCount": 3,
"buttonCount": 4,
"buttonKeys": [
90,
88,
67,
86
],
"povConfig": [
{
"key0": 328,
"key135": 323,
"key180": 322,
"key225": 321,
"key270": 324,
"key315": 327,
"key45": 329,
"key90": 326
}
],
"povCount": 1
},
{
"axisConfig": [
{
"decKey": 74,
"incKey": 76
},
{
"decKey": 73,
"incKey": 75
}
],
"axisCount": 2,
"buttonCount": 4,
"buttonKeys": [
77,
44,
46,
47
],
"povCount": 0
},
{
"axisConfig": [
{
"decKey": 263,
"incKey": 262
},
{
"decKey": 265,
"incKey": 264
}
],
"axisCount": 2,
"buttonCount": 6,
"buttonKeys": [
260,
268,
266,
261,
269,
267
],
"povCount": 0
},
{
"axisCount": 0,
"buttonCount": 0,
"povCount": 0
}
],
"robotJoysticks": [
{
"guid": "Keyboard0"
},
{
"guid": "Keyboard1"
}
]
}
31 changes: 31 additions & 0 deletions simgui.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"NTProvider": {
"types": {
"/FMSInfo": "FMSInfo",
"/Pose": "Field2d",
"/SmartDashboard/Module 0": "Mechanism2d",
"/SmartDashboard/Module 1": "Mechanism2d",
"/SmartDashboard/Module 2": "Mechanism2d",
"/SmartDashboard/Module 3": "Mechanism2d"
}
},
"NetworkTables": {
"Persistent Values": {
"open": false
},
"transitory": {
"Drive": {
"open": true
},
"Pose": {
"double[]##v_/Pose/robotPose": {
"open": true
},
"open": true
}
}
},
"NetworkTables Info": {
"visible": true
}
}
90 changes: 45 additions & 45 deletions src/main/java/frc/robot/Robot.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,70 +4,70 @@

package frc.robot;

import edu.wpi.first.wpilibj.TimedRobot;
import edu.wpi.first.wpilibj2.command.Command;
import edu.wpi.first.wpilibj2.command.CommandScheduler;
import org.littletonrobotics.junction.LoggedRobot;

public class Robot extends TimedRobot {
private Command m_autonomousCommand;
public class Robot extends LoggedRobot {
private Command m_autonomousCommand;

private RobotContainer m_robotContainer;
private RobotContainer m_robotContainer;

@Override
public void robotInit() {
m_robotContainer = new RobotContainer();
}
@Override
public void robotInit() {
m_robotContainer = new RobotContainer();
}

@Override
public void robotPeriodic() {
CommandScheduler.getInstance().run();
}
@Override
public void robotPeriodic() {
CommandScheduler.getInstance().run();
}

@Override
public void disabledInit() {}
@Override
public void disabledInit() {}

@Override
public void disabledPeriodic() {}
@Override
public void disabledPeriodic() {}

@Override
public void disabledExit() {}
@Override
public void disabledExit() {}

@Override
public void autonomousInit() {
m_autonomousCommand = m_robotContainer.getAutonomousCommand();
@Override
public void autonomousInit() {
m_autonomousCommand = m_robotContainer.getAutonomousCommand();

if (m_autonomousCommand != null) {
m_autonomousCommand.schedule();
if (m_autonomousCommand != null) {
m_autonomousCommand.schedule();
}
}
}

@Override
public void autonomousPeriodic() {}
@Override
public void autonomousPeriodic() {}

@Override
public void autonomousExit() {}
@Override
public void autonomousExit() {}

@Override
public void teleopInit() {
if (m_autonomousCommand != null) {
m_autonomousCommand.cancel();
@Override
public void teleopInit() {
if (m_autonomousCommand != null) {
m_autonomousCommand.cancel();
}
}
}

@Override
public void teleopPeriodic() {}
@Override
public void teleopPeriodic() {}

@Override
public void teleopExit() {}
@Override
public void teleopExit() {}

@Override
public void testInit() {
CommandScheduler.getInstance().cancelAll();
}
@Override
public void testInit() {
CommandScheduler.getInstance().cancelAll();
}

@Override
public void testPeriodic() {}
@Override
public void testPeriodic() {}

@Override
public void testExit() {}
@Override
public void testExit() {}
}
26 changes: 19 additions & 7 deletions src/main/java/frc/robot/RobotContainer.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,27 @@

import edu.wpi.first.wpilibj2.command.Command;
import edu.wpi.first.wpilibj2.command.Commands;
import edu.wpi.first.wpilibj2.command.button.CommandJoystick;
import frc.robot.constants.PhoenixDriveConstants;
import frc.robot.subsystems.drive.PhoenixDrive;
import frc.robot.subsystems.drive.commands.DriveWithJoysticks;

public class RobotContainer {
public RobotContainer() {
configureBindings();
}
PhoenixDrive drive = PhoenixDriveConstants.DriveTrain;
Telemetry logger = new Telemetry(6);
CommandJoystick leftJoystick = new CommandJoystick(0);
CommandJoystick rightJoystick = new CommandJoystick(1);

private void configureBindings() {}
public RobotContainer() {
configureBindings();
}

public Command getAutonomousCommand() {
return Commands.print("No autonomous command configured");
}
private void configureBindings() {
drive.registerTelemetry(logger::telemeterize);
drive.setDefaultCommand(new DriveWithJoysticks(drive, leftJoystick, rightJoystick));
}

public Command getAutonomousCommand() {
return Commands.print("No autonomous command configured");
}
}
Loading
Loading