-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Arizona North Day 3: Teleop and switch autonomous are fully functional
Following our elimination from competitive play at the regional, software was allowed some much needed one on one time with the competition bot on a practice field. All of the Telop bugs have been ironed out per our testing, and our switch autonomous is fully functional. GnarlyController and MotionProfileCommand have been debugged and tuned to very precisely follow a trajectory and scale autonomous is almost ready for testing.
- Loading branch information
1 parent
bd6faf2
commit 639a4c3
Showing
11 changed files
with
440 additions
and
353 deletions.
There are no files selected for viewing
106 changes: 53 additions & 53 deletions
106
src/com/team3925/utils/SendablePIDTuner.java → SendablePIDTuner.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,54 +1,54 @@ | ||
package com.team3925.utils; | ||
|
||
import edu.wpi.first.wpilibj.Sendable; | ||
import edu.wpi.first.wpilibj.command.Subsystem; | ||
import edu.wpi.first.wpilibj.smartdashboard.SendableBuilder; | ||
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard; | ||
|
||
public class SendablePIDTuner implements Sendable { | ||
|
||
String name = "PIDTuner"; | ||
String subsystem; | ||
PIDTunable pid_values; | ||
|
||
public SendablePIDTuner(Subsystem subsystem, PIDTunable pid_values) { | ||
this.subsystem = subsystem.getName() + "Tuner"; | ||
this.pid_values = pid_values; | ||
} | ||
|
||
@Override | ||
public String getName() { | ||
return name; | ||
} | ||
|
||
@Override | ||
public void setName(String name) { | ||
this.name = name; | ||
|
||
} | ||
|
||
@Override | ||
public String getSubsystem() { | ||
return subsystem; | ||
} | ||
|
||
@Override | ||
public void setSubsystem(String subsystem) { | ||
this.subsystem = subsystem; | ||
} | ||
|
||
@Override | ||
public void initSendable(SendableBuilder builder) { | ||
builder.setSmartDashboardType("PIDController"); | ||
builder.addDoubleProperty("p", pid_values::getkP, pid_values::setkP); | ||
builder.addDoubleProperty("i", pid_values::getkI, pid_values::setkI); | ||
builder.addDoubleProperty("d", pid_values::getkD, pid_values::setkD); | ||
builder.addDoubleProperty("f", pid_values::getkF, pid_values::setkF); | ||
} | ||
|
||
public void updateDashboard() { | ||
// TODO: should this be name or subsystem? The subsystem will allow us to | ||
// differentiate it. | ||
SmartDashboard.putData(subsystem, this); | ||
} | ||
package com.team3925.utils; | ||
|
||
import edu.wpi.first.wpilibj.Sendable; | ||
import edu.wpi.first.wpilibj.command.Subsystem; | ||
import edu.wpi.first.wpilibj.smartdashboard.SendableBuilder; | ||
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard; | ||
|
||
public class SendablePIDTuner implements Sendable { | ||
|
||
String name = "PIDTuner"; | ||
String subsystem; | ||
PIDTunable pid_values; | ||
|
||
public SendablePIDTuner(Subsystem subsystem, PIDTunable pid_values) { | ||
this.subsystem = subsystem.getName() + "Tuner"; | ||
this.pid_values = pid_values; | ||
} | ||
|
||
@Override | ||
public String getName() { | ||
return name; | ||
} | ||
|
||
@Override | ||
public void setName(String name) { | ||
this.name = name; | ||
|
||
} | ||
|
||
@Override | ||
public String getSubsystem() { | ||
return subsystem; | ||
} | ||
|
||
@Override | ||
public void setSubsystem(String subsystem) { | ||
this.subsystem = subsystem; | ||
} | ||
|
||
@Override | ||
public void initSendable(SendableBuilder builder) { | ||
builder.setSmartDashboardType("PIDController"); | ||
builder.addDoubleProperty("p", pid_values::getkP, pid_values::setkP); | ||
builder.addDoubleProperty("i", pid_values::getkI, pid_values::setkI); | ||
builder.addDoubleProperty("d", pid_values::getkD, pid_values::setkD); | ||
builder.addDoubleProperty("f", pid_values::getkF, pid_values::setkF); | ||
} | ||
|
||
public void updateDashboard() { | ||
// TODO: should this be name or subsystem? The subsystem will allow us to | ||
// differentiate it. | ||
SmartDashboard.putData(subsystem, this); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,19 @@ | ||
package com.team3925.frc2018; | ||
|
||
import com.team3925.frc2018.subsystems.Drivetrain; | ||
import com.team3925.utils.SendablePIDTuner; | ||
|
||
public class Logger { | ||
SendablePIDTuner drivetrainTuner; | ||
|
||
private static Logger instance; | ||
public static Logger getInstance() { | ||
if (instance == null) | ||
instance = new Logger(); | ||
return instance; | ||
} | ||
|
||
private Logger() { | ||
drivetrainTuner = new SendablePIDTuner(Drivetrain.getInstance(), Drivetrain.getInstance()); | ||
} | ||
public void update() { | ||
drivetrainTuner.updateDashboard(); | ||
} | ||
} | ||
package com.team3925.frc2018; | ||
|
||
public class Logger { | ||
// SendablePIDTuner drivetrainTuner; | ||
|
||
private static Logger instance; | ||
public static Logger getInstance() { | ||
if (instance == null) | ||
instance = new Logger(); | ||
return instance; | ||
} | ||
|
||
private Logger() { | ||
// drivetrainTuner = new SendablePIDTuner(Drivetrain.getInstance(), Drivetrain.getInstance()); | ||
} | ||
public void update() { | ||
// drivetrainTuner.updateDashboard(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,75 +1,75 @@ | ||
package com.team3925.frc2018.commands; | ||
|
||
import javax.print.attribute.standard.PrinterResolution; | ||
|
||
import com.team3925.frc2018.subsystems.Drivetrain; | ||
import com.team3925.frc2018.subsystems.Elevator; | ||
|
||
import edu.wpi.first.wpilibj.command.Command; | ||
|
||
public class DriveManual extends Command { | ||
|
||
public interface DriveManualInput { | ||
public abstract double getFwd(); | ||
|
||
public abstract double getLeft(); | ||
} | ||
|
||
private final boolean doReverseWhenReversing; | ||
|
||
private DriveManualInput input; | ||
private double prelimLeft, prelimRight; | ||
private double fwd, turn; | ||
private double scale; | ||
private static final double K_HEIGHT_SUBTRACTION = 0.9; | ||
|
||
public DriveManual(DriveManualInput input) { | ||
this.input = input; | ||
doReverseWhenReversing = false; | ||
requires(Drivetrain.getInstance()); | ||
} | ||
|
||
@Override | ||
protected void initialize() { | ||
Drivetrain.getInstance().setRaw(0, 0); | ||
} | ||
|
||
@Override | ||
protected void execute() { | ||
fwd = input.getFwd(); | ||
turn = input.getLeft(); | ||
if (Math.abs(fwd) < 0.1) | ||
fwd = 0; | ||
if (doReverseWhenReversing && fwd != 0) | ||
turn *= Math.signum(fwd); | ||
prelimLeft = fwd + turn; | ||
prelimRight = fwd - turn; | ||
if (prelimLeft != 0 || prelimRight != 0) { | ||
scale = Math.max(Math.abs(fwd), Math.abs(turn)) / Math.max(Math.abs(prelimLeft), Math.abs(prelimRight)); | ||
prelimLeft *= scale; | ||
prelimRight *= scale; | ||
} | ||
|
||
Drivetrain.getInstance().setRaw( | ||
prelimLeft * (1 - (Elevator.getInstance().getElevatorHeightPercentage() * K_HEIGHT_SUBTRACTION)), | ||
prelimRight * (1 - (Elevator.getInstance().getElevatorHeightPercentage() * K_HEIGHT_SUBTRACTION)) | ||
); | ||
} | ||
|
||
|
||
@Override | ||
protected boolean isFinished() { | ||
return false; | ||
} | ||
|
||
@Override | ||
protected void end() { | ||
Drivetrain.getInstance().setRaw(0, 0); | ||
} | ||
|
||
@Override | ||
protected void interrupted() { | ||
Drivetrain.getInstance().setRaw(0, 0); | ||
} | ||
|
||
} | ||
package com.team3925.frc2018.commands; | ||
|
||
import javax.print.attribute.standard.PrinterResolution; | ||
|
||
import com.team3925.frc2018.subsystems.Drivetrain; | ||
import com.team3925.frc2018.subsystems.Elevator; | ||
|
||
import edu.wpi.first.wpilibj.command.Command; | ||
|
||
public class DriveManual extends Command { | ||
|
||
public interface DriveManualInput { | ||
public abstract double getFwd(); | ||
|
||
public abstract double getLeft(); | ||
} | ||
|
||
private final boolean doReverseWhenReversing; | ||
|
||
private DriveManualInput input; | ||
private double prelimLeft, prelimRight; | ||
private double fwd, turn; | ||
private double scale; | ||
private static final double K_HEIGHT_SUBTRACTION = 0.8; | ||
|
||
public DriveManual(DriveManualInput input) { | ||
this.input = input; | ||
doReverseWhenReversing = false; | ||
requires(Drivetrain.getInstance()); | ||
} | ||
|
||
@Override | ||
protected void initialize() { | ||
Drivetrain.getInstance().setRaw(0, 0); | ||
} | ||
|
||
@Override | ||
protected void execute() { | ||
fwd = input.getFwd(); | ||
turn = input.getLeft(); | ||
if (Math.abs(fwd) < 0.1) | ||
fwd = 0; | ||
if (doReverseWhenReversing && fwd != 0) | ||
turn *= Math.signum(fwd); | ||
prelimLeft = fwd + turn; | ||
prelimRight = fwd - turn; | ||
if (prelimLeft != 0 || prelimRight != 0) { | ||
scale = Math.max(Math.abs(fwd), Math.abs(turn)) / Math.max(Math.abs(prelimLeft), Math.abs(prelimRight)); | ||
prelimLeft *= scale; | ||
prelimRight *= scale; | ||
} | ||
|
||
Drivetrain.getInstance().setRaw( | ||
prelimLeft * (1 - (Elevator.getInstance().getElevatorHeightPercentage() * K_HEIGHT_SUBTRACTION)), | ||
prelimRight * (1 - (Elevator.getInstance().getElevatorHeightPercentage() * K_HEIGHT_SUBTRACTION)) | ||
); | ||
} | ||
|
||
|
||
@Override | ||
protected boolean isFinished() { | ||
return false; | ||
} | ||
|
||
@Override | ||
protected void end() { | ||
Drivetrain.getInstance().setRaw(0, 0); | ||
} | ||
|
||
@Override | ||
protected void interrupted() { | ||
Drivetrain.getInstance().setRaw(0, 0); | ||
} | ||
|
||
} |
Oops, something went wrong.