Skip to content
Open
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
10 changes: 5 additions & 5 deletions src/main/java/team3176/robot/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@

public final class Constants {
private static final RobotType robot = RobotType.ROBOT_SIMBOT;
public static final double loopPeriodSecs = 0.02;
public static final boolean tuningMode = false;
public static final double LOOP_PERIODIC_SECS = 0.02;
public static final boolean TUNING_MODE = true;

public static boolean invalidRobotAlertSent = false;

public static RobotType getRobot() {
if (!disableHAL && RobotBase.isReal()) {
if (!isHALdisable && RobotBase.isReal()) {
if (robot == RobotType.ROBOT_SIMBOT) { // Invalid robot selected
if (!invalidRobotAlertSent) {
invalidRobotAlertSent = true;
Expand Down Expand Up @@ -62,10 +62,10 @@ public static enum Mode {
}

// Function to disable HAL interaction when running without native libs
public static boolean disableHAL = false;
public static boolean isHALdisable = false;

public static void disableHAL() {
disableHAL = true;
isHALdisable = true;
}

/** Checks whether the robot the correct robot is selected when deploying. */
Expand Down
89 changes: 53 additions & 36 deletions src/main/java/team3176/robot/Robot.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,8 @@
import edu.wpi.first.wpilibj2.command.Command;
import edu.wpi.first.wpilibj2.command.CommandScheduler;
import team3176.robot.Constants.RobotType;
import team3176.robot.subsystems.superstructure.Arm;
import edu.wpi.first.cameraserver.CameraServer;
import edu.wpi.first.cscore.UsbCamera;
import edu.wpi.first.cscore.CvSource;

/**
* The VM is configured to automatically run this class, and to call the functions corresponding to
Expand All @@ -29,11 +27,11 @@
* project.
*/
public class Robot extends LoggedRobot{
private Command m_autonomousCommand;

private RobotContainer m_robotContainer;
Thread m_fisheyeThread;
private Command autonomousCommand;

private RobotContainer robotContainer;
Thread fisheyeThread;
private static final boolean FISHEYE_CAMERA = false;
/**
* This function is run when the robot is first started up and should be used for any
* initialization code.
Expand All @@ -43,23 +41,24 @@ public void robotInit() {
// Instantiate our RobotContainer. This will perform all our button bindings, and put our
// autonomous chooser on the dashboard.
Logger logger = Logger.getInstance();
logger.recordMetadata("Robot", Constants.getRobot().toString());
System.out.println("[Init] Starting AdvantageKit");
logger.recordMetadata("Robot", Constants.getRobot().toString());
logger.recordMetadata("RuntimeType", getRuntimeType().toString());
logger.recordMetadata("ProjectName", BuildConstants.MAVEN_NAME);
logger.recordMetadata("BuildDate", BuildConstants.BUILD_DATE);
logger.recordMetadata("GitSHA", BuildConstants.GIT_SHA);
logger.recordMetadata("GitDate", BuildConstants.GIT_DATE);
logger.recordMetadata("GitBranch", BuildConstants.GIT_BRANCH);
final String GitDirty = "GitDirty";
switch (BuildConstants.DIRTY) {
case 0:
logger.recordMetadata("GitDirty", "All changes committed");
logger.recordMetadata(GitDirty, "All changes committed");
break;
case 1:
logger.recordMetadata("GitDirty", "Uncomitted changes");
logger.recordMetadata(GitDirty, "Uncomitted changes");
break;
default:
logger.recordMetadata("GitDirty", "Unknown");
logger.recordMetadata(GitDirty, "Unknown");
break;
}
switch (Constants.getMode()) {
Expand Down Expand Up @@ -90,15 +89,21 @@ public void robotInit() {
logger.start();


m_robotContainer = new RobotContainer();
robotContainer = new RobotContainer();
SmartDashboard.putData(CommandScheduler.getInstance());
// m_fisheyeThread = new Thread( () -> {
// UsbCamera fisheye = CameraServer.startAutomaticCapture();
// fisheye.setResolution(640,480);
// CvSource outputStream = CameraServer.putVideo("fisheye", 640, 480);
// });
// m_fisheyeThread.setDaemon(true);
// m_fisheyeThread.start();

if(FISHEYE_CAMERA)
{
fisheyeThread = new Thread( () -> {
UsbCamera fisheye = CameraServer.startAutomaticCapture();
fisheye.setResolution(640,480);
//not using this at the return so commenting for linting: CvSource outputStream =
CameraServer.putVideo("fisheye", 640, 480);
});
fisheyeThread.setDaemon(true);
fisheyeThread.start();
}


}

Expand All @@ -121,47 +126,53 @@ public void robotPeriodic() {
/** This function is called once each time the robot enters Disabled mode. */
@Override
public void disabledInit() {
m_robotContainer.setArmCoast();
robotContainer.setArmCoast();
}

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

/** This autonomous runs the autonomous command selected by your {@link RobotContainer} class. */
@Override
public void autonomousInit() {
m_robotContainer.clearCanFaults();
m_robotContainer.setArmBrake();
m_robotContainer.setThrustBrake();
m_autonomousCommand = m_robotContainer.getAutonomousCommand();
robotContainer.clearCanFaults();
robotContainer.setArmBrake();
robotContainer.setThrustBrake();
autonomousCommand = robotContainer.getAutonomousCommand();

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

/** This function is called periodically during autonomous. */
@Override
public void autonomousPeriodic() {}
public void autonomousPeriodic() {
//scheduled command executes from init()
}

@Override
public void teleopInit() {
// This makes sure that the autonomous stops running when
// teleop starts running. If you want the autonomous to
// continue until interrupted by another command, remove
// this line or comment it out.
m_robotContainer.clearCanFaults();
m_robotContainer.setArmBrake();
m_robotContainer.setThrustCoast();
if (m_autonomousCommand != null) {
m_autonomousCommand.cancel();
robotContainer.clearCanFaults();
robotContainer.setArmBrake();
robotContainer.setThrustCoast();
if (autonomousCommand != null) {
autonomousCommand.cancel();
}
}

/** This function is called periodically during operator control. */
@Override
public void teleopPeriodic() {}
public void teleopPeriodic() {
//command scheduler is responsible for actions
}

@Override
public void testInit() {
Expand All @@ -171,13 +182,19 @@ public void testInit() {

/** This function is called periodically during test mode. */
@Override
public void testPeriodic() {}
public void testPeriodic() {
//nan
}

/** This function is called once when the robot is first started up. */
@Override
public void simulationInit() {}
public void simulationInit() {
//nan
}

/** This function is called periodically whilst in simulation. */
@Override
public void simulationPeriodic() {}
public void simulationPeriodic() {
//nan
}
}
Loading