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

Heading control not final tuning, just for code review #14

Open
wants to merge 10 commits into
base: dev
Choose a base branch
from

Conversation

NoraZitnick
Copy link
Collaborator

Heading control works but needs to be tuned, angle wrap around does work. Uses trapezoidal profile and pid.

@NoraZitnick NoraZitnick requested a review from JayK445 December 10, 2024 19:17
Copy link
Collaborator

@JayK445 JayK445 left a comment

Choose a reason for hiding this comment

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

Excited to hear that this is working, but would like workshop the changes and lessen their footprint if possible.


teleopController.acceptJoystickInput(xAxis, yAxis, omega);
}
}
/*radians*/
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we decouple the "heading control" functionality from the pre-existing teleop control function? Grouping them may cause confusion later down the line (esp. for integrating in autos, etc.).

(ie. create a single setHeadingLock(), push integration with teleop to RobotContainer)

Copy link
Collaborator

Choose a reason for hiding this comment

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

Consider using a supplier to pass in the target(s).

@@ -99,10 +107,39 @@ public void driveTeleopController(double xAxis, double yAxis, double omega) {
if (driveMode != DriveModes.TELEOP) {
driveMode = DriveModes.TELEOP;
}
if (headingController != null) {
headingController = null;
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

What is the purpose of this statement?

targetRotation2d = new Rotation2d(targetRotation2d.getRadians() + delta);
}

public Rotation2d update(Rotation2d yaw, double currentRotationalVelocity) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

What is the purpose of currentRotationalVelocity? It doesn't appear to be used yet.

public ChassisSpeeds update(Rotation2d yaw) {
Translation2d linearVelocity = calculateLinearVelocity(controllerX, controllerY);

double omega = MathUtil.applyDeadband(controllerOmega, 0.1);
double omega = controllerOmega;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why remove the deadband?

}

public Rotation2d update(Rotation2d yaw, double currentRotationalVelocity) {
Logger.recordOutput("Swerve/TargetHeading", normalizeRadians(targetRotation2d.getRadians()));
Copy link
Collaborator

Choose a reason for hiding this comment

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

Consider applying normalizeRadians() in setTarget(). We want data logged to be the same as what is used.

return a < b ? a : -b;
}

public double normalizeRadians(double radians) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this supposed to be private?

@@ -96,10 +97,12 @@ private void configureBindings() {
swerve
.run(
() -> {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we break up the operations here?
(ie. calculate the "heading" separately, etc)

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