-
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
Colorwheel #2
base: master
Are you sure you want to change the base?
Colorwheel #2
Conversation
src/main/java/frc/robot/subsystems/colorwheel/commands/ColorReach.java
Outdated
Show resolved
Hide resolved
src/main/java/frc/robot/subsystems/colorwheel/commands/RotationControl.java
Outdated
Show resolved
Hide resolved
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 code is really good and concise, I think this would already work on the robot.
private String lastcolor = ""; | ||
|
||
public String whatcolor() { | ||
Color color = sensor.getColor(); |
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 is the right idea using the color matcher, but you don't want the match.addColorMatch here. Instead create a constructor (פעולה בונה) and put the code there, that way it will run once and not every time you run the function.
|
||
@Override | ||
public void execute() { | ||
colorWheel.setpower(0.5); |
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 code looks very good, I would just make the 0.5 value a constant
src/main/java/frc/robot/subsystems/colorwheel/commands/RotationControl.java
Outdated
Show resolved
Hide resolved
/** | ||
* This class is where the bulk of the robot should be declared. Since Command-based is a | ||
* "declarative" paradigm, very little robot logic should actually be handled in the {@link Robot} | ||
* periodic methods (other than the scheduler calls). Instead, the structure of the robot | ||
* (including subsystems, commands, and button mappings) should be declared here. | ||
*/ | ||
public class RobotContainer { | ||
|
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 buttons and implement the commands
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.
Nice work, You just need to document the functions. And please don't write in the description of this PR אמאשך.
public ColorReach(ColorWheel colorWheel, String requestedcolor) { | ||
this.colorwheel = colorWheel; | ||
this.requestedcolor = requestedcolor; | ||
} |
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.
addRequirements()
if (currentcolor.equals(requestedcolor)) { | ||
return true; | ||
} else return false; |
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.
if (currentcolor.equals(requestedcolor)) { | |
return true; | |
} else return false; | |
return currentcolor.equals(requestedcolor); |
|
||
public RotationControl(ColorWheel colorWheel) { | ||
this.colorWheel = colorWheel; | ||
} |
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.
addRequirements()
@Override | ||
public void execute() { | ||
colorwheel.setpower(0.5); | ||
currentcolor = colorwheel.whatcolor() |
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.
currentcolor = colorwheel.whatcolor() | |
currentcolor = colorwheel.whatcolor(); | |
5f7a259
to
9976b8b
Compare
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.
Keep up the good work! 😄
@@ -16,4 +16,8 @@ | |||
* constants are needed, to reduce verbosity. | |||
*/ | |||
public final class Constants { | |||
|
|||
public final class ColorWheel { | |||
public static final double power = 0.5; |
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.
Constant should be written in ALL_CAPS_WITH_UNDERSCORES
.
@@ -0,0 +1,8 @@ | |||
package frc.robot; | |||
|
|||
public class Pot { |
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.
Did you mean "ports"?
|
||
public class Pot { | ||
public static class ColorWheel { | ||
public static final int PORT_MOTOR = 0; |
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.
"motor port" is better.
VictorSPX motor = new VictorSPX(PORT_MOTOR); | ||
ColorSensorV3 sensor = new ColorSensorV3(I2C.Port.kMXP); | ||
ColorMatch match = new ColorMatch(); |
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.
All of these should be private.
match.addColorMatch(Color.kYellow); // yellow | ||
match.addColorMatch(Color.kGreen); // green | ||
match.addColorMatch(Color.kRed); // red | ||
match.addColorMatch(Color.kBlue); // blue |
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 comments are redundant, if you use kYellow
you don't need to comment that means the color "yellow".
|
||
@Override | ||
public void execute() { | ||
colorWheel.setPower(0.5); |
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've declared a constant with this value, why not use it? 🙂
if (currentColor.equals(requestedColor)) { | ||
return true; | ||
} else return false; |
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 can be shortened to one line. If you don't have an idea, here's a clue: What type of value does equals()
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.
} | |
} | |
No need for all this whitespace.
if (currentColor.equals(startingColor)) { | ||
counter += 0.5; | ||
} |
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.
Why are incrementing in only 0.5? In isFinished
you check whether the counter >= 3
. This means you'll stop only when the Control Panel reaches six full rotations, and that's too high.
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.
Right, I forgot, I thought there are only four.
if (counter >= 3) { | ||
return true; | ||
} else | ||
return false; |
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 can be shortened to one line too, in the same way as I commented on above.
אמאשך