Skip to content

Commit

Permalink
I'm a little confused, might work
Browse files Browse the repository at this point in the history
  • Loading branch information
MattD8957 committed Oct 12, 2023
1 parent 3a33978 commit 37c033c
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 7 deletions.
3 changes: 3 additions & 0 deletions src/main/java/frc/robot/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -158,5 +158,8 @@ public static final class AutonomousConstants {
public static final PIDConstants POSE_PID_CONSTANTS = new PIDConstants(0, 0, 0); // X and Y position PID

public static final PathConstraints CUBE_CHASE_CONSTRAINTS = new PathConstraints(2, 2); // TODO TEST FOR MAX

public static final double MAX_VELOCITY = 2;
public static final double MAX_ACCELERATION = 1;
}
}
16 changes: 10 additions & 6 deletions src/main/java/frc/robot/Robot.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
import edu.wpi.first.wpilibj.TimedRobot;
import edu.wpi.first.wpilibj2.command.Command;
import edu.wpi.first.wpilibj2.command.CommandScheduler;
import frc.lib.auto.Autonomous;
import frc.lib.auto.AutonomousCommandFactory;

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

private RobotContainer m_robotContainer;

Expand All @@ -18,6 +20,8 @@ public void robotInit() {
// Instantiate our RobotContainer. This will perform all our button bindings, and put our
// autonomous chooser on the dashboard.
m_robotContainer = new RobotContainer();
Autonomous.load();
AutonomousCommandFactory.connectToServer(5811);
}

/**
Expand Down Expand Up @@ -46,11 +50,11 @@ public void disabledPeriodic() {}
/** This autonomous runs the autonomous command selected by your {@link RobotContainer} class. */
@Override
public void autonomousInit() {
m_autonomousCommand = m_robotContainer.getAutonomousCommand();
autonomousCommand = Autonomous.getAutonomous();

// schedule the autonomous command (example)
if (m_autonomousCommand != null) {
m_autonomousCommand.schedule();
if (autonomousCommand != null) {
autonomousCommand.schedule();
}
}

Expand All @@ -64,8 +68,8 @@ public void teleopInit() {
// teleop starts running. If you want the autonomous to
// continue until interrupted by another command, remove
// this line or comment it out.
if (m_autonomousCommand != null) {
m_autonomousCommand.cancel();
if (autonomousCommand != null) {
autonomousCommand.cancel();
}
}

Expand Down
14 changes: 13 additions & 1 deletion src/main/java/frc/robot/RobotContainer.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
package frc.robot;

import java.util.HashMap;
import edu.wpi.first.math.geometry.Rotation2d;
import edu.wpi.first.math.geometry.Translation2d;
import edu.wpi.first.wpilibj.XboxController;
import edu.wpi.first.wpilibj2.command.Command;
import edu.wpi.first.wpilibj2.command.InstantCommand;
import edu.wpi.first.wpilibj2.command.button.Trigger;
import frc.lib.auto.AutonomousCommandFactory;
import frc.lib.pathplanner.com.pathplanner.lib.PathConstraints;
import frc.lib.pathplanner.com.pathplanner.lib.PathPoint;
import frc.lib.util.Limelight;
import frc.robot.Constants.AutonomousConstants;
Expand Down Expand Up @@ -44,5 +46,15 @@ private void configureDefaultCommands() {
drivetrain.setDefaultCommand(new TeleopSwerve(drivetrain, () -> driver.getLeftY(), () -> driver.getLeftX(), () -> driver.getRightX(), () -> (driver.getRightTriggerAxis() > 0.75)));
}

public Command getAutonomousCommand() { return autoFactory}
private void configureAutonomousCommands(){
autoFactory.makeTrajectory("B2[1]-M-C-HIGH", new HashMap<>(),
new PathConstraints(AutonomousConstants.MAX_VELOCITY, AutonomousConstants.MAX_ACCELERATION));

}

protected AutonomousCommandFactory getCommandFactory(){
return autoFactory;
}

public Command getAutonomousCommand() { return null;}
}

0 comments on commit 37c033c

Please sign in to comment.