Skip to content

Colin's Swerve + Pedro vibe coding spring break#138

Open
kevinfrei wants to merge 2 commits intodetachedfrom
swedro21
Open

Colin's Swerve + Pedro vibe coding spring break#138
kevinfrei wants to merge 2 commits intodetachedfrom
swedro21

Conversation

@kevinfrei
Copy link
Copy Markdown
Member

This is to have a single place to see all the code that Colin coerced out of some poor unsuspecting AI agent...

Copy link
Copy Markdown
Member Author

@kevinfrei kevinfrei left a comment

Choose a reason for hiding this comment

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

Added a bunch of comments on just the changes from the initial (not-working) 'Swedro21' stuff (so only the code you and your not quite competent AI friend wrote 😆)

@explosivegamer25 Please make updates and push the fixes. (I should explain how Git works to you some time...)

subsystem.updateValues(xvalue, yvalue, rvalue);
}

double xvalue = x.getAsDouble();
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Be consistent about the negation: Either do it all at the '.getAsDouble()' line, or do it all in the "updateValues" line. But have one in both places is a weird code smell.

if (gamepad1.crossWasPressed() && flsteer != null){
flsteer.setPower(1);
} else if (gamepad1.crossWasReleased() && flsteer != null){
} else
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I think removing the .crossWasRelease() thing is fine, but you also removevd the "!= null" which will cause a NullPointerException if you don't have SWERVEDRIVE enabled... (Ditto for all the changes in this file...)

@@ -0,0 +1,148 @@
package org.firstinspires.ftc.swervebot.opmodes;
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This whole file is awful. We don't use state-based code. We use Command-based code. Please stop doing this. Schedule the SwerveDriveCmd as a joystick command. If you needed this for validation, that's fine, but I really don't want this in the 'final' code, because it's duplicate work that you've done elsewhere, and it will become either unmaintainable or confusing to other programmers very quickly.

public void uponStart() {
robot.prepForStart();
}

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Whitespace-only changes should be eliminated. The auto-formatter is supposed to take care of this. Not sure why this snuck through. Delete it.

import static org.firstinspires.ftc.swervebot.opmodes.Tuning.stopRobot;
import static org.firstinspires.ftc.swervebot.opmodes.Tuning.telemetryM;


Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

See previous comment about whitespace...

}

// Calculate the desired state for each swerve module
// FIX (Bug 1 & 2): Read encoders FIRST in the module angle loop so that:
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Can you characterize what the bug was that this fixes?

public static double strafeInput = 0;
@Log.Number(name = "R: ")
public static double rotationInput = 0;
@Log.Number(name = "rNeg: ")
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Way.Too.Many.@log's.

Delete them all. Also, names like "A, B, C, E, F, G" are garbage. Name them something real, and put the in a single summary line. (This is AI Slop. Code reviewing already stinks. This makes it worse.)

// drive[i].setPower(wheelPowers[i]);
}
}

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This is just a waste. We already have an array called "wheelPowers". Why are you copying it to new local variables? Just so they get updated in the log. I'm done looking at bad AI Slop, now. Fix this file. I'm going to the next one, ignoring everything else in here.

flswervoenc = new AbsoluteAnalogEncoder(hwmap.get(AnalogInput.class, Setup.HardwareNames.FL_SWERVO_ENCODER));
rlswervoenc = new AbsoluteAnalogEncoder(hwmap.get(AnalogInput.class, Setup.HardwareNames.RL_SWERVO_ENCODER));
rrswervoenc = new AbsoluteAnalogEncoder(hwmap.get(AnalogInput.class, Setup.HardwareNames.RR_SWERVO_ENCODER));
frswervoenc = new AbsoluteAnalogEncoder(hwmap.get(AnalogInput.class, Setup.HardwareNames.FR_SWERVO_ENCODER))
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

AbsoluteAnalogEncoder belongs in TechnoLib (under RobotLibrary) and, when added to TL, should only require the name. (This is leftover from KoolPoool's stuff, but it still should be done. I'm not sure what added value AbsoluteAnalogEncoder provides over ExternalEncoder, since we don't seem to be setting the range.

rlswervoenc = new AbsoluteAnalogEncoder(hwmap.get(AnalogInput.class, Setup.HardwareNames.RL_SWERVO_ENCODER));
rrswervoenc = new AbsoluteAnalogEncoder(hwmap.get(AnalogInput.class, Setup.HardwareNames.RR_SWERVO_ENCODER));
frswervoenc = new AbsoluteAnalogEncoder(hwmap.get(AnalogInput.class, Setup.HardwareNames.FR_SWERVO_ENCODER))
.zero(-2.925);
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Hard coded constants are a big ol' no-no. Document these things and make them static's in Setup or somewhere sensible.

@kevinfrei
Copy link
Copy Markdown
Member Author

@explosivegamer25 if you have questions, start your own review. Click the "+" in the review to add comments.

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.

2 participants