Skip to content
This repository has been archived by the owner on Nov 20, 2023. It is now read-only.

Implemented builder pattern and updated the readme a bit #1

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
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
17 changes: 15 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,17 @@
Java
# Polybot Code
---

This example involves building and deploying Java sources. This should be all you need to get started, however there are plenty of resources online for building more advanced java projects should you require.
This example involves building and deploying Java sources. This should be all you need to get started, however there are plenty of resources online for building more advanced java projects should you require.


## Roadmap

* Begin some basic housekeeping :white_check_mark:
* Create helper methods for common tasks (This one is important to get done before the season starts) :no_entry:
* Improve dead reckoning movement (This has been redone every year for the past 4 years. Why stop now) :no_entry:
* Define .robot standard :no_entry:
* Implement .robot decoder :no_entry:



If you need something to do, documenting and commenting is always helpful.
6 changes: 4 additions & 2 deletions src/main/java/frc/team5468/robot/Robot.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@

public class Robot extends TimedRobot {

private RobotMap robot = new RobotMap();
private RobotMap robot = new RobotMap.Builder()
.isMain(false)
.build();

private Teleop_DefaultDrive Teleop;

Expand Down Expand Up @@ -45,7 +47,7 @@ public void testInit() {
public void disabledPeriodic() {

}

@Override
public void autonomousPeriodic() {

Expand Down
38 changes: 36 additions & 2 deletions src/main/java/frc/team5468/robot/RobotMap.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

public class RobotMap {

public boolean isMain = false;
public boolean isMain;

public static int rightFrontDrive, rightBackDrive, leftFrontDrive, leftBackDrive, hallEffectMotor;
public static int hFXSensor;
Expand All @@ -20,7 +20,41 @@ public class RobotMap {

public static DigitalInput hallEffect;

public RobotMap(){
/*
Builder pattern allows for simplified configuration of objects.

Replace
RobotMap map = new RobotMap(value1, value2, value3);

With
RobotMap map = new RobotMap.Builder()
.setValue1(whatever)
.setValue2(whatever)
.setValue3(whatever)
.build();

Hopefully it should be self evident how this will make configuration easier once configuration options start to pile up
If you still don't believe me refer to: https://dzone.com/articles/design-patterns-the-builder-pattern
*/

static class Builder {
boolean isMain = false;

public Builder(){}

Builder isMain(boolean isMain) {
this.isMain = isMain;
return this;
}

RobotMap build() {
return new RobotMap(isMain);
}

}

public RobotMap(boolean isMain){
this.isMain = isMain;
if(isMain){
rightFrontDrive = 0;
rightBackDrive = 0;
Expand Down
19 changes: 19 additions & 0 deletions src/main/java/frc/team5468/robot/Robots/polybot2019.robot
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// Consider this a teaser for now

version = 1.0

TalonSRX LeftFrontDrive = 22
TalonSRX RightFrontDrive = 21

VictorSPX LeftBackDrive = 32
VictorSPX RightBackDrive = 31

VictorSPX hallFXMotor = 33

ADXRS450 gyro

DigitalInput hall = 0

LeftBackDrive FOLLOWS LeftFrontDrive
RightBackDrive FOLLOWS LeftFrontDrive