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

Add blinky code #29

Closed
wants to merge 5 commits into from
Closed
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
33 changes: 31 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,36 @@
# Java-Template
[![CI](https://github.com/Frc5572/FRC2023/actions/workflows/main.yml/badge.svg)](https://github.com/Frc5572/FRC2023/actions/workflows/main.yml) [![Java Docs](https://img.shields.io/badge/docs-20XX-blue)](https://frc5572.github.io/Java-Template/)

[![CI](https://github.com/Frc5572/FRC2023/actions/workflows/main.yml/badge.svg)](https://github.com/Frc5572/FRC2023/actions/workflows/main.yml) [![Java Docs](https://img.shields.io/badge/docs-20XX-blue)](https://frc5572.github.io/Java-Template/)

Template repo for Java template

Good examples can be found https://github.com/wpilibsuite/allwpilib/tree/main/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples
Good examples can be found <https://github.com/wpilibsuite/allwpilib/tree/main/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples>

# Subsystems

## Drive Train

Port 7- motor bl Right VictorSP
Port 6 - motor fl Right VictorSP
Port 5 -motor fr Right VictorSP
Port 4 - motor br Right VictorSP
Drive forward
Drive back
turn left
turn right

## Intake

~Right VictorSP intake motor (ID: 2)~
~Left VictorSP intake motor (ID: 1)~
~Intake~
Outake

## LEDS

PWM Port 9
80 LEDS

Red - Red Alliance
Blue - Blue alliance
Green - intaking
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ dependencies {
nativeRelease wpi.java.vendor.jniRelease(wpi.platforms.desktop)
simulationRelease wpi.sim.enableRelease()

annotationProcessor 'com.github.Frc5572:RobotTools:v1.1.1'
// annotationProcessor 'com.github.Frc5572:RobotTools:v1.1.1'

implementation 'org.apache.httpcomponents:httpclient:4.5.14'
implementation 'org.apache.httpcomponents:httpmime:4.5.14'
Expand Down
1 change: 1 addition & 0 deletions networktables.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[]
98 changes: 98 additions & 0 deletions simgui-ds.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
{
"keyboardJoysticks": [
{
"axisConfig": [
{
"decKey": 65,
"incKey": 68
},
{
"decKey": 87,
"incKey": 83
},
{
"decKey": 69,
"decayRate": 0.0,
"incKey": 82,
"keyRate": 0.009999999776482582
}
],
"axisCount": 3,
"buttonCount": 4,
"buttonKeys": [
90,
88,
67,
86
],
"povConfig": [
{
"key0": 328,
"key135": 323,
"key180": 322,
"key225": 321,
"key270": 324,
"key315": 327,
"key45": 329,
"key90": 326
}
],
"povCount": 1
},
{
"axisConfig": [
{
"decKey": 74,
"incKey": 76
},
{
"decKey": 73,
"incKey": 75
}
],
"axisCount": 2,
"buttonCount": 4,
"buttonKeys": [
77,
44,
46,
47
],
"povCount": 0
},
{
"axisConfig": [
{
"decKey": 263,
"incKey": 262
},
{
"decKey": 265,
"incKey": 264
}
],
"axisCount": 2,
"buttonCount": 6,
"buttonKeys": [
260,
268,
266,
261,
269,
267
],
"povCount": 0
},
{
"axisCount": 0,
"buttonCount": 0,
"povCount": 0
}
],
"robotJoysticks": [
{
"guid": "78696e70757401000000000000000000",
"useGamepad": true
}
]
}
31 changes: 31 additions & 0 deletions simgui.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"HALProvider": {
"Addressable LEDs": {
"0": {
"columns": 4
},
"window": {
"visible": true
}
},
"DIO": {
"window": {
"visible": true
}
},
"Other Devices": {
"window": {
"visible": false
}
}
},
"NTProvider": {
"types": {
"/FMSInfo": "FMSInfo",
"/SmartDashboard/Choose Auto: ": "String Chooser"
}
},
"NetworkTables Info": {
"visible": true
}
}
6 changes: 6 additions & 0 deletions src/main/java/frc/robot/Robot.java
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,16 @@
* diagnostics that you want ran during disabled, autonomous, teleoperated and test.
*
* <p>
*

Check warning on line 105 in src/main/java/frc/robot/Robot.java

View workflow job for this annotation

GitHub Actions / testtool

[testtool] src/main/java/frc/robot/Robot.java#L105 <com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocParagraphCheck>

Empty line should be followed by <p> tag on the next line.
Raw output
/github/workspace/./src/main/java/frc/robot/Robot.java:105:0: warning: Empty line should be followed by <p> tag on the next line. (com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocParagraphCheck)
*

Check warning on line 106 in src/main/java/frc/robot/Robot.java

View workflow job for this annotation

GitHub Actions / testtool

[testtool] src/main/java/frc/robot/Robot.java#L106 <com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocParagraphCheck>

Empty line should be followed by <p> tag on the next line.
Raw output
/github/workspace/./src/main/java/frc/robot/Robot.java:106:0: warning: Empty line should be followed by <p> tag on the next line. (com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocParagraphCheck)
*

Check warning on line 107 in src/main/java/frc/robot/Robot.java

View workflow job for this annotation

GitHub Actions / testtool

[testtool] src/main/java/frc/robot/Robot.java#L107 <com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocParagraphCheck>

Empty line should be followed by <p> tag on the next line.
Raw output
/github/workspace/./src/main/java/frc/robot/Robot.java:107:0: warning: Empty line should be followed by <p> tag on the next line. (com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocParagraphCheck)
*

Check warning on line 108 in src/main/java/frc/robot/Robot.java

View workflow job for this annotation

GitHub Actions / testtool

[testtool] src/main/java/frc/robot/Robot.java#L108 <com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocParagraphCheck>

Empty line should be followed by <p> tag on the next line.
Raw output
/github/workspace/./src/main/java/frc/robot/Robot.java:108:0: warning: Empty line should be followed by <p> tag on the next line. (com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocParagraphCheck)
* This runs after the mode specific periodic functions, but before LiveWindow and
* SmartDashboard integrated updating.
*/



@Override
public void robotPeriodic() {
// Runs the Scheduler. This is responsible for polling buttons, adding newly-scheduled
Expand Down
27 changes: 11 additions & 16 deletions src/main/java/frc/robot/RobotContainer.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,8 @@
import edu.wpi.first.wpilibj2.command.WaitCommand;
import edu.wpi.first.wpilibj2.command.button.CommandXboxController;
import frc.robot.Robot.RobotRunType;
import frc.robot.subsystems.drive.Drivetrain;
import frc.robot.subsystems.drive.DrivetrainIO;
import frc.robot.subsystems.drive.DrivetrainReal;
import frc.robot.subsystems.Intake;
import frc.robot.subsystems.LEDs;

/**
* This class is where the bulk of the robot should be declared. Since Command-based is a
Expand All @@ -22,30 +21,22 @@
public class RobotContainer {
/* Controllers */
private final CommandXboxController driver = new CommandXboxController(Constants.driverID);
private final CommandXboxController operator = new CommandXboxController(Constants.operatorID);

// Initialize AutoChooser Sendable
private final SendableChooser<String> autoChooser = new SendableChooser<>();

/* Subsystems */
private Drivetrain drivetrain;
Intake intake = new Intake();
LEDs leds = new LEDs(9, 60);

/**
* The container for the robot. Contains subsystems, OI devices, and commands.
*/
public RobotContainer(RobotRunType runtimeType) {
SmartDashboard.putData("Choose Auto: ", autoChooser);
autoChooser.setDefaultOption("Wait 1 Second", "wait");
switch (runtimeType) {
case kReal:
drivetrain = new Drivetrain(new DrivetrainReal());
break;
case kSimulation:
// drivetrain = new Drivetrain(new DrivetrainSim() {});
break;
default:
drivetrain = new Drivetrain(new DrivetrainIO() {});
}

leds.setDefaultCommand(leds.setAllianceColor().ignoringDisable(true));
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey this needs to be changed.....

// Configure the button bindings
configureButtonBindings();
}
Expand All @@ -56,7 +47,11 @@ public RobotContainer(RobotRunType runtimeType) {
* ({@link edu.wpi.first.wpilibj.Joystick} or {@link XboxController}), and then passing it to a
* {@link edu.wpi.first.wpilibj2.command.button.JoystickButton}.
*/
private void configureButtonBindings() {}
private void configureButtonBindings() {

driver.a().whileTrue(intake.intakeCommand());

}

/**
* Gets the user's selected autonomous command.
Expand Down
Empty file.
28 changes: 28 additions & 0 deletions src/main/java/frc/robot/commands/IntakeCommand.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package frc.robot.commands;

import edu.wpi.first.wpilibj2.command.Command;
import frc.robot.subsystems.Intake;

public class IntakeCommand extends Command {

Check warning on line 6 in src/main/java/frc/robot/commands/IntakeCommand.java

View workflow job for this annotation

GitHub Actions / testtool

[testtool] src/main/java/frc/robot/commands/IntakeCommand.java#L6 <com.puppycrawl.tools.checkstyle.checks.javadoc.MissingJavadocTypeCheck>

Missing a Javadoc comment.
Raw output
/github/workspace/./src/main/java/frc/robot/commands/IntakeCommand.java:6:1: warning: Missing a Javadoc comment. (com.puppycrawl.tools.checkstyle.checks.javadoc.MissingJavadocTypeCheck)

Intake intake;

public IntakeCommand(Intake intake) {
this.intake = intake;
}

@Override
public void execute() {
intake.intake();
}

@Override
public void end(boolean interrupted) {
intake.stop();
}

@Override
public boolean isFinished() {
return false; // intake.beambrake.get();
}
}
Empty file.
41 changes: 41 additions & 0 deletions src/main/java/frc/robot/subsystems/Intake.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package frc.robot.subsystems;

import edu.wpi.first.wpilibj.DigitalInput;
import edu.wpi.first.wpilibj.motorcontrol.VictorSP;
import edu.wpi.first.wpilibj2.command.Command;
import edu.wpi.first.wpilibj2.command.Commands;
import edu.wpi.first.wpilibj2.command.SubsystemBase;

public class Intake extends SubsystemBase {

Check warning on line 9 in src/main/java/frc/robot/subsystems/Intake.java

View workflow job for this annotation

GitHub Actions / testtool

[testtool] src/main/java/frc/robot/subsystems/Intake.java#L9 <com.puppycrawl.tools.checkstyle.checks.javadoc.MissingJavadocTypeCheck>

Missing a Javadoc comment.
Raw output
/github/workspace/./src/main/java/frc/robot/subsystems/Intake.java:9:1: warning: Missing a Javadoc comment. (com.puppycrawl.tools.checkstyle.checks.javadoc.MissingJavadocTypeCheck)

VictorSP intakeMotor1 = new VictorSP(1);
VictorSP intakeMotor2 = new VictorSP(2);

public DigitalInput touchSensor = new DigitalInput(1);

public Intake() {
intakeMotor2.setInverted(true);
intakeMotor1.addFollower(intakeMotor2);
}

public void setPower(double power) {
intakeMotor1.set(power);
}

public void intake() {
setPower(-0.7);
}

public void outtake() {
setPower(0.7);
}

public void stop() {
setPower(0);
}

public Command intakeCommand() {
return Commands.runEnd(this::intake, this::stop, this); // .until(() -> beambrake.get());
}

}
45 changes: 45 additions & 0 deletions src/main/java/frc/robot/subsystems/LEDs.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package frc.robot.subsystems;

import edu.wpi.first.wpilibj.AddressableLED;
import edu.wpi.first.wpilibj.AddressableLEDBuffer;
import edu.wpi.first.wpilibj.DriverStation;
import edu.wpi.first.wpilibj.DriverStation.Alliance;
import edu.wpi.first.wpilibj.util.Color;
import edu.wpi.first.wpilibj2.command.Command;
import edu.wpi.first.wpilibj2.command.Commands;
import edu.wpi.first.wpilibj2.command.SubsystemBase;

public class LEDs extends SubsystemBase {

Check warning on line 12 in src/main/java/frc/robot/subsystems/LEDs.java

View workflow job for this annotation

GitHub Actions / testtool

[testtool] src/main/java/frc/robot/subsystems/LEDs.java#L12 <com.puppycrawl.tools.checkstyle.checks.javadoc.MissingJavadocTypeCheck>

Missing a Javadoc comment.
Raw output
/github/workspace/./src/main/java/frc/robot/subsystems/LEDs.java:12:1: warning: Missing a Javadoc comment. (com.puppycrawl.tools.checkstyle.checks.javadoc.MissingJavadocTypeCheck)

AddressableLED leds;
AddressableLEDBuffer buffer;

public LEDs(int portNum, int length) {

Check warning on line 17 in src/main/java/frc/robot/subsystems/LEDs.java

View workflow job for this annotation

GitHub Actions / testtool

[testtool] src/main/java/frc/robot/subsystems/LEDs.java#L17 <com.puppycrawl.tools.checkstyle.checks.javadoc.MissingJavadocMethodCheck>

Missing a Javadoc comment.
Raw output
/github/workspace/./src/main/java/frc/robot/subsystems/LEDs.java:17:5: warning: Missing a Javadoc comment. (com.puppycrawl.tools.checkstyle.checks.javadoc.MissingJavadocMethodCheck)
this.leds = new AddressableLED(portNum);
this.buffer = new AddressableLEDBuffer(length);
leds.setLength(buffer.getLength());
leds.setData(buffer);
leds.start();
}

public void setColor(Color color) {

Check warning on line 25 in src/main/java/frc/robot/subsystems/LEDs.java

View workflow job for this annotation

GitHub Actions / testtool

[testtool] src/main/java/frc/robot/subsystems/LEDs.java#L25 <com.puppycrawl.tools.checkstyle.checks.javadoc.MissingJavadocMethodCheck>

Missing a Javadoc comment.
Raw output
/github/workspace/./src/main/java/frc/robot/subsystems/LEDs.java:25:5: warning: Missing a Javadoc comment. (com.puppycrawl.tools.checkstyle.checks.javadoc.MissingJavadocMethodCheck)
for (var i = 0; i < buffer.getLength(); i++) {
buffer.setLED(i, color);
}
leds.setData(buffer);
}

public Command setAllianceColor() {

Check warning on line 32 in src/main/java/frc/robot/subsystems/LEDs.java

View workflow job for this annotation

GitHub Actions / testtool

[testtool] src/main/java/frc/robot/subsystems/LEDs.java#L32 <com.puppycrawl.tools.checkstyle.checks.javadoc.MissingJavadocMethodCheck>

Missing a Javadoc comment.
Raw output
/github/workspace/./src/main/java/frc/robot/subsystems/LEDs.java:32:5: warning: Missing a Javadoc comment. (com.puppycrawl.tools.checkstyle.checks.javadoc.MissingJavadocMethodCheck)
return Commands.run(() -> {
Color color = Color.kYellow;
if (DriverStation.getAlliance().isPresent()) {
if (DriverStation.getAlliance().get() == Alliance.Red) {
color = Color.kRed;
} else {
color = Color.kBlue;
}
}
setColor(color);
}, this);
}
}
Loading
Loading