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

Added GearPlacerServo subsystem and added some Javadocs. #4

Open
wants to merge 7 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
44 changes: 44 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

435 changes: 435 additions & 0 deletions .idea/workspace.xml

Large diffs are not rendered by default.

69 changes: 69 additions & 0 deletions NU17.iml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="EclipseModuleManager">
<varelement var="file://$wpilib$" value="wpilib" />
<varelement var="file://$wpilib.sources$" kind="src:" value="wpilib.sources" />
<varelement var="file://$networktables$" value="networktables" />
<varelement var="file://$networktables.sources$" kind="src:" value="networktables.sources" />
<varelement var="file://$opencv$" value="opencv" />
<varelement var="file://$opencv.sources$" kind="src:" value="opencv.sources" />
<varelement var="file://$cscore$" value="cscore" />
<varelement var="file://$cscore.sources$" kind="src:" value="cscore.sources" />
<src_description expected_position="0">
<src_folder value="file://$MODULE_DIR$/src" expected_position="0" />
</src_description>
</component>
<component name="NewModuleRootManager" inherit-compiler-output="false">
<output url="file://$MODULE_DIR$/bin" />
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
</content>
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="module-library">
<library name="wpilib">
<CLASSES>
<root url="file://$wpilib$" />
</CLASSES>
<JAVADOC />
<SOURCES>
<root url="file://$wpilib.sources$" />
</SOURCES>
</library>
</orderEntry>
<orderEntry type="module-library">
<library name="networktables">
<CLASSES>
<root url="file://$networktables$" />
</CLASSES>
<JAVADOC />
<SOURCES>
<root url="file://$networktables.sources$" />
</SOURCES>
</library>
</orderEntry>
<orderEntry type="module-library">
<library name="opencv">
<CLASSES>
<root url="file://$opencv$" />
</CLASSES>
<JAVADOC />
<SOURCES>
<root url="file://$opencv.sources$" />
</SOURCES>
</library>
</orderEntry>
<orderEntry type="module-library">
<library name="cscore">
<CLASSES>
<root url="file://$cscore$" />
</CLASSES>
<JAVADOC />
<SOURCES>
<root url="file://$cscore.sources$" />
</SOURCES>
</library>
</orderEntry>
<orderEntry type="inheritedJdk" />
</component>
</module>
4 changes: 2 additions & 2 deletions src/com/nutrons/nu17/OI.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ public class OI {
private final Button LOWER_PLACER = new JoystickButton(
this.OPERATOR_PAD,
RobotMap.JOYSTICK_X);

public static final Joystick DRIVER_PAD = new Joystick(RobotMap.JOYSTICK1);
public static final Joystick OPERATOR_PAD = new Joystick(RobotMap.JOYSTICK2);

public OI() {
this.RAISE_PLACER.whenPressed(new RaiseGearPlacerCmd());
this.LOWER_PLACER.whenPressed(new LowerGearPlacerCmd());
Expand Down
5 changes: 3 additions & 2 deletions src/com/nutrons/nu17/RobotMap.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@

public class RobotMap {

Copy link
Contributor

Choose a reason for hiding this comment

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

The bit that said they were wheels was helpful. Add a comment:
// Wheel motors

// Ports of wheels
// Wheel motors
public static final int FRONT_LEFT = 0;
public static final int BACK_LEFT = 1;
public static final int FRONT_RIGHT = 2;
public static final int BACK_RIGHT = 3;

// Paramter naming convention : Subsystem SIDE_PLACEMENT
// Ports of intake
public static final int ROLLER_FRONT = 0;
Expand All @@ -24,6 +25,7 @@ public class RobotMap {
public static final int DRIVETRAIN_HEADING_GYRO = 0;

// Port of gear placer
public static final int GEAR_PLACER = 0;
public static final int GEAR_PLACER_SERVO = 0;

// Port of shooter
Expand All @@ -50,7 +52,6 @@ public class RobotMap {
public static final int TWIN_RIGHT_ENCODER_2 = 12;
public static final int SHOOT_ENCODER_1 = 0;
public static final int SHOOT_ENCODER_2 = 1;


// Port of joysticks
public static final int JOYSTICK1 = 0;
Copy link
Contributor

Choose a reason for hiding this comment

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

which joysticks? The number does not tell me anything

Expand Down
39 changes: 39 additions & 0 deletions src/com/nutrons/nu17/commands/DrivePIDCmd.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package com.nutrons.nu17.commands;

import com.nutrons.nu17.Robot;
import edu.wpi.first.wpilibj.command.Command;

public class DrivePIDCmd extends Command {

private double target;

public DrivePIDCmd(double target) {
requires(Robot.DRIVETRAIN);
this.target = target;
}

/**
* Sets a target to drive to. Sets how far the robot can be displaced from the target.
*/
protected void initialize() {
Robot.DRIVETRAIN.DISTANCE_PID.setSetpoint(this.target);
Robot.DRIVETRAIN.DISTANCE_PID.setAbsoluteTolerance(0.2);
Robot.DRIVETRAIN.DISTANCE_PID.enable();
}

protected void execute() {
//empty
}
// Finishes when targeted destination is reached
protected boolean isFinished() {
return Math.abs(Robot.DRIVETRAIN.DISTANCE_PID.getError()) < 0.2;
}

protected void end() {
Robot.DRIVETRAIN.DISTANCE_PID.disable();
}

protected void interrupted() {
end();
}
}
9 changes: 6 additions & 3 deletions src/com/nutrons/nu17/commands/LowerGearPlacerCmd.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import edu.wpi.first.wpilibj.command.Command;

/**
*
* Lower the gear placer.
*/
public class LowerGearPlacerCmd extends Command {

Expand All @@ -14,7 +14,7 @@ public LowerGearPlacerCmd() {
}

/**
* Lowers the gear placer.
* Lower the gear placer.
*/
protected void initialize() {
Robot.GP.set(0);
Expand All @@ -23,7 +23,10 @@ protected void initialize() {
protected void execute() {
//empty
}
// Finished when the placer is at the lowest position

/**
* Finished once the gear placer is at the lowest position.
*/
protected boolean isFinished() {
return Robot.GP.getPosition() == 0;
}
Expand Down
9 changes: 6 additions & 3 deletions src/com/nutrons/nu17/commands/RaiseGearPlacerCmd.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import edu.wpi.first.wpilibj.command.Command;
Copy link
Contributor

Choose a reason for hiding this comment

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

These descriptions are for commands. Write them like commands i.e. "Raise the gear placer" instead of "Raises the gear placer"


/**
*
* Raise the gear placer.
*/
public class RaiseGearPlacerCmd extends Command {

Expand All @@ -16,7 +16,7 @@ public RaiseGearPlacerCmd() {
}

/**
* Lowers the gear placer.
* Raises the gear placer.
*/
protected void initialize() {
Robot.GP.set(this.PLACER_MAX_POSITION);
Expand All @@ -25,7 +25,10 @@ protected void initialize() {
protected void execute() {
//empty
}
// Finishes when the placer is at the highest position

/**
* Raise the gear placer to the highest position.
*/
protected boolean isFinished() {
return Robot.GP.getPosition() == this.PLACER_MAX_POSITION;
}
Expand Down
2 changes: 0 additions & 2 deletions src/com/nutrons/nu17/subsystems/Drivetrain.java
Original file line number Diff line number Diff line change
Expand Up @@ -94,15 +94,13 @@ public double getEncoderRate() {
*/
public void resetEncoder() {
this.DRIVE_DISTANCE_ENCODER.reset();

}

/**
* Resets the gyro.
*/
public void resetGyro() {
this.HEADING_GRYO.reset();

}

public void initDefaultCommand() {
Expand Down
Loading