Skip to content
Open
Changes from all commits
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
23 changes: 15 additions & 8 deletions src/main/java/frc/robot/subsystems/Vision.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,20 +34,27 @@ public Vision() {
}

/**
* Gets an arraylist of all the current "blocks" the camera detects and returns true
* if the largest block's color matches the one inputed
* Gets an arraylist of all the current "blocks" the camera detects and returns the
* largest block that is the same color as requested in the parameters
*
* @param color Color to check if the largest block matches it
* @return Returns true if the colors inputed and of the largest block are the same
* @param color Color to check if the block's color matches it
* @return Returns the largest block of the same color
*/
public boolean getRecentBlocks(Color color) {
public Block getLargestSameColorBlock(Color color) {
// Get data from all blocks and recieve said data
pixyCCC.getBlocks(true, 255, 255);
ArrayList<Block> blocks = pixyCCC.getBlocks();

// Send and gets data from largest block (color)
Color myColor = getBlockColor(blocks.get(0));
return(myColor.equals(color));
// Goes through every block to get largest same color block
Block myBlock = null;
for (Block block: blocks) {
if (color.equals(getBlockColor(block))) {
myBlock = block;
break;
}
}

return(myBlock);
}

/**
Expand Down