Patribots4738 / 2023-Summer-Robot

The summer robotics program at Patrick Henry High in the summer of 2023
Other
2 stars 0 forks source link

Add more constants for PLACEMENT POSITIONS #3

Closed GalexY727 closed 1 year ago

GalexY727 commented 1 year ago

With the addition of shooting forward and backward, we now need to do some more organizing in our PlacementConstants class. I recommend taking all of the values inside of the arrays in placement constants and extracting them into their own value, similar to how Jerome's Arm Indices worked.

Example:

If we wanted to hard code in a automatic pivot stow mechanic (#2), instead of saying

new InstantCommand(() -> pivot.setDesiredRotation(PlacementConstants.PLACEMENT_POSITIONS[PlacementConstants.RESET_INDEX]));

we could simply write

new InstantCommand(() -> pivot.setDesiredRotation(PlacementConstants.RESET_POSITION));

please note that PLACEMENT_POSITIONS,SPEEDS,TIMES,etc are not being removed, they are just changing from a low level storage environment to a step above in abstraction.

i.e.

public static double[] speeds = {
  LOW_SPEED,
  MID_SPEED,
  HIGH_SPEED,
  RESET_SPEED
}

💃

PatribotsProgramming commented 1 year ago

Would this be a good idea? We are already using index in a lot of other parts of our code, why should we switch to use variables instead? Many different parts of our code use the index, changing the constants would break several things in different files.

PatribotsProgramming commented 1 year ago

What is trying to be said here is that instead of having 'hard coded' values, such as:

 public static final double[] PLACEMENT_SPEEDS_BACK = {
        // Low | Index 0
        -0.15,
        // Mid | Index 1
        -0.24,
        // High | Index 2
        -0.4,
        // Reset | Index 3
        0.0

    }; 

instead, write the function like:

public static final double LOW_PLACEMENT_BACK = 270 + 0;
    public static final double MID_PLACEMENT_BACK = 270 - 44;
    public static final double HIGH_PLACEMENT_BACK = 270 - 54;
    public static final double RESET_PLACEMENT_BACK = 78;

    public static final double[] PLACEMENT_POSITIONS_BACK = {
        LOW_PLACEMENT_BACK,
        MID_PLACEMENT_BACK,
        HIGH_PLACEMENT_BACK,
        RESET_PLACEMENT_BACK
    };

sorry for any confusion this post may have caused