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

Logger test rewrite #3

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
52 changes: 44 additions & 8 deletions src/main/java/frc/robot/Robot.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
package frc.robot;

// Imports
import java.util.logging.Logger; // Logging based on
// https://github.com/frc6506/SkeletorCode-2022/releases/tag/v0.2.0l-Logging-Backup

import edu.wpi.first.cameraserver.CameraServer;
import edu.wpi.first.cscore.UsbCamera;
import edu.wpi.first.wpilibj.Joystick;
Expand All @@ -23,6 +26,9 @@
* project.
*/
public class Robot extends TimedRobot {
// Get logger
private final Logger logger = Logger.getLogger(this.getClass().getName());

// Spark motor controller
private final Spark m_leftMotor1 = new Spark(0);
private final Spark m_leftMotor2 = new Spark(1);
Expand Down Expand Up @@ -51,6 +57,8 @@ public void robotInit() {
UsbCamera cam = CameraServer.startAutomaticCapture();
cam.setResolution(160, 120);
cam.setFPS(30);

logger.info("robotInit complete");
}

/**
Expand All @@ -64,7 +72,9 @@ public void robotInit() {
* https://github.com/BobSaidHi/FRC-2022.2.1-TimedRobotTemplate
*/
@Override
public void robotPeriodic() {}
public void robotPeriodic() {
logger.finer("robotPeriodic complete");
}

/**
* This autonomous (along with the chooser code above) shows how to select between different
Expand All @@ -77,37 +87,63 @@ public void robotPeriodic() {}
* chooser code above as well.
*/
@Override
public void autonomousInit() {}
public void autonomousInit() {
logger.info("autonomousInit complete");
}

/** This function is called periodically during autonomous. */
@Override
public void autonomousPeriodic() {}
public void autonomousPeriodic() {
logger.finer("autonomousPeriodic complete");
}

/** This function is called once when teleop is enabled. */
@Override
public void teleopInit() {}

@Override
public void teleopPeriodic() {
// Read the controller and store is as variable so that it can be logged
double ySpeedRaw = m_stick.getY();
double zRotatoinRaw = m_stick.getX();
logger.fine("ySpeedRaw: " + ySpeedRaw + "\tzRotatoinRaw: " + zRotatoinRaw);

// Scale the raw reading to make it more controllabe and/or limit power consumption
// double ySpeedScaled = -ySpeedRaw * .75;
double ySpeedScaled = -ySpeedRaw * 1;
// ouble zRotatoinScaled = zRotatoinRaw * .65;
double zRotatoinScaled = zRotatoinRaw * 1;
logger.fine("xSpeedScaled: " + ySpeedScaled + "\tzRotatoinScaled: " + zRotatoinScaled);

// Drive with arcade drive.
// That means that the Y axis drives forward
// and backward, and the X turns left and right.
m_robotDrive.arcadeDrive(-m_stick.getY(), m_stick.getX());
m_robotDrive.arcadeDrive(ySpeedScaled, zRotatoinScaled);

logger.finer("autonomousPeriodic complete");
}

/** This function is called once when the robot is disabled. */
@Override
public void disabledInit() {}
public void disabledInit() {
logger.info("disabledInit complete");
}

/** This function is called periodically when disabled. */
@Override
public void disabledPeriodic() {}
public void disabledPeriodic() {
logger.finer("disabledPeriodic complete");
}

/** This function is called once when test mode is enabled. */
@Override
public void testInit() {}
public void testInit() {
logger.info("testInit complete");
}

/** This function is called periodically during test mode. */
@Override
public void testPeriodic() {}
public void testPeriodic() {
logger.finer("testPeriodic complete");
}
}