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

Colorwheel #2

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
Open

Colorwheel #2

wants to merge 14 commits into from

Conversation

AlonSchwierz
Copy link

אמאשך

@AlonSchwierz AlonSchwierz requested review from Se-gol, adamv17 and barel13 and removed request for Se-gol and adamv17 September 3, 2021 10:45
Copy link
Contributor

@adamv17 adamv17 left a 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();
Copy link
Contributor

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);
Copy link
Contributor

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

/**
* 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 {

Copy link
Contributor

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

Copy link
Member

@barel13 barel13 left a 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;
}
Copy link
Member

Choose a reason for hiding this comment

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

addRequirements()

Comment on lines 34 to 36
if (currentcolor.equals(requestedcolor)) {
return true;
} else return false;
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
if (currentcolor.equals(requestedcolor)) {
return true;
} else return false;
return currentcolor.equals(requestedcolor);


public RotationControl(ColorWheel colorWheel) {
this.colorWheel = colorWheel;
}
Copy link
Member

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()
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
currentcolor = colorwheel.whatcolor()
currentcolor = colorwheel.whatcolor();

Copy link
Member

@katzuv katzuv left a 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;
Copy link
Member

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 {
Copy link
Member

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;
Copy link
Member

Choose a reason for hiding this comment

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

"motor port" is better.

Comment on lines 15 to 17
VictorSPX motor = new VictorSPX(PORT_MOTOR);
ColorSensorV3 sensor = new ColorSensorV3(I2C.Port.kMXP);
ColorMatch match = new ColorMatch();
Copy link
Member

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.

Comment on lines +22 to +25
match.addColorMatch(Color.kYellow); // yellow
match.addColorMatch(Color.kGreen); // green
match.addColorMatch(Color.kRed); // red
match.addColorMatch(Color.kBlue); // blue
Copy link
Member

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);
Copy link
Member

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? 🙂

Comment on lines +38 to +40
if (currentColor.equals(requestedColor)) {
return true;
} else return false;
Copy link
Member

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?

Comment on lines +40 to +44


}


Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
}
}

No need for all this whitespace.

Comment on lines 36 to 38
if (currentColor.equals(startingColor)) {
counter += 0.5;
}
Copy link
Member

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.

Copy link
Member

Choose a reason for hiding this comment

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

In every rotation the same color appears twice.

image

Copy link
Member

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.

Comment on lines +47 to +50
if (counter >= 3) {
return true;
} else
return false;
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants