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

setTargetVelocity to setTargetPercent #72

Merged
merged 4 commits into from
Jan 27, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 1 addition & 1 deletion src/main/java/frc/robot/subsystems/Shooter.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public Command shoot(Pose2d position, boolean shootingAtSpeaker) {
SpeedAnglePair pair = calculateSpeed(position, shootingAtSpeaker);
return runOnce(() -> motorLeft.setTargetPercent(1));
}
//TODO: change target velocity to target percent

public Command stop() {
return runOnce(() -> motorLeft.setTargetPercent(0));
}
Expand Down
6 changes: 6 additions & 0 deletions src/main/java/frc/robot/util/Neo.java
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,16 @@ public void setTargetPosition(double position) {
setTargetPosition(position, 0, 0);
}

// Creates method to set the target percent of the volatge for the NEO.
public void setTargetPercent(double percent) {
setTargetPercent(percent, 0);
}

Copy link
Member

Choose a reason for hiding this comment

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

If you would like, you can add a javadoc here that explains what the method does. If you don't know exactly how to approach it. Take a look at the SpeedAngleTriplet/ShooterCalc file for inspiration. Thankfully it doesn't do much so it doesn't have to be long and descriptive as some of the ones I linked are.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added some documentation simialr to the one you had for setTargetVelocity but since you had lines 103 & 104 selcted I added a doc to that too. Do you want me to change it or add more?

/**
* Sets the target percent of voltage for the NEO.
* @param percent Percent of battery voltage
Copy link
Member

Choose a reason for hiding this comment

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

Rather than percent of battery voltage, this parameter represents the percent output for the motor. For example, if we give it a 100% input (1) then it will go at 100% speed. If we give it a -50% input, (-0.5) it will go at -50% speed.

* @param slot The PID slot.
*/
public void setTargetPercent(double percent, int slot) {
percent *= reversedMultiplier;
if (percent == 0) {
Expand Down
Loading