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 2 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
24 changes: 2 additions & 22 deletions src/com/nutrons/nu17/RobotMap.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,40 +2,22 @@

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
public static final int FRONT_LEFT = 0;
public static final int FRONT_RIGHT = 1;
public static final int BACK_LEFT = 2;
public static final int BACK_RIGHT = 3;

// Ports of intake
public static final int ROLLER_A = 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 ones are A and B? Top/Bottom? Left/Right? Specify. If you don't know, put that in a TODO comment

public static final int ROLLER_B = 0;

// Ports of fly wheels
public static final int FLY_WHEEL_R = 0;
public static final int FLY_WHEEL_L = 0;

// Ports of Ultrasonics
public static final int ULTRASONIC_RX = 0;
public static final int ULTRASONIC_TX = 1;

// Port of gyro
public static final int GYRO = 0;
Copy link
Contributor

Choose a reason for hiding this comment

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

We know the RobotMap class is full of port numbers, eliminate that from the comments throughout the class


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

// Port of shooter
public static final int GEAR_PLACER = 0;
public static final int GEAR_PLACER_SERVO = 0;
public static final int SHOOTER = 0;

// Port of climber
public static final int CLIMBER = 0;

// Port of micro switch
public static final int MICRO_SWITCH = 0;

// Ports of encoders
public static final int DT_ENCODER_1 = 1;
Copy link
Contributor

Choose a reason for hiding this comment

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

A number tells us nothing. Where are these on the robot?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We'll be using CANTalons so we won't need these anymore.

public static final int DT_ENCODER_2 = 2;
public static final int DT_ENCODER_3 = 3;
Expand All @@ -50,8 +32,6 @@ public class RobotMap {
public static final int TWIN_ENCODER_4 = 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

public static final int JOYSTICK2 = 1;

Expand Down
7 changes: 5 additions & 2 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;

/**
*
* Lowers the gear placer to safely drive.
*/
public class LowerGearPlacerCmd extends Command {

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"


/**
*
* Lifts the gear placer to interact with a gear.
*/
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

/**
* Raises the gear placer to the highest position.
*/
protected boolean isFinished() {
return Robot.GP.getPosition() == this.PLACER_MAX_POSITION;
}
Expand Down
5 changes: 4 additions & 1 deletion src/com/nutrons/nu17/subsystems/GearPlacer.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,12 @@
import edu.wpi.first.wpilibj.Talon;
import edu.wpi.first.wpilibj.command.Subsystem;

/**
* Class of a single arm that will interact with the gears.
*/
public class GearPlacer extends Subsystem {

private final Talon PLACER = new Talon(RobotMap.PLACER);
private final Talon PLACER = new Talon(RobotMap.GEAR_PLACER);

public void initDefaultCommand() {
//empty
Expand Down
41 changes: 41 additions & 0 deletions src/com/nutrons/nu17/subsystems/GearPlacerServo.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package com.nutrons.nu17.subsystems;

import com.nutrons.nu17.RobotMap;

import edu.wpi.first.wpilibj.Servo;
import edu.wpi.first.wpilibj.command.Subsystem;

/**
* Similar to {@link GearPlacer} class but uses a servo instead.
Copy link
Contributor

Choose a reason for hiding this comment

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

Perhaps this should extend the GearPlacer class or alternately you should have an interface that abstracts over both.

*/
public class GearPlacerServo extends Subsystem {

private final Servo PLACER = new Servo(RobotMap.GEAR_PLACER_SERVO);

public void initDefaultCommand() {
//empty
}

/**
* Sets the gear placer to a position.
*
* @param position Where the gear placer will be set to.
*/
public void setPosition(double position) {
PLACER.set(position);
}

/**
* Returns the current position of the gear placer.
*
* @return Gives us where the gear placer is at this moment.
*/
public double getPosition() {
return PLACER.get();
}

public void stop() {
this.setPosition(this.getPosition());
}
}