-
Notifications
You must be signed in to change notification settings - Fork 0
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
Intake #1
base: master
Are you sure you want to change the base?
Intake #1
Conversation
@@ -16,4 +16,7 @@ | |||
* constants are needed, to reduce verbosity. | |||
*/ | |||
public final class Constants { | |||
public static final class Intake { | |||
public static final double power = 0.8; // [%] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CAPITALIZE
public static final double power = 0.8; // [%] | |
public static final double POWER = 0.8; // [%] |
public XboxController Xbox = new XboxController(1); | ||
public JoystickButton a = new JoystickButton(Xbox, XboxController.Button.kA.value); | ||
public JoystickButton b = new JoystickButton(Xbox, XboxController.Button.kB.value); | ||
private Intake intake; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
private Intake intake; | |
private final Intake intake = new Intake(); |
/** | ||
* Add&named motors in Intake. | ||
*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add proper documentation!!! (everywhere)
/** | ||
* Add motor inverted. | ||
*/ | ||
public void TalonSRXSelenoid() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
public void TalonSRXSelenoid() { | |
public Intake() { |
|
||
/** | ||
* Set power for motor. | ||
* @param power the speed times the torque. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wrong units, it's just percentage
|
||
/** | ||
* A check to see if piston is open or close. | ||
* @return |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should write what true mean (does it mean open or closed?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A shorter solution will be renaming the function isPistonOpen
or something similar.
@@ -0,0 +1,14 @@ | |||
package frc.robot.subsystems.intake; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ports should be in frc.robot
package!!!!!!!!!!!!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤢🤮
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- No need to shout 🙂
- IMO ports and constants should be stored in every subsystem's packages except global stuff like we did in 2019. When they are all in the same file you have a lot of merge conflicts.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great job, there is really very little left to improve in this code. :)
* Set power for motor. | ||
* @param power the speed times the torque. | ||
*/ | ||
public void setMotorPower(double power) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rename to setPower
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I disagree, it might not be the proper naming, maybe powerWheels(...)
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure it's just repetitive to call the method setMotorPower
* Add motor inverted. | ||
*/ | ||
public void TalonSRXSelenoid() { | ||
this.motor.setInverted(Ports.Intake.IS_MOTOR_INVERTED); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"this" isn't necessary here
/** | ||
* Add Commandy function; | ||
*/ | ||
public class Commandy extends CommandBase { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a command that only opens and closes the intake
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed, and add another command that powers the wheels. Then, if needed, combine both commands in a command group.
Also, change the command's name because "commandy" is very not indicative.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great job! 😁
@@ -0,0 +1,14 @@ | |||
package frc.robot.subsystems.intake; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- No need to shout 🙂
- IMO ports and constants should be stored in every subsystem's packages except global stuff like we did in 2019. When they are all in the same file you have a lot of merge conflicts.
/** | ||
* Add Commandy function; | ||
*/ | ||
public class Commandy extends CommandBase { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed, and add another command that powers the wheels. Then, if needed, combine both commands in a command group.
Also, change the command's name because "commandy" is very not indicative.
|
||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need for all those blank lines.
if (isPistonEngaged()) { | ||
setPistonMode(false); | ||
} else { | ||
setPistonMode(true); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can shorten this code:
if (isPistonEngaged()) { | |
setPistonMode(false); | |
} else { | |
setPistonMode(true); | |
} | |
setPistonMode(!isPistonEngaged()); |
|
||
/** | ||
* A check to see if piston is open or close. | ||
* @return |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A shorter solution will be renaming the function isPistonOpen
or something similar.
*/ | ||
public class Intake extends SubsystemBase { | ||
private TalonSRX motor = new TalonSRX(Ports.Intake.MOTOR); | ||
private Solenoid piston = new Solenoid(Ports.Intake.SOLENOID); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Better to call it "retractor" or something similar, to explain what the piston's purpose is. Make sure you change the name everywhere, for example, change every function name that has "piston" inside it.
Also, "piston" is a hardware component, making it an implementation detail. Thus, users of the subsystem (i.e. commands) do not care about it, they care only about what the subsystem does, not about how it does that. Therefore, "piston" shouldn't be exposed outside of this class. This is also why you declared it private
.
Please let me know if the explanation wasn't clear.
*/ | ||
public class Intake extends SubsystemBase { | ||
private TalonSRX motor = new TalonSRX(Ports.Intake.MOTOR); | ||
private Solenoid piston = new Solenoid(Ports.Intake.SOLENOID); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Better to call this "retractor" or something similar, so that it's clear what is the piston's purpose.
* A check to see if piston is open or close, true= open, false= close. | ||
* @return | ||
*/ | ||
public boolean isPistonEngaged() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As written above, it's better to name this function isRetracted
or something similar. That way, the function's purpose is clear. Make sure you do the renaming everywhere else appropriate in this class.
Also, the piston is a hardware component, which means it is an implementation detail. Thus, it shouldn't be exposed to external users of the class, such as commands. Users of the class care about what it does, not how it does it.
Please reach out if the explanation above is not clear 🙂
src/main/java/frc/robot/Intake.java
Outdated
|
||
} | ||
|
||
} | ||
|
||
|
||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
} | |
} | |
} | |
} | |
No need for all these blank lines 🙂
|
||
@Override | ||
public void initialize() { | ||
super.initialize(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need for this call to super
's methods and also the ones in the methods following. As you can see in WPILib's source code, these methods are empty in the parent class, so these calls do nothing (source code taken from here):
public interface Command {
/** The initial subroutine of a command. Called once when the command is initially scheduled. */
default void initialize() {}
/** The main body of a command. Called repeatedly while the command is scheduled. */
default void execute() {}
/**
* The action to take when the command ends. Called when either the command finishes normally, or
* when it interrupted/canceled.
*
* <p>Do not schedule commands here that share requirements with this command. Use {@link
* #andThen(Command...)} instead.
*
* @param interrupted whether the command was interrupted/canceled
*/
default void end(boolean interrupted) {}
/**
* Whether the command has finished. Once a command finishes, the scheduler will call its end()
* method and un-schedule it.
*
* @return whether the command has finished.
*/
default boolean isFinished() {
return false;
}
Just a small comment – every commit should document a single change. so 42689a0 should have been split into four different commits. |
|
||
/** | ||
* Set percentage for motor. | ||
* @param power the speed times the torque. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The units are simply %
public XboxController Xbox = new XboxController(1); | ||
public JoystickButton a = new JoystickButton(Xbox, XboxController.Button.kA.value); | ||
public JoystickButton b = new JoystickButton(Xbox, XboxController.Button.kB.value); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(Also, make them private
)
|
||
private Intake intake; | ||
|
||
public ToggleIntake(Intake intake) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The should also move to specific state, not only toggle.
No description provided.