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 threading #26

Merged
merged 8 commits into from
Oct 12, 2023
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
482 changes: 241 additions & 241 deletions src/main/java/frc/robot/Robot.java

Large diffs are not rendered by default.

114 changes: 63 additions & 51 deletions src/main/java/frc/robot/subsystems/Angle.java
Original file line number Diff line number Diff line change
@@ -1,51 +1,63 @@
// 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;

public final class Angle {
public static final double TAU = Math.PI * 2;

private double dec = 0.0;

public double radians() {
return dec * TAU;
}

public double degrees() {
return dec * 360.0;
}

public Angle setRadians(double radians) {
dec = radians / TAU;
return this;
}

public Angle setDegrees(double degrees) {
dec = degrees / 360.0;
return this;
}

public Angle add(Angle other) {
var angle = new Angle();
angle.dec = this.dec + other.dec;
return angle;
}

public Angle sub(Angle other) {
var angle = new Angle();
angle.dec = this.dec - other.dec;
return angle;
}

/**
* Creates a new identical angle so that modification of the original will not
* effect the value returned from this function.
*/
public Angle clone() {
var ang = new Angle();
ang.dec = this.dec;
return ang;
}
}
// 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;

public final class Angle implements Cloneable {
public static final double TAU = Math.PI * 2;

private double dec = 0.0;

public double radians() {
return dec * TAU;
}

public double degrees() {
return dec * 360.0;
}

public Angle setRadians(double radians) {
dec = radians / TAU;
return this;
}

public Angle setDegrees(double degrees) {
dec = degrees / 360.0;
return this;
}

public Angle add(Angle other) {
var angle = new Angle();
angle.dec = this.dec + other.dec;
return angle;
}

public Angle sub(Angle other) {
var angle = new Angle();
angle.dec = this.dec - other.dec;
return angle;
}

public Angle mul(double scalar) {
var angle = new Angle();
angle.dec = this.dec * scalar;
return angle;
}

public Angle div(double scalar) {
return this.mul(1 / scalar);
}

@Override
public Angle clone() {
var ang = new Angle();
ang.dec = this.dec;
return ang;
}

@Override
public String toString() {
return this.degrees() + "°";
}
}
Loading
Loading